]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
4 years agoc++: consteval and explicit instantiation [PR96905]
Jason Merrill [Mon, 8 Feb 2021 22:16:14 +0000 (17:16 -0500)] 
c++: consteval and explicit instantiation [PR96905]

Normally, an explicit instantiation means we want to write out the
instantiation.  But not for a consteval function.

gcc/cp/ChangeLog:

PR c++/96905
* pt.c (mark_decl_instantiated): Exit early if consteval.

gcc/testsuite/ChangeLog:

PR c++/96905
* g++.dg/cpp2a/consteval-expinst1.C: New test.

4 years agoc++: generic lambda, fn* conv, empty class [PR98326]
Jason Merrill [Mon, 8 Feb 2021 22:04:03 +0000 (17:04 -0500)] 
c++: generic lambda, fn* conv, empty class [PR98326]

Here, in the thunk returned from the captureless lambda conversion to
pointer-to-function, we try to pass through invisible reference parameters
by reference, without doing a copy.  The empty class copy optimization was
messing that up.

gcc/cp/ChangeLog:

PR c++/98326
PR c++/20408
* cp-gimplify.c (simple_empty_class_p): Don't touch an invisiref
parm.

gcc/testsuite/ChangeLog:

PR c++/98326
* g++.dg/cpp1y/lambda-generic-empty1.C: New test.

4 years agoDaily bump.
GCC Administrator [Fri, 12 Feb 2021 00:17:08 +0000 (00:17 +0000)] 
Daily bump.

4 years agoc++: Endless loop with targ deduction in member tmpl [PR95888]
Marek Polacek [Tue, 9 Feb 2021 20:17:48 +0000 (15:17 -0500)] 
c++: Endless loop with targ deduction in member tmpl [PR95888]

My r10-7007 patch tweaked tsubst not to reduce the template level of
template parameters when tf_partial.  That caused infinite looping in
is_specialization_of: we ended up with a class template specialization
whose TREE_TYPE (CLASSTYPE_TI_TEMPLATE (t)) == t, so the second for
loop in is_specialization_of never finished.

There's a lot going on in this test, but essentially: the template fn
here has two template parameters, we call it with one explicitly
provided, the other one has to be deduced.  So we'll find ourselves
in fn_type_unification which uses tf_partial when tsubsting the
*explicit* template arguments into the function type.  That leads to
tsubstituting the return type, C<T>.  C is a member template; its
most general template is

  template<class U> template<class V> struct B<U>::C

we figure out (tsubst_template_args) that the template argument list
is <int, int>.  They come from different levels, one comes from B<int>,
the other one from fn<int>.

So now we lookup_template_class to see if we have C<int, int>.  We
do the
  /* This is a full instantiation of a member template.  Find
     the partial instantiation of which this is an instance.  */
  TREE_VEC_LENGTH (arglist)--;
  // arglist is now <int>, not <int, int>
  found = tsubst (gen_tmpl, arglist, complain, NULL_TREE);
  TREE_VEC_LENGTH (arglist)++;

magic which is looking for the partial instantiation, in this case,
that would be template<class V> struct B<int>::C.  Note we're still
in a tf_partial context!  So the tsubst_template_args in the tsubst
(which tries to substitute <int> into <U, V>) returns <int, V>, but
V's template level hasn't been reduced!  After tsubst_template_args,
tsubst_template_decl looks to see if we already have this specialization:

  // t = template_decl C
  // full_args = <int, V>
  spec = retrieve_specialization (t, full_args, hash);

but doesn't find the one we created a while ago, when processing
B<int> b; in the test, because V's levels don't match.  Whereupon
tsubst_template_decl creates a new TEMPLATE_DECL, one that leads to
the infinite looping problem.

Fixed by using tf_none when looking for an existing partial instantiation.

It also occurred to me that I should be able to trigger a similar
problem with 'auto', since r10-7007 removed an is_auto check.  And lo,
I constructed deduce10.C which exhibits the same issue with pre-r10-7007
compilers.  This patch fixes that problem as well.  I'm ecstatic.

gcc/cp/ChangeLog:

PR c++/95888
* pt.c (lookup_template_class_1): Pass tf_none to tsubst when looking
for the partial instantiation.

gcc/testsuite/ChangeLog:

PR c++/95888
* g++.dg/template/deduce10.C: New test.
* g++.dg/template/deduce9.C: New test.

(cherry picked from commit 88cfd531c69b3c1fe7a3c183d83cfeacc8f69402)

4 years agoFix -freorder-blocks-and-partition glitch with Windows SEH
Eric Botcazou [Thu, 11 Feb 2021 23:16:49 +0000 (00:16 +0100)] 
Fix -freorder-blocks-and-partition glitch with Windows SEH

Since GCC 8, the -freorder-blocks-and-partition pass can split a function
into hot and cold parts, thus generating 2 CIEs for a single function in
DWARF for exception purposes and doing an equivalent trick for Windows SEH.

Now the Windows system unwinder is picky when it comes to the boundary
between an active EH region and the end of the function and, therefore,
a nop may need to be added in specific cases.

gcc/
* config/i386/winnt.c (i386_pe_seh_unwind_emit): When switching to
the cold section, emit a nop before the directive if the previous
active instruction can throw.

4 years agoFortran: Fix calls to associate name typebound subroutines [PR98897].
Paul Thomas [Thu, 11 Feb 2021 13:24:50 +0000 (13:24 +0000)] 
Fortran: Fix calls to associate name typebound subroutines [PR98897].

2021-02-11  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/98897
* match.c (gfc_match_call): Include associate names as possible
entities with typebound subroutines. The target needs to be
resolved for the type.

gcc/testsuite/
PR fortran/98897
* gfortran.dg/typebound_call_32.f90: New test.

(cherry picked from commit ff6903288d96aa1d28ae4912b1270985475f3ba8)

4 years agoFortran: Fix ICE after error regression [PR99060].
Paul Thomas [Thu, 11 Feb 2021 10:38:23 +0000 (10:38 +0000)] 
Fortran: Fix ICE after error regression [PR99060].

2021-02-11  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/99060
* primary.c (gfc_match_varspec): Test for non-null 'previous'
before using its name in the error message.

gcc/testsuite/
PR fortran/99060
* gfortran.dg/pr99060.f90: New test.

(cherry picked from commit 5ee5415af8691640b0f7a5332b78d04ba309f4f0)

4 years agoDaily bump.
GCC Administrator [Thu, 11 Feb 2021 00:17:17 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Wed, 10 Feb 2021 00:17:23 +0000 (00:17 +0000)] 
Daily bump.

4 years agoFix miscompilation of Python on HP-PA/Linux
Eric Botcazou [Tue, 9 Feb 2021 18:49:18 +0000 (19:49 +0100)] 
Fix miscompilation of Python on HP-PA/Linux

This is the miscompilation of Python at -O2 on HP-PA/Linux present
on the mainline and 10 branch, caused by the presence of a call to
__builtin_unreachable () in the middle of a heavily branchy code,
which confuses the reorg pass.

gcc/
PR rtl-optimization/96015
* reorg.c (skip_consecutive_labels): Minor comment tweaks.
(relax_delay_slots): When deleting a jump to the next active
instruction over a barrier, first delete the barrier if the
jump is the only way to reach the target label.

4 years agolibstdc++: Make coroutine_handle<_Promise>::from_address() noexcept [PR 99021]
Jonathan Wakely [Tue, 9 Feb 2021 11:23:29 +0000 (11:23 +0000)] 
libstdc++: Make coroutine_handle<_Promise>::from_address() noexcept [PR 99021]

The coroutine_handle<void>::from_address(void*) version is already
noexcept, and they do the same thing. Make them consistent.

libstdc++-v3/ChangeLog:

PR libstdc++/99021
* include/std/coroutine (coroutine_handle<P>::from_address): Add
noexcept.

(cherry picked from commit 26a3f288f1895a8c061c0458590542a3d2ee796a)

4 years agoDaily bump.
GCC Administrator [Tue, 9 Feb 2021 00:17:13 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Mon, 8 Feb 2021 00:17:18 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sun, 7 Feb 2021 00:17:24 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sat, 6 Feb 2021 00:17:23 +0000 (00:17 +0000)] 
Daily bump.

4 years agoc++: Empty args for variadic concept [PR98717]
Jason Merrill [Thu, 4 Feb 2021 16:46:45 +0000 (11:46 -0500)] 
c++: Empty args for variadic concept [PR98717]

Nice when fixing a bug is as easy as removing incorrect checks.

gcc/cp/ChangeLog:

PR c++/98717
* constraint.cc (build_concept_check_arguments): Remove assert.
(build_concept_check): Allow empty args.

gcc/testsuite/ChangeLog:

PR c++/98717
* g++.dg/cpp2a/concepts-variadic3.C: New test.

4 years agoDaily bump.
GCC Administrator [Fri, 5 Feb 2021 00:17:08 +0000 (00:17 +0000)] 
Daily bump.

4 years ago[PR97701] LRA: Don't narrow class only for REG or MEM. A version modified for gcc-10.
Vladimir N. Makarov [Thu, 4 Feb 2021 20:57:55 +0000 (15:57 -0500)] 
[PR97701] LRA: Don't narrow class only for REG or MEM.  A version modified for gcc-10.

This is modified version of the patch committed for the trunk.  The
modification for gcc-10 includes lra-constraint.c code and the test.

gcc/ChangeLog:

PR target/97701
* lra-constraints.c (in_class_p): Don't narrow class only for REG
or MEM.

gcc/testsuite/ChangeLog:

PR target/97701
* gcc.target/aarch64/pr97701.c: New.

4 years agoc++: No aggregate CTAD with explicit dguide [PR98802]
Jason Merrill [Thu, 4 Feb 2021 02:56:59 +0000 (21:56 -0500)] 
c++: No aggregate CTAD with explicit dguide [PR98802]

In my implementation of P2082R1 I missed this piece: the aggregate deduction
candidate is not generated if the class has user-written deduction guides.

gcc/cp/ChangeLog:

PR c++/98802
* pt.c (deduction_guides_for): Add any_dguides_p parm.
(do_class_deduction): No aggregate guide if any_dguides_p.

gcc/testsuite/ChangeLog:

PR c++/98802
* g++.dg/cpp1z/class-deduction78.C: New test.

4 years agoDaily bump.
GCC Administrator [Thu, 4 Feb 2021 00:17:13 +0000 (00:17 +0000)] 
Daily bump.

4 years agotestsuite: Add test for already fixed PR [PR97804]
Jakub Jelinek [Wed, 3 Feb 2021 16:14:40 +0000 (17:14 +0100)] 
testsuite: Add test for already fixed PR [PR97804]

This testcase got fixed with the PR98463
r11-6895-g94ff4c9dd98f39280fba22d1ad0958fb25a5363b fix.

2021-02-03  Jakub Jelinek  <jakub@redhat.com>

PR c++/97804
* g++.dg/cpp2a/no_unique_address11.C: New test.

4 years agopreprocessor: Make quoting : [PR 95253]
Nathan Sidwell [Fri, 15 Jan 2021 14:47:13 +0000 (06:47 -0800)] 
preprocessor: Make quoting : [PR 95253]

Make doesn't need ':' quoting (in a filename).

PR preprocessor/95253
libcpp/
* mkdeps.c (munge): Do not escape ':'.

4 years agortl-optimization/98863 - tame i386 specific RPAD pass
Richard Biener [Fri, 29 Jan 2021 15:02:36 +0000 (16:02 +0100)] 
rtl-optimization/98863 - tame i386 specific RPAD pass

This removes analyzing DF with expensive problems which we do not
use at all and which somehow cause 5GB of memory to leak.  Instead
just do a defered rescan of added insns.

This avoids

> FAIL: gcc.c-torture/compile/20051216-1.c   -O1  (internal compiler error)
> FAIL: gcc.c-torture/compile/20051216-1.c   -O1  (test for excess errors)

by clearing DF_DEFER_INSN_RESCAN after calling df_process_deferred_rescans,
so that it doesn't leak into following unprepared passes that expect
non-deferred rescans.

2021-02-03  Richard Biener  <rguenther@suse.de>
    Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/98863
* config/i386/i386-features.c (remove_partial_avx_dependency):
Do not perform DF analysis.
(pass_data_remove_partial_avx_dependency): Remove
TODO_df_finish.

* gcc.target/i386/20051216-1.c: New test.

4 years agoFix regression with partial rep clause on variant record type
Eric Botcazou [Wed, 3 Feb 2021 10:38:04 +0000 (11:38 +0100)] 
Fix regression with partial rep clause on variant record type

It can yield an incorrect layout when there is a partial representation
clause on a discriminated record type with a variant part.

gcc/ada/
* gcc-interface/decl.c (components_to_record): If the first component
with rep clause is the _Parent field with variable size, temporarily
set it aside when computing the internal layout of the REP part again.
* gcc-interface/utils.c (finish_record_type): Revert to taking the
maximum when merging sizes for all record types with rep clause.
(merge_sizes): Put SPECIAL parameter last and adjust recursive calls.

4 years agoAssorted LTO fixes for Ada
Eric Botcazou [Wed, 3 Feb 2021 10:11:26 +0000 (11:11 +0100)] 
Assorted LTO fixes for Ada

This polishes a few rough edges visible in LTO mode.

gcc/ada/
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Make the
two fields of the fat pointer type addressable, and do not make the
template type read-only.
<E_Record_Type>: If the type has discriminants mark it as may_alias.
* gcc-interface/utils.c (make_dummy_type): Likewise.
(build_dummy_unc_pointer_types): Likewise.

4 years agortl-optimization/98863 - prune RD with LIVE in STV
Richard Biener [Mon, 1 Feb 2021 08:18:43 +0000 (09:18 +0100)] 
rtl-optimization/98863 - prune RD with LIVE in STV

This sets DF_RD_PRUNE_DEAD_DEFS like all other uses of the UD/DU
chain problems which makes the RD problem consume a lot less memory.

2021-02-01  Richard Biener  <rguenther@suse.de>

PR rtl-optimization/98863
* config/i386/i386-features.c (convert_scalars_to_vector):
Set DF_RD_PRUNE_DEAD_DEFS.

(cherry picked from commit 972918eea873f8b1663151316c4b3aee7ae028e2)

4 years agortl-optimization/98144 - tame REE memory usage
Richard Biener [Fri, 29 Jan 2021 09:23:40 +0000 (10:23 +0100)] 
rtl-optimization/98144 - tame REE memory usage

This changes the REE dataflow to change the explicit all-ones
starting solution to be implicit via a visited flag, removing
the need to initially start with fully populated bitmaps for
all basic-blocks.  That reduces peak memory use when compiling
the RTL checking enabled insn-extract.c testcase from PR98144
from 6GB to less than 2GB.

2021-01-29  Richard Biener  <rguenther@suse.de>

PR rtl-optimization/98144
* df.h (df_mir_bb_info): Add con_visited member.
* df-problems.c (df_mir_alloc): Initialize con_visited,
do not fully populate IN and OUT.
(df_mir_reset): Likewise.
(df_mir_confluence_0): Set con_visited.
(df_mir_confluence_n): Properly handle implicitely
fully populated IN and OUT as designated by con_visited
and update con_visited accordingly.

(cherry picked from commit a8c455bafdefdab0a7b8cdbcdb116c0086bae05e)

4 years agoDaily bump.
GCC Administrator [Wed, 3 Feb 2021 00:17:13 +0000 (00:17 +0000)] 
Daily bump.

4 years agoc++: Fix ICE from verify_ctor_sanity [PR98295]
Patrick Palka [Mon, 1 Feb 2021 15:27:45 +0000 (10:27 -0500)] 
c++: Fix ICE from verify_ctor_sanity [PR98295]

In this testcase we're crashing during constexpr evaluation of the
ARRAY_REF b[0] as part of evaluation of the lambda's by-copy capture of b
(which is encoded as a VEC_INIT_EXPR<b>).  Since A's constexpr default
constructor is not yet defined, b's initialization is not actually
constant, but because A is an empty type, evaluation of b from
cxx_eval_array_ref is successful and yields an empty CONSTRUCTOR.
And since this CONSTRUCTOR is empty, we {}-initialize the desired array
element, and end up crashing from verify_ctor_sanity during evaluation
of this initializer because we updated new_ctx.ctor without updating
new_ctx.object: the former now has type A[3] and the latter is still the
target of a TARGET_EXPR for b[0][0] created from cxx_eval_vec_init
(and so has type A).

This patch fixes this by setting new_ctx.object appropriately at the
same time that we set new_ctx.ctor from cxx_eval_array_reference.

gcc/cp/ChangeLog:

PR c++/98295
* constexpr.c (cxx_eval_array_reference): Also set
new_ctx.object when setting new_ctx.ctor.

gcc/testsuite/ChangeLog:

PR c++/98295
* g++.dg/cpp0x/constexpr-98295.C: New test.

(cherry picked from commit 7e534fb7d8256a605b6bdc12451d209af1bed329)

4 years agod: Fix junk in generated symbol on powerpc64-*-* [PR98921]
Iain Buclaw [Mon, 1 Feb 2021 23:52:49 +0000 (00:52 +0100)] 
d: Fix junk in generated symbol on powerpc64-*-* [PR98921]

This adds a special formatter to OutBuffer to handle formatted printing
of integers, a common case.  The replacement is faster and safer.

In dmangle.c, it also gets rid of a number of problematic casts, as seen
on powerpc64 targets.

gcc/d/ChangeLog:

PR d/98921
* dmd/dmangle.c (Mangler::visit (TypeSArray *)): Use buf->print
  to format integer value.
(Mangler::visit (TypeIdentifier *)): Likewise.
(Mangler::toBuffer): Likewise.
(Mangler::visit (IntegerExp *)): Likewise.
(Mangler::visit (StringExp *)): Likewise.
(Mangler::visit (ArrayLiteralExp *)): Likewise.
(Mangler::visit (AssocArrayLiteralExp *)): Likewise.
(Mangler::visit (StructLiteralExp *)): Likewise.
* dmd/root/outbuffer.c (OutBuffer::print): New function.
* dmd/root/outbuffer.h (OutBuffer::print): Declare.

(cherry picked from commit 6a481021a65d6237b0c509a76fcd9c1f32c4558e)

4 years agoDaily bump.
GCC Administrator [Tue, 2 Feb 2021 00:17:13 +0000 (00:17 +0000)] 
Daily bump.

4 years agoc++: Improve sorry for __builtin_has_attribute [PR98355]
Marek Polacek [Fri, 29 Jan 2021 16:29:25 +0000 (11:29 -0500)] 
c++: Improve sorry for __builtin_has_attribute [PR98355]

__builtin_has_attribute doesn't work in templates yet (bug 92104), so
in r11-471 I added a sorry.  But that only caught type-dependent
expressions and we also want to sorry on value-dependent expressions.
This patch uses uses_template_parms, but guarded with p_t_d, because
u_t_p sets p_t_d and then v_d_e_p considers variables with reference
types value-dependent, which breaks builtin-has-attribute-6.c.

This is a regression and I also plan to apply this to gcc-10.

gcc/cp/ChangeLog:

PR c++/98355
* parser.c (cp_parser_has_attribute_expression): Use
uses_template_parms instead of type_dependent_expression_p.

gcc/testsuite/ChangeLog:

PR c++/98355
* g++.dg/ext/builtin-has-attribute2.C: New test.

(cherry picked from commit bab669f2fc643cb1673aecd177eec1c773e9e48e)

4 years agoc++: cxx_eval_vec_init after zero-initialization [PR96282]
Patrick Palka [Wed, 5 Aug 2020 19:05:30 +0000 (15:05 -0400)] 
c++: cxx_eval_vec_init after zero-initialization [PR96282]

In the first testcase below, expand_aggr_init_1 sets up t's default
constructor such that the ctor first zero-initializes the entire base b,
followed by calling b's default constructor, the latter of which just
default-initializes the array member b::m via a VEC_INIT_EXPR.

So upon constexpr evaluation of this latter VEC_INIT_EXPR, ctx->ctor is
nonempty due to the prior zero-initialization, and we proceed in
cxx_eval_vec_init to append new constructor_elts to the end of ctx->ctor
without first checking if a matching constructor_elt already exists.
This leads to ctx->ctor having two matching constructor_elts for each
index.

This patch fixes this issue by truncating a zero-initialized array
CONSTRUCTOR in cxx_eval_vec_init_1 before we begin appending array
elements to it.  We propagate its zeroed out state during evaluation by
clearing CONSTRUCTOR_NO_CLEARING on each new appended aggregate element.

gcc/cp/ChangeLog:

PR c++/96282
* constexpr.c (cxx_eval_vec_init_1): Truncate ctx->ctor and
then clear CONSTRUCTOR_NO_CLEARING on each appended element
initializer if we're initializing a previously zero-initialized
array object.

gcc/testsuite/ChangeLog:

PR c++/96282
* g++.dg/cpp0x/constexpr-array26.C: New test.
* g++.dg/cpp0x/constexpr-array27.C: New test.
* g++.dg/cpp2a/constexpr-init18.C: New test.

Co-authored-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit d21252de6c81ed236d8981d47b9a57dc4f1c6d57)

4 years agortl-optimization/98863 - fix PRE/CPROP memory usage check
Richard Biener [Fri, 29 Jan 2021 12:25:49 +0000 (13:25 +0100)] 
rtl-optimization/98863 - fix PRE/CPROP memory usage check

This fixes overflow of the memory usage estimate in turn failing
to disable itself on WRF with LTO, causing a few GBs worth of
memory peak.

2021-01-29  Richard Biener  <rguenther@suse.de>

PR rtl-optimization/98863
* gcse.c (gcse_or_cprop_is_too_expensive): Use unsigned
HOST_WIDE_INT for the memory estimate.

(cherry picked from commit cb52e59e33845152cef6f9042a142a246e9447f6)

4 years agoPR target/96307: Fix KASAN option checking.
Kito Cheng [Mon, 5 Oct 2020 06:01:04 +0000 (14:01 +0800)] 
PR target/96307: Fix KASAN option checking.

 - Disable kasan if target is unsupported and -fasan-shadow-offset= is not
   given, no matter `--param asan-stack=1` is given or not.

 - Moving KASAN option checking testcase to gcc.dg, those testcase could be
   useful for all other target which not support asan.

 - Verifed on riscv and x86.

gcc/ChangeLog:

PR target/96307
* toplev.c (process_options): Remove param_asan_stack checking for kasan
option checking.

gcc/testsuite/ChangeLog:

PR target/96307
* gcc.dg/pr96307.c: New.
* gcc.target/riscv/pr96260.c: Move this test case from here to ...
* gcc.dg/pr96260.c: ... here.
* gcc.target/riscv/pr91441.c: Move this test case from here to ...
* gcc.dg/pr91441.c: ... here.
* lib/target-supports.exp (check_effective_target_no_fsanitize_address):
New proc.

(cherry picked from commit 65e82636bcdb72a878c2e53943e71b15dd9fb22d)

4 years agoDaily bump.
GCC Administrator [Mon, 1 Feb 2021 00:17:00 +0000 (00:17 +0000)] 
Daily bump.

4 years agoAdd missing definition of SIZE_MAX
Eric Botcazou [Sun, 31 Jan 2021 22:23:31 +0000 (23:23 +0100)] 
Add missing definition of SIZE_MAX

If the stdint.h system file follows the ISO C99 specification, it might
not define SIZE_MAX in C++ by default, so provide a local fallback.

gcc/
* system.h (SIZE_MAX): Define if not already defined.

4 years agoDaily bump.
GCC Administrator [Sun, 31 Jan 2021 00:17:06 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sat, 30 Jan 2021 00:17:19 +0000 (00:17 +0000)] 
Daily bump.

4 years agoexpand: Fix up find_bb_boundaries [PR98331]
Jakub Jelinek [Fri, 29 Jan 2021 09:30:09 +0000 (10:30 +0100)] 
expand: Fix up find_bb_boundaries [PR98331]

When expansion emits some control flow insns etc. inside of a former GIMPLE
basic block, find_bb_boundaries needs to split it into multiple basic
blocks.
The code needs to ignore debug insns in decisions how many splits to do or
where in between some non-debug insns the split should be done, but it can
decide where to put debug insns if they can be kept and otherwise throws
them away (they can't stay outside of basic blocks).
On the following testcase, we end up in the bb from expander with
control flow insn
debug insns
barrier
some other insn
(the some other insn is effectively dead after __builtin_unreachable and
we'll optimize that out later).
Without debug insns, we'd do the split when encountering some other insn
and split after PREV_INSN (some other insn), i.e. after barrier (and the
splitting code then moves the barrier in between basic blocks).
But if there are debug insns, we actually split before the first debug insn
that appeared after the control flow insn, so after control flow insn,
and get a basic block that starts with debug insns and then has a barrier
in the middle that nothing moves it out of the bb.  This leads to ICEs and
even if it wouldn't, different behavior from -g0.
The reason for treating debug insns that way is a different case, e.g.
control flow insn
debug insns
some other insn
or even
control flow insn
barrier
debug insns
some other insn
where splitting before the first such debug insn allows us to keep them
while otherwise we would have to drop them on the floor, and in those
situations we behave the same with -g0 and -g.

So, the following patch fixes it by resetting debug_insn not just when
splitting the blocks (it is set only after seeing a control flow insn and
before splitting for it if needed), but also when seeing a barrier,
which effectively means we always throw away debug insns after a control
flow insn and before following barrier if any, but there is no way around
that, control flow insn must be the last in the bb (BB_END) and BARRIER
after it, debug insns aren't allowed outside of bb.
We still handle the other cases fine (when there is no barrier or when
debug insns appear only after the barrier).

2021-01-29  Jakub Jelinek  <jakub@redhat.com>

PR debug/98331
* cfgbuild.c (find_bb_boundaries): Reset debug_insn when seeing
a BARRIER.

* gcc.dg/pr98331.c: New test.

4 years agoc++: Fix up handling of register ... asm ("...") vars in templates [PR33661, PR98847]
Jakub Jelinek [Thu, 28 Jan 2021 15:13:11 +0000 (16:13 +0100)] 
c++: Fix up handling of register ... asm ("...") vars in templates [PR33661, PR98847]

As the testcase shows, for vars appearing in templates, we don't attach
the asm spec string to the pattern decls, nor pass it back to cp_finish_decl
during instantiation.

The following patch does that.

2021-01-28  Jakub Jelinek  <jakub@redhat.com>

PR c++/33661
PR c++/98847
* decl.c (cp_finish_decl): For register vars with asmspec in templates
call set_user_assembler_name and set DECL_HARD_REGISTER.
* pt.c (tsubst_expr): When instantiating DECL_HARD_REGISTER vars,
pass asmspec_tree to cp_finish_decl.

* g++.target/i386/pr98847.C: New test.

4 years agoaarch64: Fix up *aarch64_bfxilsi_uxtw [PR98853]
Jakub Jelinek [Wed, 27 Jan 2021 19:35:21 +0000 (20:35 +0100)] 
aarch64: Fix up *aarch64_bfxilsi_uxtw [PR98853]

The https://gcc.gnu.org/legacy-ml/gcc-patches/2018-07/msg01895.html
patch that introduced this pattern claimed:
Would generate:

combine_balanced_int:
        bfxil   w0, w1, 0, 16
        uxtw    x0, w0
        ret

But with this patch generates:

combine_balanced_int:
        bfxil   w0, w1, 0, 16
        ret
and it is indeed what it should generate, but it doesn't do that,
it emits bfxil  x0, x1, 0, 16
instead which doesn't zero extend from 32 to 64 bits, but preserves
the bits from the destination register.

2021-01-27  Jakub Jelinek  <jakub@redhat.com>

PR target/98853
* config/aarch64/aarch64.md (*aarch64_bfxilsi_uxtw): Use
%w0, %w1 and %2 instead of %0, %1 and %2.

* gcc.c-torture/execute/pr98853-1.c: New test.
* gcc.c-torture/execute/pr98853-2.c: New test.

4 years agoaarch64: Tighten up checks for ubfix [PR98681]
Jakub Jelinek [Tue, 26 Jan 2021 13:48:26 +0000 (14:48 +0100)] 
aarch64: Tighten up checks for ubfix [PR98681]

The testcase in the patch doesn't assemble, because the instruction requires
that the penultimate operand (lsb) range is [0, 32] (or [0, 64]) and the last
operand's range is [1, 32 - lsb] (or [1, 64 - lsb]).
The INTVAL (shft_amnt) < GET_MODE_BITSIZE (mode) will accept the lsb operand
to be in range [MIN, 32] (or [MIN, 64]) and then we invoke UB in the
compiler and sometimes it will make it through.
The patch changes all the INTVAL uses in that function to UINTVAL,
which isn't strictly necessary, but can be done (e.g. after the
UINTVAL (shft_amnt) < GET_MODE_BITSIZE (mode) check we know it is not
negative and thus INTVAL (shft_amnt) and UINTVAL (shft_amnt) then behave the
same.  But, I had to add INTVAL (mask) > 0 check in that case, otherwise we
risk (hypothetically) emitting instruction that doesn't assemble.
The problem is with masks that have the MSB bit set, while the instruction
can handle those, e.g.
ubfiz w1, w0, 13, 19
will do
(w0 << 13) & 0xffffe000
in RTL we represent SImode constants with MSB set as negative HOST_WIDE_INT,
so it will actually be HOST_WIDE_INT_C (0xffffffffffffe000), and
the instruction uses %P3 to print the last operand, which calls
asm_fprintf (f, "%u", popcount_hwi (INTVAL (x)))
to print that.  But that will not print 19, but 51 instead, will include
there also all the copies of the sign bit.
Not supporting those masks with MSB set isn't a big loss though, they really
shouldn't appear normally, as both GIMPLE and RTL optimizations should
optimize those away (one isn't masking any bits off with such masks, so
just w0 << 13 will do too).

2021-01-26  Jakub Jelinek  <jakub@redhat.com>

PR target/98681
* config/aarch64/aarch64.c (aarch64_mask_and_shift_for_ubfiz_p):
Use UINTVAL (shft_amnt) and UINTVAL (mask) instead of INTVAL (shft_amnt)
and INTVAL (mask).  Add && INTVAL (mask) > 0 condition.

* gcc.c-torture/execute/pr98681.c: New test.

4 years agofold: Fix up strn{case,}cmp folding [PR98771]
Jakub Jelinek [Mon, 25 Jan 2021 09:03:40 +0000 (10:03 +0100)] 
fold: Fix up strn{case,}cmp folding [PR98771]

As mentioned in the PR, the compiler behaves differently during strncmp
and strncasecmp folding between 32-bit and 64-bit hosts targeting 64-bit
target.  I think that is highly undesirable.

The culprit is the host_size_t_cst_p predicate that is used by
fold_const_call, which punts if the target size_t constants don't fit into
host size_t.  This patch gets rid of that behavior, instead it punts the
same when it doesn't fit into uhwi.

The predicate was used for strncmp and strncasecmp folding and for bcmp, memcmp and
memchr folding.
The constant is in all cases compared to 0, we can do that whether it fits
into size_t or unsigned HOST_WIDE_INT, then it is used in s2 <= s0 or
s2 <= s1 comparisons where s0 and s1 already have uhwi type and represent
the sizes of the objects.
The important difference is for strn{,case}cmp folding, we pass that s2
value as the last argument to the host functions comparing the c_getstr
results.  If s2 fits into size_t, then my patch makes no difference,
but if it is larger, we know the 2 c_getstr objects need to fit into the
host address space, so larger s2 should just act essentially as strcmp
or strcasecmp; as none of those objects can occupy 100% of the address
space, using MIN (SIZE_MAX, s2) achieves that.

2021-01-25  Jakub Jelinek  <jakub@redhat.com>

PR testsuite/98771
* fold-const-call.c (host_size_t_cst_p): Renamed to ...
(size_t_cst_p): ... this.  Check and store unsigned HOST_WIDE_INT
value rather than host size_t.
(fold_const_call): Change type of s2 from size_t to
unsigned HOST_WIDE_INT.  Use size_t_cst_p instead of
host_size_t_cst_p.  For strncmp calls, pass MIN (s2, SIZE_MAX)
instead of s2 as last argument.

4 years agors6000: Fix up __m64 typedef in mmintrin.h [PR97301]
Jakub Jelinek [Sat, 23 Jan 2021 08:41:58 +0000 (09:41 +0100)] 
rs6000: Fix up __m64 typedef in mmintrin.h [PR97301]

The x86 __m64 type is defined as:
/* The Intel API is flexible enough that we must allow aliasing with other
   vector types, and their scalar components.  */
typedef int __m64 __attribute__ ((__vector_size__ (8), __may_alias__));
and so matches the comment above it in that reads and stores through
pointers to __m64 can alias anything.
But in the rs6000 headers that is the case only for __m128, but not __m64.

The following patch adds that attribute, which fixes the
FAIL: gcc.target/powerpc/sse-movhps-1.c execution test
FAIL: gcc.target/powerpc/sse-movlps-1.c execution test
regressions that appeared when Honza improved ipa-modref.

2021-01-23  Jakub Jelinek  <jakub@redhat.com>

PR testsuite/97301
* config/rs6000/mmintrin.h (__m64): Add __may_alias__ attribute.

4 years agoc++: Fix up ubsan false positives on references [PR95693]
Jakub Jelinek [Fri, 22 Jan 2021 18:03:23 +0000 (19:03 +0100)] 
c++: Fix up ubsan false positives on references [PR95693]

Alex' 2 years old change to build_zero_init_1 to return NULL pointer with
reference type for references breaks the sanitizers, the assignment of NULL
to a reference typed member is then instrumented before it is overwritten
with a non-NULL address later on.
That change has been done to fix error recovery ICE during
process_init_constructor_record, where we:
          if (TYPE_REF_P (fldtype))
            {
              if (complain & tf_error)
                error ("member %qD is uninitialized reference", field);
              else
                return PICFLAG_ERRONEOUS;
            }
a few lines earlier, but then continue and ICE when build_zero_init returns
NULL.

The following patch reverts the build_zero_init_1 change and instead creates
the NULL with reference type constants during the error recovery.

The pr84593.C testcase Alex' change was fixing still works as before.

2021-01-22  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/95693
* init.c (build_zero_init_1): Revert the 2018-03-06 change to
return build_zero_cst for reference types.
* typeck2.c (process_init_constructor_record): Instead call
build_zero_cst here during error recovery instead of build_zero_init.

* g++.dg/ubsan/pr95693.C: New test.

4 years agomatch.pd: Replace incorrect simplifications into copysign [PR90248]
Jakub Jelinek [Fri, 22 Jan 2021 10:50:18 +0000 (11:50 +0100)] 
match.pd: Replace incorrect simplifications into copysign [PR90248]

In the PR Andrew said he has implemented a simplification that has been
added to LLVM, but that actually is not true, what is in there are
X * (X cmp 0.0 ? +-1.0 : -+1.0) simplifications into +-abs(X)
but what has been added into GCC are (X cmp 0.0 ? +-1.0 : -+1.0)
simplifications into copysign(1, +-X) and then
X * copysign (1, +-X) into +-abs (X).
The problem is with the (X cmp 0.0 ? +-1.0 : -+1.0) simplifications,
they don't work correctly when X is zero.
E.g.
(X > 0.0 ? 1.0 : -1.0)
is -1.0 when X is either -0.0 or 0.0, but copysign will make it return
1.0 for 0.0 and -1.0 only for -0.0.
(X >= 0.0 ? 1.0 : -1.0)
is 1.0 when X is either -0.0 or 0.0, but copysign will make it return
still 1.0 for 0.0 and -1.0 for -0.0.
The simplifications were guarded on !HONOR_SIGNED_ZEROS, but as discussed in
the PR, that option doesn't mean that -0.0 will not ever appear as operand
of some operation, it is hard to guarantee that without compiler adding
canonicalizations of -0.0 to 0.0 after most of the operations and thus
making it very slow, but that the user asserts that he doesn't care if the result
of operations will be 0.0 or -0.0.  Not to mention that some of the
transformations are incorrect even for positive 0.0.

So, instead of those simplifications this patch recognizes patterns where
those ?: expressions are multiplied by X, directly into +-abs.
That works fine even for 0.0 and -0.0 (as long as we don't care about
whether the result is exactly 0.0 or -0.0 in those cases), because
whether the result of copysign is -1.0 or 1.0 doesn't matter when it is
multiplied by 0.0 or -0.0.

As a follow-up, maybe we should add the simplification mentioned in the PR,
in particular doing copysign by hand through
VIEW_CONVERT_EXPR <int, float_X> < 0 ? -float_constant : float_constant
into copysign (float_constant, float_X).  But I think that would need to be
done in phiopt.

2021-01-22  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/90248
* match.pd (X cmp 0.0 ? 1.0 : -1.0 -> copysign(1, +-X),
X cmp 0.0 ? -1.0 : +1.0 -> copysign(1, -+X)): Remove
simplifications.
(X * (X cmp 0.0 ? 1.0 : -1.0) -> +-abs(X),
X * (X cmp 0.0 ? -1.0 : 1.0) -> +-abs(X)): New simplifications.

* gcc.dg/tree-ssa/copy-sign-1.c: Don't expect any copysign
builtins.
* gcc.dg/pr90248.c: New test.

4 years agoon ARRAY_REFs sign-extend offsets only from sizetype's precision [PR98255]
Jakub Jelinek [Fri, 22 Jan 2021 10:42:03 +0000 (11:42 +0100)] 
on ARRAY_REFs sign-extend offsets only from sizetype's precision [PR98255]

As discussed in the PR, the problem here is that the routines changed in
this patch sign extend the difference of index and low_bound from the
precision of the index, so e.g. when index is unsigned int and contains
value -2U, we treat it as index -2 rather than 0x00000000fffffffeU on 64-bit
arches.
On the other hand, get_inner_reference which is used during expansion, does:
            if (! integer_zerop (low_bound))
              index = fold_build2 (MINUS_EXPR, TREE_TYPE (index),
                                   index, low_bound);

            offset = size_binop (PLUS_EXPR, offset,
                                 size_binop (MULT_EXPR,
                                             fold_convert (sizetype, index),
                                             unit_size));
which effectively requires that either low_bound is constant 0 and then
index in ARRAY_REFs can be arbitrary type which is then sign or zero
extended to sizetype, or low_bound is something else and then index and
low_bound must have compatible types and it is still converted afterwards to
sizetype and from there then a few lines later:
expr.c-  if (poly_int_tree_p (offset))
expr.c-    {
expr.c:      poly_offset_int tem = wi::sext (wi::to_poly_offset (offset),
expr.c-                               TYPE_PRECISION (sizetype));
The following patch makes those routines match what get_inner_reference is
doing.

2021-01-22  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/98255
* tree-dfa.c (get_ref_base_and_extent): For ARRAY_REFs, sign
extend index - low_bound from sizetype's precision rather than index
precision.
(get_addr_base_and_unit_offset_1): Likewise.
* tree-ssa-sccvn.c (ao_ref_init_from_vn_reference): Likewise.
* gimple-fold.c (fold_const_aggregate_ref_1): Likewise.

* gcc.dg/pr98255.c: New test.

4 years agoc++: Fix up potential_constant_expression_1 FOR/WHILE_STMT handling [PR98672]
Jakub Jelinek [Thu, 21 Jan 2021 16:20:24 +0000 (17:20 +0100)] 
c++: Fix up potential_constant_expression_1 FOR/WHILE_STMT handling [PR98672]

The following testcase is rejected even when it is valid.
The problem is that potential_constant_expression_1 doesn't have the
accurate *jump_target tracking cxx_eval_* has, and when the loop has
a condition that isn't guaranteed to be always true, the body isn't walked
at all.  That is mostly a correct conservative behavior, except that it
doesn't detect if there are any return statements in the body, which means
the loop might return instead of falling through to the next statement.
We already have code for return stmt discovery in code snippets we don't
try to evaluate for switches, so this patch reuses that for FOR_STMT
and WHILE_STMT bodies.

Note, I haven't touched FOR_EXPR, with statement expressions it could
have return stmts in it too, or it could have break or continue statements
that wouldn't bind to the current loop but to something outer.  That
case is clearly mishandled by potential_constant_expression_1 even
when the condition is missing or is always true, and it wouldn't surprise me
if cxx_eval_* didn't handle it right either, so I'm deferring that to
separate PR for later.  We'd need proper test coverage for all of that.

> Hmm, IF_STMT probably also needs to check the else clause, if the condition
> isn't a known constant.

You're right, I thought it was ok because it recurses with tf_none, but
if the then branch is potentially constant and only else returns, continues
or breaks, then as the enhanced testcase shows we were mishandling it too.

2021-01-21  Jakub Jelinek  <jakub@redhat.com>

PR c++/98672
* constexpr.c (check_for_return_continue_data): Add break_stmt member.
(check_for_return_continue): Also look for BREAK_STMT.  Handle
SWITCH_STMT by ignoring break_stmt from its body.
(potential_constant_expression_1) <case FOR_STMT>,
<case WHILE_STMT>: If the condition isn't constant true, check if
the loop body can contain a return stmt.
<case SWITCH_STMT>: Adjust check_for_return_continue_data initializer.
<case IF_STMT>: If recursion with tf_none is successful,
merge *jump_target from the branches - returns with highest priority,
breaks or continues lower.  If then branch is potentially constant and
doesn't return, check the else branch if it could return, break or
continue.

* g++.dg/cpp1y/constexpr-98672.C: New test.

4 years agoc++: [[no_unique_address]] in empty base [PR98463]
Jason Merrill [Fri, 22 Jan 2021 18:17:10 +0000 (13:17 -0500)] 
c++: [[no_unique_address]] in empty base [PR98463]

In this testcase, cxx_eval_store_expression got confused trying to build up
CONSTRUCTORs for initializing a subobject because the subobject is a member
of an empty base.  In C++14 mode and below we don't build FIELD_DECLs for
empty bases, so the CONSTRUCTOR skipped the empty base, and treated the
member as a member of the derived class, which breaks.

Fixed by recognizing this situation and giving up on trying to build a
CONSTRUCTOR for the inner target at that point; since it doesn't have any
data, we don't need to actually store anything.

gcc/cp/ChangeLog:

PR c++/98463
* constexpr.c (get_or_insert_ctor_field): Add check.
(cxx_eval_store_expression): Handle discontinuity of refs.

gcc/testsuite/ChangeLog:

PR c++/98463
* g++.dg/cpp2a/no_unique_address8.C: New test.

4 years agoc++: Invisible refs are not restrict [PR97474]
Jason Merrill [Tue, 26 Jan 2021 21:04:24 +0000 (16:04 -0500)] 
c++: Invisible refs are not restrict [PR97474]

In this testcase, we refer to the a parameter through a reference in its own
member, which we asserted couldn't happen by marking the parameter as
'restrict'.  This assumption could also be broken if the address escapes
from the constructor.

gcc/cp/ChangeLog:

PR c++/97474
* call.c (type_passed_as): Don't mark invisiref restrict.

gcc/testsuite/ChangeLog:

PR c++/97474
* g++.dg/torture/pr97474.C: New test.

4 years agoc++: Avoid redundant copy in {} init [PR98642]
Jason Merrill [Wed, 13 Jan 2021 18:27:06 +0000 (13:27 -0500)] 
c++: Avoid redundant copy in {} init [PR98642]

Here, initializing from { } implies a call to the default constructor for
base.  We were then seeing that we're initializing a base subobject, so we
tried to copy the result of that call.  This is clearly wrong; we should
initialize the base directly from its default constructor.

gcc/cp/ChangeLog:

PR c++/98642
* typeck2.c (split_nonconstant_init_1): Don't copy a list-init
constructor call.

gcc/testsuite/ChangeLog:

PR c++/98642
* g++.dg/cpp1z/elide5.C: New test.

4 years agoc++: Fix list-init of array of no-copy type [PR63707]
Jason Merrill [Fri, 15 Jan 2021 16:42:00 +0000 (11:42 -0500)] 
c++: Fix list-init of array of no-copy type [PR63707]

build_vec_init_elt models initialization from some arbitrary object of the
type, i.e. copy, but in the case of list-initialization we don't do a copy
from the elements, we initialize them directly.

gcc/cp/ChangeLog:

PR c++/63707
* tree.c (build_vec_init_expr): Don't call build_vec_init_elt
if we got a CONSTRUCTOR.

gcc/testsuite/ChangeLog:

PR c++/63707
* g++.dg/cpp0x/initlist-array13.C: New test.

4 years agotree-optimization/97627 - Avoid computing niters for fake edges
Richard Biener [Fri, 29 Jan 2021 10:17:42 +0000 (11:17 +0100)] 
tree-optimization/97627 - Avoid computing niters for fake edges

This avoids computing niters information for fake edges.

2021-01-29  Bin Cheng  <bin.cheng@linux.alibaba.com>
    Richard Biener  <rguenther@suse.de>

PR tree-optimization/97627
* tree-ssa-loop-niter.c (number_of_iterations_exit_assumptions):
Do not analyze fake edges.

* g++.dg/pr97627.C: New testcase.

4 years agoDaily bump.
GCC Administrator [Fri, 29 Jan 2021 00:17:05 +0000 (00:17 +0000)] 
Daily bump.

4 years agoPR fortran/86470 - ICE with OpenMP, class(*) allocatable
Harald Anlauf [Thu, 28 Jan 2021 09:13:46 +0000 (10:13 +0100)] 
PR fortran/86470 - ICE with OpenMP, class(*) allocatable

gfc_call_malloc should malloc an area of size 1 if no size given.

gcc/fortran/ChangeLog:

PR fortran/86470
* trans.c (gfc_call_malloc): Allocate area of size 1 if passed
size is NULL (as documented).

gcc/testsuite/ChangeLog:

PR fortran/86470
* gfortran.dg/gomp/pr86470.f90: New test.

(cherry picked from commit 33a7a93218b1393d0135e3c4a9ad9ced87808f5e)

4 years agoFix LTO bootstrap on Windows
Eric Botcazou [Thu, 28 Jan 2021 10:31:35 +0000 (11:31 +0100)] 
Fix LTO bootstrap on Windows

The latest fix introduced a comparison of executables and this cannot
directly work on Windows because they are timestamped.  Moreover nobody
sets $(exeext) at top level, at least on MinGW, so you get weird behavior
because some tools add the implicit .exe suffix and others do not.

contrib/
PR lto/85574
* compare-lto: Deal with PE-COFF executables specifically.

4 years agoDaily bump.
GCC Administrator [Thu, 28 Jan 2021 00:17:36 +0000 (00:17 +0000)] 
Daily bump.

4 years agotree-ssa-mathopts: Use proper poly_int64 comparison with param_avoid_fma_max_bits...
Kyrylo Tkachov [Thu, 21 Jan 2021 16:33:49 +0000 (16:33 +0000)] 
tree-ssa-mathopts: Use proper poly_int64 comparison with param_avoid_fma_max_bits [PR 98766]

We ICE here because we end up comparing a poly_int64 with a scalar using
<= rather than maybe_le.
This patch fixes that in the way rich suggests in the PR.

gcc/ChangeLog:

PR tree-optimization/98766
* tree-ssa-math-opts.c (convert_mult_to_fma): Use maybe_le when
comparing against type size with param_avoid_fma_max_bits.

gcc/testsuite/ChangeLog:

PR tree-optimization/98766
* gcc.dg/pr98766.c: New test.

(cherry picked from commit 9d33785f57daf29dc0c106c919da319fe1906bc6)

4 years agoDaily bump.
GCC Administrator [Wed, 27 Jan 2021 00:17:18 +0000 (00:17 +0000)] 
Daily bump.

4 years agoFix PR ada/98228
Eric Botcazou [Tue, 26 Jan 2021 17:54:26 +0000 (18:54 +0100)] 
Fix PR ada/98228

This is the profiled bootstrap failure for s390x/Linux on the mainline,
which has been introduced by the modref pass but actually exposing an
existing issue in the maybe_pad_type function that is visible on s390x.

The issue is too weak a test for the addressability of the inner component.

gcc/ada/
    Marius Hillenbrand  <mhillen@linux.ibm.com>

PR ada/98228
* gcc-interface/utils.c (maybe_pad_type): Test the size of the new
packable type instead of its alignment for addressability's sake.

4 years agoFix missing equal symbol for -fprofile-reproducible opt.
Martin Liska [Tue, 26 Jan 2021 11:48:35 +0000 (12:48 +0100)] 
Fix missing equal symbol for -fprofile-reproducible opt.

gcc/ChangeLog:

PR gcov-profile/98739
* common.opt: Add missing equal symbol.

4 years agoDaily bump.
GCC Administrator [Tue, 26 Jan 2021 00:17:23 +0000 (00:17 +0000)] 
Daily bump.

4 years agoRTEMS: Fix default linker script
Sebastian Huber [Mon, 25 Jan 2021 11:29:05 +0000 (12:29 +0100)] 
RTEMS: Fix default linker script

We have to use ENDFILE_SPEC for the default linker script and not
STARTFILE_SPEC, since STARTFILE_SPEC is place before the user provided
library search paths.

gcc/

* config/rtems.h (STARTFILE_SPEC): Remove qnolinkcmds.
(ENDFILE_SPEC): Evaluate qnolinkcmds.

(cherry picked from commit 0433fc2d7d44eafd61017cd0b6c4cab1fcb16990)

4 years agoRTEMS: Fix GCC specification
Sebastian Huber [Fri, 22 Jan 2021 11:45:49 +0000 (12:45 +0100)] 
RTEMS: Fix GCC specification

The use of -nostdlib and -nodefaultlibs disables the processing of
LIB_SPEC (%L) as specified by LINK_COMMAND_SPEC and thus disables the
default linker script for RTEMS.  Move the linker script to
STARTFILE_SPEC which is controlled by -nostdlib and -nostartfiles.  This
fits better since the linker script defines the platform start file
provided by the board support package in RTEMS.

gcc/

* config/rtems.h (STARTFILE_SPEC): Remove nostdlib and
nostartfiles handling since this is already done by
LINK_COMMAND_SPEC.  Evaluate qnolinkcmds.
(ENDFILE_SPEC): Remove nostdlib and nostartfiles handling since this
is already done by LINK_COMMAND_SPEC.
(LIB_SPECS): Remove nostdlib and nodefaultlibs handling since
this is already done by LINK_COMMAND_SPEC.  Remove qnolinkcmds
evaluation.

(cherry picked from commit 28229916e1b131ad5d17a73603f65229e0a92f58)

4 years agoFix internal error on extension with interface at -O2
Eric Botcazou [Mon, 25 Jan 2021 10:27:29 +0000 (11:27 +0100)] 
Fix internal error on extension with interface at -O2

This is a regression present on the mainline, 10 and 9 branches, in the
form of an internal error with the Ada compiler when a covariant-only
thunk is inlined into its caller.

gcc/ada/
* gcc-interface/trans.c (make_covariant_thunk): Set the DECL_CONTEXT
of the parameters and do not set TREE_PUBLIC on the thunk.
(maybe_make_gnu_thunk): Pass the alias to the covariant thunk.
* gcc-interface/utils.c (finish_subprog_decl): Set the DECL_CONTEXT
of the parameters here...
(begin_subprog_body): ...instead of here.

gcc/testsuite/
* gnat.dg/thunk2.adb, gnat.dg/thunk2.ads: New test.
* gnat.dg/thunk2_pkg.ads: New helper.

4 years agoFortran: Fix deferred character lengths in array constructors [PR98517].
Paul Thomas [Mon, 25 Jan 2021 10:27:51 +0000 (10:27 +0000)] 
Fortran: Fix deferred character lengths in array constructors [PR98517].

2021-01-25  Steve Kargl  <kargl@gcc.gnu.org>

gcc/fortran
PR fortran/98517
* resolve.c (resolve_charlen): Check that length expression is
present before testing for scalar/integer..

gcc/testsuite/
PR fortran/98517
* gfortran.dg/charlen_18.f90 : New test.

(cherry picked from commit c6b0e33febbf73abfcc2bb0e28f0b62afe3b0f2a)

4 years agoarc: Use separate predicated patterns for mpyd(u)
Claudiu Zissulescu [Tue, 28 Jul 2020 10:15:48 +0000 (13:15 +0300)] 
arc: Use separate predicated patterns for mpyd(u)

The compiler can match mpyd.eq r0,r1,r0 as a predicated instruction,
which is incorrect. The mpyd(u) instruction takes as input two 32-bit
registers, returning into a double 64-bit even-odd register pair.  For
the predicated case, the ARC instruction decoder expects the
destination register to be the same as the first input register. In
the big-endian case the result is swaped in the destination register
pair, however, the instruction encoding remains the same.  Refurbish
the mpyd(u) patterns to take into account the above observation.

gcc/
2020-12-11  Claudiu Zissulescu  <claziss@synopsys.com>

* config/arc/arc.md (mpyd<su_optab>_arcv2hs): New template
pattern.
(*pmpyd<su_optab>_arcv2hs): Likewise.
(*pmpyd<su_optab>_imm_arcv2hs): Likewise.
(mpyd_arcv2hs): Moved into above template.
(mpyd_imm_arcv2hs): Moved into above template.
(mpydu_arcv2hs): Likewise.
(mpydu_imm_arcv2hs): Likewise.
(su_optab): New optab prefix for sign/zero-extending operations.

gcc/testsuite/
2020-12-11  Claudiu Zissulescu  <claziss@synopsys.com>

* gcc.target/arc/pmpyd.c: New test.
* gcc.target/arc/tmac-1.c: Update.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
(cherry picked from commit f7ad4446274831234e5acd3506fd2e01c7594c6a)

4 years agoFortran: Fix deferred character lengths in array constructors [PR93833].
Paul Thomas [Tue, 29 Dec 2020 17:37:25 +0000 (17:37 +0000)] 
Fortran: Fix deferred character lengths in array constructors [PR93833].

2020-12-29  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/93833
* trans-array.c (get_array_ctor_var_strlen): If the character
length backend_decl cannot be found, convert the expression and
use the string length. Clear up some minor white space issues
in the rest of the file.

gcc/testsuite/
PR fortran/93833
* gfortran.dg/deferred_character_36.f90 : New test.

(cherry picked from commit feae0af82753e06fbff6103da5fbb3b28e1ddbd7)

4 years agoDaily bump.
GCC Administrator [Mon, 25 Jan 2021 00:17:08 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sun, 24 Jan 2021 00:17:05 +0000 (00:17 +0000)] 
Daily bump.

4 years agolibphobos: Fix executables segfault on mipsel architecture
Iain Buclaw [Sat, 23 Jan 2021 23:20:25 +0000 (00:20 +0100)] 
libphobos: Fix executables segfault on mipsel architecture

The dynamic section on MIPS is read-only, but this was not properly
handled in the runtime library.  The segfault only occurred for programs
that linked to the shared libphobos library.

libphobos/ChangeLog:

PR d/98806
* libdruntime/gcc/sections/elf_shared.d (MIPS_Any): Declare version
for MIPS32 and MIPS64.
(getDependencies): Adjust dlpi_addr on MIPS_Any.

(cherry picked from commit 81f928ec8e8abf1f21c5ff008c39b5d6af78f6cb)

4 years agoFortran: Correction to recent patch in light of comments [PR98022].
Paul Thomas [Sat, 26 Dec 2020 16:44:24 +0000 (16:44 +0000)] 
Fortran: Correction to recent patch in light of comments [PR98022].

2020-12-26  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/98022
* data.c (gfc_assign_data_value): Throw an error for inquiry
references. Follow with corrected code that would provide the
expected result and provides clean error recovery.

gcc/testsuite/
PR fortran/98022
* gfortran.dg/data_inquiry_ref.f90: Change to dg-compile and
add errors for inquiry references.

(cherry picked from commit c7256c8260afa313e019fd531574ad33ec49b9f6)

4 years agoFortran: Enable inquiry references in data statements [PR98022].
Paul Thomas [Sat, 12 Dec 2020 14:01:08 +0000 (14:01 +0000)] 
Fortran: Enable inquiry references in data statements [PR98022].

2020-12-12  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/98022
* data.c (gfc_assign_data_value): Handle inquiry references in
the data statement object list.

gcc/testsuite/
PR fortran/98022
* gfortran.dg/data_inquiry_ref.f90: New test.

(cherry picked from commit ff2dfdef2f2e01c579dd280daa1d81fbeb4d7ac5)

4 years agoDaily bump.
GCC Administrator [Sat, 23 Jan 2021 00:17:17 +0000 (00:17 +0000)] 
Daily bump.

4 years agoc++: Crash when deducing template arguments [PR98790]
Marek Polacek [Fri, 22 Jan 2021 17:50:53 +0000 (12:50 -0500)] 
c++: Crash when deducing template arguments [PR98790]

maybe_instantiate_noexcept doesn't expect to see error_mark_node, but
the new callsite I introduced in r11-6476 can pass error_mark_node to
it.  So cope.

gcc/cp/ChangeLog:

PR c++/98790
* pt.c (maybe_instantiate_noexcept): Return false if FN is
error_mark_node.

gcc/testsuite/ChangeLog:

PR c++/98790
* g++.dg/template/deduce8.C: New test.

4 years agovect: Fix VLA SLP invariant optimisation [PR98535]
Richard Sandiford [Fri, 22 Jan 2021 09:13:12 +0000 (09:13 +0000)] 
vect: Fix VLA SLP invariant optimisation [PR98535]

duplicate_and_interleave is the main fallback way of loading
a repeating sequence of elements into variable-length vectors.
The code handles cases in which the number of elements in the
sequence is potentially several times greater than the number
of elements in a vector.

Let:

- NE be the (compile-time) number of elements in the sequence
- NR be the (compile-time) number of vector results and
- VE be the (run-time) number of elements in each vector

The basic approach is to duplicate each element into a
separate vector, giving NE vectors in total, then use
log2(NE) rows of NE permutes to generate NE results.

In the worst case --- when VE has no known compile-time factor
and NR >= NE --- all of these permutes are necessary.  However,
if VE is known to be a multiple of 2**F, then each of the
first F permute rows produces duplicate results; specifically,
the high permute for a given pair is the same as the low permute.
The code dealt with this by reusing the low result for the
high result.  This part was OK.

However, having duplicate results from one row meant that the
next row did duplicate work.  The redundancies would be optimised
away by later passes, but the code tried to avoid generating them
in the first place.  This is the part that went wrong.

Specifically, NR is typically less than NE when some permutes are
redundant, so the code tried to use NR to reduce the amount of work
performed.  The problem was that, although it correctly calculated
a conservative bound on how many results were needed in each row,
it chose the wrong results for anything other than the final row.

This doesn't usually matter for fully-packed SVE vectors.  We first
try to coalesce smaller elements into larger ones, so normally
VE ends up being 2**VQ (where VQ is the number of 128-bit blocks
in an SVE vector).  In that situation we'd only apply the faulty
optimisation to the final row, i.e. the case it handled correctly.
E.g. for things like:

  void
  f (long *x)
  {
    for (int i = 0; i < 100; i += 8)
      {
        x[i] += 1;
        x[i + 1] += 2;
        x[i + 2] += 3;
        x[i + 3] += 4;
        x[i + 4] += 5;
        x[i + 5] += 6;
        x[i + 6] += 7;
        x[i + 7] += 8;
      }
  }

(already tested by the testsuite), we'd have 3 rows of permutes
producing 4 vector results.  The schemne produced:

1st row: 8 results from 4 permutes, highs duplicates of lows
2nd row: 8 results from 8 permutes (half of which are actually redundant)
3rd row: 4 results from 4 permutes

However, coalescing elements is trickier for unpacked vectors,
and at the moment we don't try to do it (see the GET_MODE_SIZE
check in can_duplicate_and_interleave_p).  Unpacked vectors
therefore stress the code in ways that packed vectors didn't.

The patch fixes this by removing the redundancies from each row,
rather than trying to work around them later.  This also removes
the redundant work in the second row of the example above.

gcc/
PR tree-optimization/98535
* tree-vect-slp.c (duplicate_and_interleave): Use quick_grow_cleared.
If the high and low permutes are the same, remove the high permutes
from the working set and only continue with the low ones.

(cherry picked from commit ea74a3f548eb321429c371e327e778e63d9128a0)

4 years agoDaily bump.
GCC Administrator [Fri, 22 Jan 2021 00:17:12 +0000 (00:17 +0000)] 
Daily bump.

4 years agoFix typo in arm_mve.h __arm_vcmpneq_s8 return type
Christophe Lyon [Tue, 19 Jan 2021 10:31:48 +0000 (10:31 +0000)] 
Fix typo in arm_mve.h __arm_vcmpneq_s8 return type

Like all vcmp intrinsics, __arm_vcmpneq_s8 should return a mve_pred16_t.

2021-01-21  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/
* config/arm/arm_mve.h (__arm_vcmpneq_s8): Fix return type.

4 years agoPowerPC: Backport fix for libgcc long double support.
Michael Meissner [Thu, 21 Jan 2021 01:30:22 +0000 (20:30 -0500)] 
PowerPC: Backport fix for libgcc long double support.

libgcc/
2021-01-20  Michael Meissner  <meissner@linux.ibm.com>

* config/rs6000/t-linux (IBM128_STATIC_OBJS): Back port from
master (12/3/2020).  New make variable.
(IBM128_SHARED_OBJS): New make variable.
(IBM128_OBJS): New make variable.  Set all objects to use the
explicit IBM format, and disable gnu attributes.
(IBM128_CFLAGS): New make variable.
(gcc_s_compile): Add -mno-gnu-attribute to all shared library
modules.

4 years agoDaily bump.
GCC Administrator [Thu, 21 Jan 2021 00:17:18 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Wed, 20 Jan 2021 00:17:32 +0000 (00:17 +0000)] 
Daily bump.

4 years agoUpdate gcc de.po.
Joseph Myers [Tue, 19 Jan 2021 23:30:46 +0000 (23:30 +0000)] 
Update gcc de.po.

* de.po: Update.

4 years agoipa-sra: Do not remove return values needed because of non-call EH
Martin Jambor [Tue, 19 Jan 2021 14:50:49 +0000 (15:50 +0100)] 
ipa-sra: Do not remove return values needed because of non-call EH

IPA-SRA already contains a check to figure out that an otherwise dead
parameter is actually required because of non-call exceptions, but it
is not present at the equivalent spot where SRA figures out whether
the return statement is used for anything useful.  This patch adds
that condition there.

Unfortunately, even though this patch should be good enough for any
normal (I'd even say reasonable) use of the compiler, it hints that
when the user manually switches all sorts of DCE, IPA-SRA would
probably leave behind problematic statements manipulating what
originally were return values, just like it does for parameters (PR
93385).  Fixing this properly might unfortunately be a separate issue
from the mentioned bug because the LHS of a call is changed during
call redirection and the caller often is not a clone.  But I'll see
what I can do.

Meanwhile, the patch below has been bootstrapped and tested on x86_64.

gcc/ChangeLog:

2021-01-18  Martin Jambor  <mjambor@suse.cz>

PR ipa/98690
* ipa-sra.c (ssa_name_only_returned_p): New parameter fun.  Check
whether non-call exceptions allow removal of a statement.
(isra_analyze_call): Pass the appropriate function to
ssa_name_only_returned_p.

gcc/testsuite/ChangeLog:

2021-01-18  Martin Jambor  <mjambor@suse.cz>

PR ipa/98690
* g++.dg/ipa/pr98690.C: New test.

(cherry picked from commit 9b8741c98f2876a430c12c85b396d29a87c9c488)

4 years agosparc,rtems: add __FIX_LEON3FT_TN0018 for affected targets
Daniel Hellstrom [Tue, 19 Jan 2021 09:39:51 +0000 (10:39 +0100)] 
sparc,rtems: add __FIX_LEON3FT_TN0018 for affected targets

Enable a define FIX_LEON3FT_TN0018 for the LEON3FT targets affected
by the GRLIB-TN-0018 errata described here:
  https://www.gaisler.com/notes

gcc/

* config/sparc/rtemself.h (TARGET_OS_CPP_BUILTINS): Add
built-in define __FIX_LEON3FT_TN0018.

(cherry picked from commit 4b690f161b82e428dbe648075da215daa52be0ea)

4 years agoFix PR ada/98740
Eric Botcazou [Tue, 19 Jan 2021 09:43:15 +0000 (10:43 +0100)] 
Fix PR ada/98740

It's a long-standing GENERIC tree sharing issue.

gcc/ada/ChangeLog:
PR ada/98740
* gcc-interface/trans.c (add_decl_expr): Always mark TYPE_ADA_SIZE.

4 years agoDaily bump.
GCC Administrator [Tue, 19 Jan 2021 00:17:16 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Mon, 18 Jan 2021 00:17:09 +0000 (00:17 +0000)] 
Daily bump.

4 years agotestsuite: i386: Require ifunc support in gcc.target/i386/pr98100.c
Rainer Orth [Tue, 8 Dec 2020 12:29:26 +0000 (13:29 +0100)] 
testsuite: i386: Require ifunc support in gcc.target/i386/pr98100.c

The new gcc.target/i386/pr98100.c test FAILs on Solaris/x86:

FAIL: gcc.target/i386/pr98100.c (test for excess errors)

Excess errors:
/vol/gcc/src/hg/master/local/gcc/testsuite/gcc.target/i386/pr98100.c:6:1: error: the call requires 'ifunc', which is not supported by this target

Fixed as follows.

Tested on i386-pc-solaris2.11 and x86_64-pc-linux-gnu.

2020-12-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
* gcc.target/i386/pr98100.c: Require ifunc support.

4 years agoDaily bump.
GCC Administrator [Sun, 17 Jan 2021 00:17:06 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sat, 16 Jan 2021 00:17:12 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Fri, 15 Jan 2021 00:17:11 +0000 (00:17 +0000)] 
Daily bump.

4 years ago[gcn offloading] Only supported in 64-bit configurations
Thomas Schwinge [Tue, 28 Apr 2020 18:43:38 +0000 (20:43 +0200)] 
[gcn offloading] Only supported in 64-bit configurations

Similar to nvptx offloading, see PR65099 "nvptx offloading: hard-coded 64-bit
assumptions".

gcc/
* config/gcn/mkoffload.c (main): Create an offload image only in
64-bit configurations.

(cherry picked from commit 505caa7295b93ecdec8ac9b31595eb34dbd48c9f)

4 years ago[nvptx libgomp plugin] Build only in supported configurations
Thomas Schwinge [Mon, 30 Nov 2020 14:15:20 +0000 (15:15 +0100)] 
[nvptx libgomp plugin] Build only in supported configurations

As recently again discussed in <https://gcc.gnu.org/PR97436> "[nvptx] -m32
support", nvptx offloading other than for 64-bit host has never been
implemented, tested, supported.  So we simply should buildn't the nvptx libgomp
plugin in this case.

This avoids build problems if, for example, in a (standard) bi-arch
x86_64-pc-linux-gnu '-m64'/'-m32' build, libcuda is available only in a 64-bit
variant but not in a 32-bit one, which, for example, is the case if you build
GCC against the CUDA toolkit's 'stubs/libcuda.so' (see
<https://stackoverflow.com/a/52784819>).

This amends PR65099 commit a92defdab79a1268f4b9dcf42b937e4002a4cf15 (r225560)
"[nvptx offloading] Only 64-bit configurations are currently supported" to
match the way we're doing this for the HSA/GCN plugins.

libgomp/
PR libgomp/65099
* plugin/configfrag.ac (PLUGIN_NVPTX): Restrict to supported
configurations.
* configure: Regenerate.
* plugin/plugin-nvptx.c (nvptx_get_num_devices): Remove 64-bit
check.

(cherry picked from commit 6106dfb9f73a33c87108ad5b2dcd4842bdd7828e)

4 years agoObjective-C++ : Fix ICE in potential_constant_expression_1.
Iain Sandoe [Sat, 31 Oct 2020 09:25:47 +0000 (09:25 +0000)] 
Objective-C++ : Fix ICE in potential_constant_expression_1.

We cannot, as things stand, handle Objective-C tree codes in
the switch and deal with this by calling out to a function that
has a dummy version when Objective-C is not enabled.

Because of the way the logic works (with a fall through to a
'sorry' in case of unhandled expressions), the function reports
cases that are known to be unsuitable for constant exprs. The
dummy function always reports 'false' and thus will fall through
to the 'sorry'.

gcc/c-family/ChangeLog:

* c-objc.h (objc_non_constant_expr_p): New.
* stub-objc.c (objc_non_constant_expr_p): New.

gcc/cp/ChangeLog:

* constexpr.c (potential_constant_expression_1): Handle
expressions known to be non-constant for Objective-C.

gcc/objc/ChangeLog:

* objc-act.c (objc_non_constant_expr_p): New.

(cherry picked from commit 878cffbd9e6e1b138a6e0d362e7b29bc0a259940)

4 years agoDaily bump.
GCC Administrator [Thu, 14 Jan 2021 00:17:09 +0000 (00:17 +0000)] 
Daily bump.

4 years agolibstdc++: Fix clang analyzer suppression [PR 98605]
Jonathan Wakely [Wed, 13 Jan 2021 11:03:58 +0000 (11:03 +0000)] 
libstdc++: Fix clang analyzer suppression [PR 98605]

The fix for PR libstdc++/82481 should only have applied for targets
where _GLIBCXX_HAVE_TLS is defined. Because it was also done for non-TLS
targets, it isn't possible to use clang's analyzers on non-TLS targets
if the code uses <mutex>. This fixes it by using a NOLINT comment on
the relevant line instead of testing #ifdef __clang_analyzer__ and
compiling different code when analyzing.

I'm not actually able to reproduce the analyzer warning with the tools
from Clang 10.0.1 so I'm not going to try to make the suppression more
specific with NOLINTNEXTLINE(clang-analyzer-code.StackAddressEscape).

libstdc++-v3/ChangeLog:

PR libstdc++/98605
* include/std/mutex (call_once): Use NOLINT to suppress clang
analyzer warnings.

4 years agoHurd: Enable ifunc by default
Samuel Thibault [Sun, 8 Nov 2020 22:52:51 +0000 (23:52 +0100)] 
Hurd: Enable ifunc by default

The binutils bugs seem to have been fixed.

gcc/
* config.gcc [$target == *-*-gnu*]: Enable
'default_gnu_indirect_function'.

(cherry picked from commit e9cb89b936f831a02318d45fc4ddb06f7be55ae4)

4 years agohurd: libgcc unwinding over signal trampolines with SIGINFO
Samuel Thibault [Mon, 21 Dec 2020 14:36:30 +0000 (15:36 +0100)] 
hurd: libgcc unwinding over signal trampolines with SIGINFO

When the application sets SA_SIGINFO, the signal trampoline parameters
are different to follow POSIX.

libgcc/
* config/i386/gnu-unwind.h (x86_gnu_fallback_frame_state): Add the
posix siginfo case to struct handler_args. Detect between legacy
and siginfo from the second parameter, which is a small sigcode in
the legacy case, and a pointer in the siginfo case.

(cherry picked from commit 2b356e689c334ca4765a9ffd95a76cf715447200)

4 years agoDaily bump.
GCC Administrator [Wed, 13 Jan 2021 00:17:19 +0000 (00:17 +0000)] 
Daily bump.