gcc.git
3 years agoDaily bump. master
GCC Administrator [Sun, 24 Jan 2021 00:16:16 +0000 (00:16 +0000)]
Daily bump.

3 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.

3 years agoc++: private inheritance access diagnostics fix [PR17314]
Anthony Sharp [Fri, 22 Jan 2021 22:36:06 +0000 (22:36 +0000)]
c++: private inheritance access diagnostics fix [PR17314]

This patch fixes PR17314. Previously, when class C attempted
to access member a declared in class A through class B, where class B
privately inherits from A and class C inherits from B, GCC would correctly
report an access violation, but would erroneously report that the reason was
because a was "protected", when in fact, from the point of view of class C,
it was really "private". This patch updates the diagnostics code to generate
more correct errors in cases of failed inheritance such as these.

The reason this bug happened was because GCC was examining the
declared access of decl, instead of looking at it in the
context of class inheritance.

gcc/cp/ChangeLog:

2021-01-21  Anthony Sharp  <anthonysharp15@gmail.com>

* call.c (complain_about_access): Altered function.
* cp-tree.h (complain_about_access): Changed parameters of function.
(get_parent_with_private_access): Declared new function.
* search.c (get_parent_with_private_access): Defined new function.
* semantics.c (enforce_access): Modified function.
* typeck.c (complain_about_unrecognized_member): Updated function
arguments in complain_about_access.

gcc/testsuite/ChangeLog:

2021-01-21  Anthony Sharp  <anthonysharp15@gmail.com>

* g++.dg/lookup/scoped1.C: Modified testcase to run successfully
with changes.
* g++.dg/tc1/dr142.C: Same as above.
* g++.dg/tc1/dr52.C: Same as above.
* g++.old-deja/g++.brendan/visibility6.C: Same as above.
* g++.old-deja/g++.brendan/visibility8.C: Same as above.
* g++.old-deja/g++.jason/access8.C: Same as above.
* g++.old-deja/g++.law/access4.C: Same as above.
* g++.old-deja/g++.law/visibility12.C: Same as above.
* g++.old-deja/g++.law/visibility4.C: Same as above.
* g++.old-deja/g++.law/visibility8.C: Same as above.
* g++.old-deja/g++.other/access4.C: Same as above.

3 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.

3 years agoc++: 'this' injection and static member functions [PR97399]
Patrick Palka [Sat, 23 Jan 2021 05:24:17 +0000 (00:24 -0500)]
c++: 'this' injection and static member functions [PR97399]

In the testcase pr97399.C below, finish_qualified_id_expr at parse time
adds an implicit 'this->' to the expression tmp::integral<T> (because
it's type-dependent, and also current_class_ptr is set at this point)
within the trailing return type.  Later when substituting into this
trailing return type we crash because we can't resolve the 'this', since
tsubst_function_type does inject_this_parm only for non-static member
functions, which tmp::func is not.

This patch fixes this issue by removing the type-dependence check
in finish_qualified_id_expr added by r9-5972, and instead relaxes
shared_member_p to handle dependent USING_DECLs:

> I think I was wrong in my assertion around Alex's patch that
> shared_member_p should abort on a dependent USING_DECL; it now seems
> appropriate for it to return false if we don't know, we just need to
> adjust the comment to say that.

And when parsing a friend function declaration, we shouldn't be setting
current_class_ptr at all, so this patch additionally suppresses
inject_this_parm in this case.

Finally, the self-contained change to cp_parser_init_declarator is so
that we properly communicate static-ness to cp_parser_direct_declarator
when parsing a member function template.  This lets us reject the
explicit use of 'this' in the testcase this2.C below.

gcc/cp/ChangeLog:

PR c++/97399
* cp-tree.h (shared_member_p): Adjust declaration.
* parser.c (cp_parser_init_declarator): If the storage class
specifier is sc_static, pass true for static_p to
cp_parser_declarator.
(cp_parser_direct_declarator): Don't do inject_this_parm when
the declarator is a friend.
* search.c (shared_member_p): Change return type to bool and
adjust function body accordingly.  Return false for a dependent
USING_DECL instead of aborting.
* semantics.c (finish_qualified_id_expr): Rely on shared_member_p
even when type-dependent.

gcc/testsuite/ChangeLog:

PR c++/88548
PR c++/97399
* g++.dg/cpp0x/this2.C: New test.
* g++.dg/template/pr97399.C: New test.

3 years agotestsuite: fix gcc.target/powerpc ilp32 failures
David Edelsohn [Sat, 23 Jan 2021 00:54:24 +0000 (19:54 -0500)]
testsuite: fix gcc.target/powerpc ilp32 failures

The recent vec insert code generation changes were not reflected in the
expected output for ilp32 targets.  This patch updates the expected
instructions and counts.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/fold-vec-insert-char-p9.c: Adjust ilp32.
* gcc.target/powerpc/fold-vec-insert-float-p9.c: Same.
* gcc.target/powerpc/fold-vec-insert-int-p9.c: Same.
* gcc.target/powerpc/fold-vec-insert-longlong.c: Same.
* gcc.target/powerpc/fold-vec-insert-short-p9.c: Same.
* gcc.target/powerpc/pr79251.p9.c: Same.

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

3 years agoaarch64: Use RTL builtins for integer mla intrinsics
Jonathan Wright [Thu, 14 Jan 2021 18:38:07 +0000 (18:38 +0000)]
aarch64: Use RTL builtins for integer mla intrinsics

Rewrite integer mla Neon intrinsics to use RTL builtins rather than
inline assembly code, allowing for better scheduling and optimization.

gcc/Changelog:

2021-01-14  Jonathan Wright  <jonathan.wright@arm.com>

* config/aarch64/aarch64-simd-builtins.def: Add mla builtin
generator macro.
* config/aarch64/arm_neon.h (vmla_s8): Use RTL builtin rather
than asm.
(vmla_s16): Likewise.
(vmla_s32): Likewise.
(vmla_u8): Likewise.
(vmla_u16): Likewise.
(vmla_u32): Likewise.
(vmlaq_s8): Likewise.
(vmlaq_s16): Likewise.
(vmlaq_s32): Likewise.
(vmlaq_u8): Likewise.
(vmlaq_u16): Likewise.
(vmlaq_u32): Likewise.

3 years agoc++: ICE with noexcept in class in member function [PR96623]
Marek Polacek [Thu, 21 Jan 2021 21:12:28 +0000 (16:12 -0500)]
c++: ICE with noexcept in class in member function [PR96623]

I discovered very strange code in inject_parm_decls:

   if (args && is_this_parameter (args))
     {
       gcc_checking_assert (current_class_ptr == NULL_TREE);
       current_class_ptr = NULL_TREE;

We are tripping up on the assert because when we call inject_parm_decls,
current_class_ptr is set to 'A'.  It was set by inject_this_parameter
after we've parsed the parameter-declaration-clause of the member
function foo.  It seems correct to set ccp/ccr to A::B when we're
late parsing the noexcept-specifiers of bar* functions in B, so that
this-> does the right thing.  Since inject_parm_decls doesn't expect
to see non-null ccp/ccr, reset it before calling inject_parm_decls.

gcc/cp/ChangeLog:

PR c++/96623
* parser.c (inject_parm_decls): Remove a redundant assignment.
(cp_parser_class_specifier_1): Clear current_class_{ptr,ref}
before calling inject_parm_decls.

gcc/testsuite/ChangeLog:

PR c++/96623
* g++.dg/cpp0x/noexcept64.C: New test.

3 years agotestsuite: Enable spbp.C on AIX.
David Edelsohn [Fri, 22 Jan 2021 02:12:06 +0000 (21:12 -0500)]
testsuite: Enable spbp.C on AIX.

This testcase was disabled in the distant past when AIX did not have
support for DWARF and the testcase explicitly invokes DWARF debugging.
This patch re-enables the testcase.

gcc/testsuite/ChangeLog:

* g++.dg/eh/spbp.C: Remove skip on AIX.

3 years agodoc: ensure GCC_EXTRA_DIAGNOSTIC_OUTPUT gets an HTML anchor
David Malcolm [Fri, 22 Jan 2021 22:07:30 +0000 (17:07 -0500)]
doc: ensure GCC_EXTRA_DIAGNOSTIC_OUTPUT gets an HTML anchor

This is referenced by my recent release notes changes for GCC 11:
  https://gcc.gnu.org/pipermail/gcc-patches/2021-January/564164.html

gcc/ChangeLog:
* doc/invoke.texi (GCC_EXTRA_DIAGNOSTIC_OUTPUT): Add @findex
directive.

3 years agotestsuite: Fix a typo - UINON_TYPE to UNION_TYPE - in gcc.target/powerpc
Jakub Jelinek [Fri, 22 Jan 2021 21:55:44 +0000 (22:55 +0100)]
testsuite: Fix a typo - UINON_TYPE to UNION_TYPE - in gcc.target/powerpc

Spotted while fixing the rs6000 aliasing issue.

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

* gcc.target/powerpc/m128-check.h (CHECK_EXP, CHECK_FP_EXP): Fix a
typo, UINON_TYPE to UNION_TYPE.

3 years agotestsuite: Fix a typo - UINON_TYPE to UNION_TYPE - in gcc.target/i386
Jakub Jelinek [Fri, 22 Jan 2021 21:51:03 +0000 (22:51 +0100)]
testsuite: Fix a typo - UINON_TYPE to UNION_TYPE - in gcc.target/i386

Spotted while fixing the rs6000 aliasing issue.

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

* gcc.target/i386/m128-check.h (CHECK_EXP, CHECK_FP_EXP): Fix a typo,
UINON_TYPE to UNION_TYPE.
* gcc.target/i386/m256-check.h (CHECK_FP_EXP): Likewise.
* gcc.target/i386/m512-check.h (CHECK_ROUGH_EXP): Likewise.

3 years agotestsuite: Fix sse2-andnpd-1.c and sse-andnps-1.c testscases on powerpc
Jakub Jelinek [Fri, 22 Jan 2021 21:38:31 +0000 (22:38 +0100)]
testsuite: Fix sse2-andnpd-1.c and sse-andnps-1.c testscases on powerpc

On Mon, Sep 21, 2020 at 10:12:20AM +0200, Richard Biener wrote:
> On Mon, 21 Sep 2020, Jan Hubicka wrote:
> > these testcases now fails because they contains an invalid type puning
> > that happens via const VALUE_TYPE *v pointer. Since the check function
> > is noinline, modref is needed to trigger the wrong code.
> > I think it is easiest to fix it by no-strict-aliasing.
> >
> > Regtested x86_64-linux, OK?
>
> OK.
>
> >     * gcc.target/i386/m128-check.h: Add no-strict aliasing to
> >     CHECK_EXP macro.
> >
> > diff --git a/gcc/testsuite/gcc.target/i386/m128-check.h b/gcc/testsuite/gcc.target/i386/m128-check.h
> > index 48b23328539..6f414b07be7 100644
> > --- a/gcc/testsuite/gcc.target/i386/m128-check.h
> > +++ b/gcc/testsuite/gcc.target/i386/m128-check.h
> > @@ -78,6 +78,7 @@ typedef union
> >
> >  #define CHECK_EXP(UINON_TYPE, VALUE_TYPE, FMT)             \
> >  static int                                         \
> > +__attribute__((optimize ("no-strict-aliasing")))   \
> >  __attribute__((noinline, unused))                  \
> >  check_##UINON_TYPE (UINON_TYPE u, const VALUE_TYPE *v)     \
> >  {                                                  \

On powerpc64le the tests suffer from the exact same issue.

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

* gcc.target/powerpc/m128-check.h (check_##UINON_TYPE): Add
optimize ("no-strict-aliasing") attribute.

3 years agodwarf2out: Always emit required 0 entries for DWARF 5 in *.debug_line [PR98796]
Jakub Jelinek [Fri, 22 Jan 2021 21:37:36 +0000 (22:37 +0100)]
dwarf2out: Always emit required 0 entries for DWARF 5 in *.debug_line [PR98796]

When GCC is emitting .debug_line or .gnu.debuglto_.debug_line section by
itself (happens either with too old or non-GNU assembler, with
-gno-as-loc-support or with -flto) on empty translation units, it violates
the DWARF 5 requirements.
The standard says:
"The first entry is the current directory of the compilation."
and a few lines later:
"The first entry in the sequence is the primary source file whose file name
exactly matches that given in the DW_AT_name attribute in the compilation
unit debugging information entry."
GCC emits 4 zeros (directory entry format count, directories count,
filename entry format count and filename count), which would be ok if the
spec said The first entry may be rather than is.

I had a brief look at whether I could just fall through into the rest of the
function, but there are too many assumptions that there is at least one
normal file that it can't be done that way easily.

So this patch instead extends the early out code to emit the required
minimum, which is 15 bytes more than we used to emit before.

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

PR debug/98796
* dwarf2out.c (output_file_names): For -gdwarf-5, if there are no
filenames to emit, still emit the required 0 index directory and
filename entries that match DW_AT_comp_dir and DW_AT_name of the
compilation unit.

3 years agoMAINTAINERS: Add myself for write after approval
Jonathan Wright [Fri, 22 Jan 2021 19:09:11 +0000 (19:09 +0000)]
MAINTAINERS: Add myself for write after approval

ChangeLog:

2021-01-22  Jonathan Wright  <jonathan.wright@arm.com>

* MAINTAINERS (Write After Approval): Add myself.

3 years agoc++: Fix base copy elision thinko [PR98744]
Jason Merrill [Fri, 22 Jan 2021 16:57:27 +0000 (11:57 -0500)]
c++: Fix base copy elision thinko [PR98744]

As Jakub points out in the PR, I was mixing up
DECL_HAS_IN_CHARGE_PARM_P (which is true for the abstract maybe-in-charge
constructor) and DECL_HAS_VTT_PARM_P (which is true for a base constructor
that needs to handle virtual bases).

gcc/cp/ChangeLog:

PR c++/98744
* call.c (make_base_init_ok): Use DECL_HAS_VTT_PARM_P.

gcc/testsuite/ChangeLog:

PR c++/98744
* g++.dg/init/elide7.C: New test.

3 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.

3 years agoc++: ICE when mangling operator name [PR98545]
Marek Polacek [Wed, 13 Jan 2021 21:33:39 +0000 (16:33 -0500)]
c++: ICE when mangling operator name [PR98545]

r11-6301 added some asserts in mangle.c, and now we trip over one of
them.  In particular, it's the one asserting that we didn't get
IDENTIFIER_ANY_OP_P when mangling an expression with a dependent name.

As this testcase shows, it's possible to get that, so turn the assert
into an if and write "on".  That changes the mangling in the following
way:

With this patch:

$ c++filt _ZN1i1hIJ1adS1_EEEDTcldtdefpTonclspcvT__EEEDpS2_
decltype (((*this).(operator()))((a)(), (double)(), (a)())) i::h<a, double, a>(a, double, a)

G++10:
$ c++filt _ZN1i1hIJ1adS1_EEEDTcldtdefpTclspcvT__EEEDpS2_
decltype (((*this).(operator()))((a)(), (double)(), (a)())) i::h<a, double, a>(a, double, a)

clang++/icc:
$ c++filt _ZN1i1hIJ1adS1_EEEDTclonclspcvT__EEEDpS2_
decltype ((operator())((a)(), (double)(), (a)())) i::h<a, double, a>(a, double, a)

This is now tracked in PR98756.

gcc/cp/ChangeLog:

PR c++/98545
* mangle.c (write_member_name): Emit abi_warn_or_compat_version_crosses
warnings regardless of abi_version_at_least.
(write_expression): When the expression is a dependent name
and an operator name, write "on" before writing its name.

gcc/ChangeLog:

PR c++/98545
* doc/invoke.texi: Update C++ ABI Version 15 description.

gcc/testsuite/ChangeLog:

PR c++/98545
* g++.dg/abi/mangle76.C: New test.

3 years agoFortran: Fix for class functions as associated target [PR98565].
Paul Thomas [Fri, 22 Jan 2021 17:11:06 +0000 (17:11 +0000)]
Fortran: Fix for class functions as associated target [PR98565].

2021-01-22  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/98565
* trans-intrinsic.c (gfc_conv_associated): Do not add a _data
component for scalar class function targets. Instead, fix the
function result and access the _data from that.

gcc/testsuite/
PR fortran/98565
* gfortran.dg/associated_target_7.f90 : New test.

3 years agoTestcase for old PR 47059
Martin Jambor [Fri, 22 Jan 2021 17:09:38 +0000 (18:09 +0100)]
Testcase for old PR 47059

I stumbled across PR 47059 from 2010 which has been addressed by
store-merging.  I am going to close it but would like to add its
testcase too.

gcc/testsuite/ChangeLog:

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

PR tree-optimization/47059
* gcc.dg/tree-ssa/pr47059.c: New test.

3 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.

3 years agotestsuite: Uniquify test names [PR 98795]
Nathan Sidwell [Fri, 22 Jan 2021 14:44:22 +0000 (06:44 -0800)]
testsuite: Uniquify test names [PR 98795]

Header unit names come from the path the preprocessor determines, and
thus can be absolute.  This tweaks the testsuite to elide that
absoluteness when embedded in a CMI name.  We were also not
distinguishing link and execute tests by the $std flags, so append
them when necessary.

PR testsuite/98795
gcc/testsuite/
* g++.dg/modules/modules.exp (module_cmi_p): Avoid
embedded absolute paths.
(module_do_it): Append $std to test name.

3 years agomiddle-end/98793 - properly handle BLKmode vectors in vector_element_bits
Richard Biener [Fri, 22 Jan 2021 13:32:39 +0000 (14:32 +0100)]
middle-end/98793 - properly handle BLKmode vectors in vector_element_bits

The previous change made AVX512 mask vectors correct but disregarded
the possibility of generic (BLKmode) boolean vectors which are exposed
by the frontends already.

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

PR middle-end/98793
* tree.c (vector_element_bits): Key single-bit bool vector on
integer mode rather than not vector mode.

* gcc.dg/pr98793.c: New testcase.

3 years agors6000: Enable vec_insert for P8 with rs6000_expand_vector_set_var_p8 [PR98093]
Xionghu Luo [Fri, 22 Jan 2021 03:03:28 +0000 (21:03 -0600)]
rs6000: Enable vec_insert for P8 with rs6000_expand_vector_set_var_p8 [PR98093]

Support P8 variable vec_insert and Update testcases' instruction count.

gcc/ChangeLog:

2021-01-22  Xionghu Luo  <luoxhu@linux.ibm.com>

PR target/98093

* config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin):
Generate ARRAY_REF(VIEW_CONVERT_EXPR) for P8 and later
platforms.
* config/rs6000/rs6000.c (rs6000_expand_vector_set_var): Update
to call different path for P8 and P9.
(rs6000_expand_vector_set_var_p9): New function.
(rs6000_expand_vector_set_var_p8): New function.

gcc/testsuite/ChangeLog:

2021-01-22  Xionghu Luo  <luoxhu@linux.ibm.com>

* gcc.target/powerpc/pr79251.p8.c: New test.
* gcc.target/powerpc/fold-vec-insert-char-p8.c: Adjust
instruction counts.
* gcc.target/powerpc/fold-vec-insert-char-p9.c: Likewise.
* gcc.target/powerpc/fold-vec-insert-double.c: Likewise.
* gcc.target/powerpc/fold-vec-insert-float-p8.c: Likewise.
* gcc.target/powerpc/fold-vec-insert-float-p9.c: Likewise.
* gcc.target/powerpc/fold-vec-insert-int-p8.c: Likewise.
* gcc.target/powerpc/fold-vec-insert-int-p9.c: Likewise.
* gcc.target/powerpc/fold-vec-insert-longlong.c: Likewise.
* gcc.target/powerpc/fold-vec-insert-short-p8.c: Likewise.
* gcc.target/powerpc/fold-vec-insert-short-p9.c: Likewise.
* gcc.target/powerpc/vsx-builtin-7.c: Likewise.

3 years agors6000: Support variable insert and Expand vec_insert in expander [PR79251]
Xionghu Luo [Fri, 22 Jan 2021 03:01:24 +0000 (21:01 -0600)]
rs6000: Support variable insert and Expand vec_insert in expander [PR79251]

vec_insert accepts 3 arguments, arg0 is input vector, arg1 is the value
to be insert, arg2 is the place to insert arg1 to arg0.  Current expander
generates stxv+stwx+lxv if arg2 is variable instead of constant, which
causes serious store hit load performance issue on Power.  This patch tries
 1) Build VIEW_CONVERT_EXPR for vec_insert (i, v, n) like v[n&3] = i to
unify the gimple code, then expander could use vec_set_optab to expand.
 2) Expand the IFN VEC_SET to fast instructions: lvsr+insert+lvsl.
In this way, "vec_insert (i, v, n)" and "v[n&3] = i" won't be expanded too
early in gimple stage if arg2 is variable, avoid generating store hit load
instructions.

For Power9 V4SI:
addi 9,1,-16
rldic 6,6,2,60
stxv 34,-16(1)
stwx 5,9,6
lxv 34,-16(1)
=>
rlwinm 6,6,2,28,29
mtvsrwz 0,5
lvsr 1,0,6
lvsl 0,0,6
xxperm 34,34,33
xxinsertw 34,0,12
xxperm 34,34,32

Though instructions increase from 5 to 7, the performance is improved
60% in typical cases.
Tested with V2DI, V2DF V4SI, V4SF, V8HI, V16QI on Power9-LE.

2021-01-22  Xionghu Luo  <luoxhu@linux.ibm.com>

gcc/ChangeLog:

PR target/79251
PR target/98065

* config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin):
Ajdust variable index vec_insert from address dereference to
ARRAY_REF(VIEW_CONVERT_EXPR) tree expression.
* config/rs6000/rs6000-protos.h (rs6000_expand_vector_set_var):
New declaration.
* config/rs6000/rs6000.c (rs6000_expand_vector_set_var): New function.

2021-01-22  Xionghu Luo  <luoxhu@linux.ibm.com>

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr79251.p9.c: New test.
* gcc.target/powerpc/pr79251-run.c: New test.
* gcc.target/powerpc/pr79251.h: New header.

3 years agoDrop time profile for multi-threaded training run.
Martin Liska [Fri, 22 Jan 2021 13:00:30 +0000 (14:00 +0100)]
Drop time profile for multi-threaded training run.

gcc/ChangeLog:

PR gcov-profile/98739
* profile.c (compute_value_histograms): Drop time profile for
-fprofile-reproducible=multithreaded.

3 years agodriver: do not check file existence here [PR 98452]
Nathan Sidwell [Tue, 19 Jan 2021 19:43:15 +0000 (11:43 -0800)]
driver: do not check file existence here [PR 98452]

The driver checks whether OPT_SPECIAL_input_file options are readable.
There's no need, the compiler proper will do that anyway.

gcc/
* gcc.c (process_command): Don't check OPT_SPECIAL_input_file
existence here.

3 years agomiddle-end/98773 - always sign extend CHREC_RIGHT
Richard Biener [Fri, 22 Jan 2021 10:29:17 +0000 (11:29 +0100)]
middle-end/98773 - always sign extend CHREC_RIGHT

The previous change exposed a miscompile when trying to interpret
CHREC_RIGHT correctly which in fact it already was to the extent
it is used.  The following reverts this part of the change, only
retaining the singling out of HOST_WIDE_INT_MIN.

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

PR middle-end/98773
* tree-data-ref.c (initalize_matrix_A): Revert previous
change, retaining failing on HOST_WIDE_INT_MIN CHREC_RIGHT.

* gcc.dg/torture/pr98773.c: New testcase.

3 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.

3 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.

3 years agotree-optimization/98786 - fix issue with phiopt and abnormals
Richard Biener [Fri, 22 Jan 2021 09:34:42 +0000 (10:34 +0100)]
tree-optimization/98786 - fix issue with phiopt and abnormals

This fixes factor_out_conditional_conversion to avoid creating overlapping
lifetimes for abnormals.  It also makes sure we do deal with a conditional
conversion (at least for one PHI arg def) - for the testcase that wasn't the case.

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

PR tree-optimization/98786
* tree-ssa-phiopt.c (factor_out_conditional_conversion): Avoid
adding new uses of abnormals.  Verify we deal with a conditional
conversion.

* gcc.dg/torture/pr98786.c: New testcase.

3 years agoarm: Fix ICE with incompatible values for -mfp16-format [PR98636].
Prathamesh Kulkarni [Fri, 22 Jan 2021 08:44:20 +0000 (14:14 +0530)]
arm: Fix ICE with incompatible values for -mfp16-format [PR98636].

gcc/
2021-01-22  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

PR target/98636
* optc-save-gen.awk: Add arm_fp16_format to checked_options.

gcc/testsuite/
2021-01-22  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

PR target/98636
* gcc.target/arm/pr98636.c: New test.

3 years agoLower AVX512 vector comparison to AVX version when dest is vector.
liuhongt [Fri, 18 Dec 2020 07:56:06 +0000 (15:56 +0800)]
Lower AVX512 vector comparison to AVX version when dest is vector.

gcc/ChangeLog:

PR target/96891
PR target/98348
* config/i386/sse.md (VI_128_256): New mode iterator.
(*avx_cmp<mode>3_1, *avx_cmp<mode>3_2, *avx_cmp<mode>3_3,
 *avx_cmp<mode>3_4, *avx2_eq<mode>3, *avx2_pcmp<mode>3_1,
 *avx2_pcmp<mode>3_2, *avx2_gt<mode>3): New
define_insn_and_split to lower avx512 vector comparison to avx
version when dest is vector.
(*<avx512>_cmp<mode>3,*<avx512>_cmp<mode>3,*<avx512>_ucmp<mode>3):
define_insn_and_split for negating the comparison result.
* config/i386/predicates.md (float_vector_all_ones_operand):
New predicate.
* config/i386/i386-expand.c (ix86_expand_sse_movcc): Use
general NOT operator without UNSPEC_MASKOP.

gcc/testsuite/ChangeLog:

PR target/96891
PR target/98348
* gcc.target/i386/avx512bw-pr96891-1.c: New test.
* gcc.target/i386/avx512f-pr96891-1.c: New test.
* gcc.target/i386/avx512f-pr96891-2.c: New test.
* gcc.target/i386/avx512f-pr96891-3.c: New test.
* g++.target/i386/avx512f-pr96891-1.C: New test.
* gcc.target/i386/bitwise_mask_op-3.c: Adjust testcase.

3 years agoc++: ICE with delayed noexcept and attribute used [PR97966]
Marek Polacek [Tue, 12 Jan 2021 21:16:44 +0000 (16:16 -0500)]
c++: ICE with delayed noexcept and attribute used [PR97966]

Another ICE with delayed noexcept parsing, but a bit gnarlier.

A function definition marked with __attribute__((used)) ought to be
emitted even when it is not referenced in the TU.  For a member function
template marked with __attribute__((used)) this means that it will
be instantiated: in instantiate_class_template_1 we have

11971               /* Instantiate members marked with attribute used.  */
11972               if (r != error_mark_node && DECL_PRESERVE_P (r))
11973                 mark_used (r);

It is not so surprising that this doesn't work well with delayed
noexcept parsing: when we're processing the function template we delay
the parsing, so the member "foo" is found, but then when we're
instantiating it, "foo" hasn't yet been seen, which creates a
discrepancy and a crash ensues.  "foo" hasn't yet been seen because
instantiate_class_template_1 just loops over the class members and
instantiates right away.

To make it work, this patch uses a vector to keep track of members
marked with attribute used and uses it to instantiate such members
only after we're done with the class; in particular, after we have
called finish_member_declaration for each member.  And we ought to
be verifying that we did emit such members, so I've added a bunch
of dg-finals.

gcc/cp/ChangeLog:

PR c++/97966
* pt.c (instantiate_class_template_1): Instantiate members
marked with attribute used only after we're done instantiating
the class.

gcc/testsuite/ChangeLog:

PR c++/97966
* g++.dg/cpp0x/noexcept63.C: New test.

3 years agoMAINTAINERS: Update my e-mail address
Maciej W. Rozycki [Fri, 22 Jan 2021 00:11:12 +0000 (00:11 +0000)]
MAINTAINERS: Update my e-mail address

* MAINTAINERS (Write After Approval): Update my e-mail address.

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

3 years agotestsuite: Adjust cpp2a/lambda-uneval regrex
David Edelsohn [Thu, 21 Jan 2021 19:17:10 +0000 (14:17 -0500)]
testsuite: Adjust cpp2a/lambda-uneval regrex

Both lambda-uneval1.C and lambda-uneval5.C test that a symbol is not
declared global by looking for "globl" assembler directive.  The testcases
generate the "lglobl" directive in AIX XCOFF, which is a false positive.
This patch restricts the regex to ignore a prepended "l".  The patch
also tightens the regex to specifically look for space, tab or period
between the "globl" and the symbol.

Tested on powerpc-ibm-aix7.2.3.0 and powerpc64le-linux-gnu.

* g++.dg/cpp2a/lambda-uneval1.C: Ignore preceding "l" and
intervening period.
* g++.dg/cpp2a/lambda-uneval5.C: Ignore preceding "l" and
explicitly check for intervening space, tab or period.

3 years ago[PR98777] LRA: Use preliminary created pseudo for in LRA elimination subpass
Vladimir N. Makarov [Thu, 21 Jan 2021 22:27:01 +0000 (17:27 -0500)]
[PR98777] LRA: Use preliminary created pseudo for in LRA elimination subpass

LRA did not extend ira_reg_equiv after generation of a pseudo in
eliminate_regs_in_insn which might results in LRA crash.  It is better not
to extend ira_reg_equiv but to use preliminary generated pseudo.  The
patch implements it.

gcc/ChangeLog:

PR rtl-optimization/98777
* lra-int.h (lra_pmode_pseudo): New extern.
* lra.c (lra_pmode_pseudo): New global.
(lra): Set it up.
* lra-eliminations.c (eliminate_regs_in_insn): Use it.

gcc/testsuite/ChangeLog:

PR rtl-optimization/98777
* gcc.target/riscv/pr98777.c: New.

3 years agofwprop: Allow (subreg (mem)) simplifications
Ilya Leoshkevich [Thu, 14 Jan 2021 23:14:56 +0000 (00:14 +0100)]
fwprop: Allow (subreg (mem)) simplifications

Suppose we have:

    (set (reg/v:TF 63) (mem/c:TF (reg/v:DI 62)))
    (set (reg:FPRX2 66) (subreg:FPRX2 (reg/v:TF 63) 0))

It is clearly profitable to propagate the first insn into the second
one and get:

    (set (reg:FPRX2 66) (mem/c:FPRX2 (reg/v:DI 62)))

fwprop actually manages to perform this, but doesn't think the result is
worth it, which results in unnecessary store/load sequences on s390.
Improve the situation by classifying SUBREG -> MEM changes as
profitable.

gcc/ChangeLog:

2021-01-15  Ilya Leoshkevich  <iii@linux.ibm.com>

* fwprop.c (fwprop_propagation::classify_result): Allow
(subreg (mem)) simplifications.

3 years agoc++: Fix excessive instantiation inside decltype [PR71879]
Patrick Palka [Thu, 21 Jan 2021 19:04:55 +0000 (14:04 -0500)]
c++: Fix excessive instantiation inside decltype [PR71879]

Here after resolving the address of a template-id inside decltype, we
end up instantiating the chosen specialization (from the call to
mark_used in resolve_nondeduced_context), even though only its type is
needed.

This patch sets cp_unevaluated_operand throughout finish_decltype_type,
so that in particular it's set during the call to
resolve_nondeduced_context within.

gcc/cp/ChangeLog:

PR c++/71879
* semantics.c (finish_decltype_type): Set up a cp_unevaluated
sentinel at the start of the function.  Remove a now-redundant
manual adjustment of cp_unevaluated_operand.

gcc/testsuite/ChangeLog:

PR c++/71879
* g++.dg/cpp0x/decltype-71879.C: New test.

3 years agoc++: Fix null this pointer [PR 98624]
Nathan Sidwell [Thu, 21 Jan 2021 18:37:23 +0000 (10:37 -0800)]
c++: Fix null this pointer [PR 98624]

One may not use a null this pointer to invoke a static member
function.  This fixes the remaining ubsan errors found with an
ubsan bootstrap.

PR c++/98624
gcc/cp/
* module.cc (depset::hash::find_dependencies): Add
module arg.
(trees_out::core_vals): Check state before calling
write_location.
(sort_cluster, module_state::write): Adjust
find_dependencies call.

3 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.

3 years agoaarch64: Use canonical RTL for sqdmlal patterns
Kyrylo Tkachov [Thu, 21 Jan 2021 14:06:16 +0000 (14:06 +0000)]
aarch64: Use canonical RTL for sqdmlal patterns

The aarch64_sqdml<SBINQOPS:as>l patterns are of the form:
  [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
        (SBINQOPS:<VWIDE>
  (match_operand:<VWIDE> 1 "register_operand" "0")
  (ss_ashift:<VWIDE>
      (mult:<VWIDE>
(sign_extend:<VWIDE>
      (match_operand:VSD_HSI 2 "register_operand" "w"))
(sign_extend:<VWIDE>
      (match_operand:VSD_HSI 3 "register_operand" "w")))
      (const_int 1))))]

where SBINQOPS is ss_plus and ss_minus. The problem is that for the
ss_plus case the RTL
is not canonical: the (match_oprand 1) should be the second arm of the
PLUS.
I've seen this manifest in combine missing some legitimate
simplifications because it generates
the canonical ss_plus form and fails to match the pattern.

This patch splits the patterns into the ss_plus and ss_minus forms with
the canonical form for each.
I've seen this improve my testcase (which I can't include as it's too
large and not easy to test reliably).

gcc/ChangeLog:

* config/aarch64/aarch64-simd.md (aarch64_sqdml<SBINQOPS:as>l<mode>):
Split into...
(aarch64_sqdmlal<mode>): ... This...
(aarch64_sqdmlsl<mode>): ... And this.
(aarch64_sqdml<SBINQOPS:as>l_lane<mode>): Split into...
(aarch64_sqdmlal_lane<mode>): ... This...
(aarch64_sqdmlsl_lane<mode>): ... And this.
(aarch64_sqdml<SBINQOPS:as>l_laneq<mode>): Split into...
(aarch64_sqdmlsl_laneq<mode>): ... This...
(aarch64_sqdmlal_laneq<mode>):  ... And this.
(aarch64_sqdml<SBINQOPS:as>l_n<mode>): Split into...
(aarch64_sqdmlsl_n<mode>): ... This...
(aarch64_sqdmlal_n<mode>): ... And this.
(aarch64_sqdml<SBINQOPS:as>l2<mode>_internal): Split into...
(aarch64_sqdmlal2<mode>_internal): ... This...
(aarch64_sqdmlsl2<mode>_internal): ... And this.

3 years agod: Enable private member access for __traits
Iain Buclaw [Thu, 21 Jan 2021 09:31:36 +0000 (10:31 +0100)]
d: Enable private member access for __traits

The following traits can now access non-public members:
 - hasMember
 - getMember
 - getOverloads
 - getVirtualMethods
 - getVirtualFuntions

This fixes a long-standing issue in D where the allMembers trait would
correctly return non-public members but those non-public members would
be inaccessible to other traits.

Reviewed-on: https://github.com/dlang/dmd/pull/12135

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 3a7ebef73.

3 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.

3 years agoarm: [testuiste] Fix ivopts.c target test [PR96372]
Andrea Corallo [Fri, 15 Jan 2021 14:34:19 +0000 (15:34 +0100)]
arm: [testuiste] Fix ivopts.c target test [PR96372]

gcc/
2021-01-15  Andrea Corallo  <andrea.corallo@arm.com>
PR target/96372
* doc/sourcebuild.texi (arm_thumb2_no_arm_v8_1_lob): Document.

gcc/testsuite/
2021-01-15  Andrea Corallo  <andrea.corallo@arm.com>
PR target/96372
* lib/target-supports.exp
(check_effective_target_arm_thumb2_no_arm_v8_1_lob): Define proc.
* gcc.target/arm/ivopts.c: Use target
'arm_thumb2_no_arm_v8_1_lob'.

3 years agogcc/fortran/intrinsic.texi: Fix typo
Jorge D'Elia [Thu, 21 Jan 2021 13:23:28 +0000 (14:23 +0100)]
gcc/fortran/intrinsic.texi: Fix typo

gcc/fortran/ChangeLog:

* intrinsic.texi (CO_MAX): Fix typo.

3 years agoc++: Stat-hack for members [PR 98530]
Nathan Sidwell [Thu, 21 Jan 2021 12:48:39 +0000 (04:48 -0800)]
c++: Stat-hack for members [PR 98530]

This was a header file that deployed the stat-hack inside a class
(both a member-class and a [non-static data] member had the same
name).  Due to the way that's represented in name lookup we missed the
class.  Sadly just changing the representation globally has
detrimental effects elsewhere, and this is a rare case, so just
creating a new overload on the fly shouldn't be a problem.

PR c++/98530
gcc/cp/
* name-lookup.c (lookup_class_binding): Rearrange a stat-hack.
gcc/testsuite/
* g++.dg/modules/stat-mem-1.h: New.
* g++.dg/modules/stat-mem-1_a.H: New.
* g++.dg/modules/stat-mem-1_b.C: New.

3 years agolibstdc++: Regenerate Makefile.in
Jonathan Wakely [Thu, 21 Jan 2021 11:56:07 +0000 (11:56 +0000)]
libstdc++: Regenerate Makefile.in

This removes a trivial whitespace difference between the currently
committed file and the one regenerated by autotools.

libstdc++-v3/ChangeLog:

* src/c++17/Makefile.in: Regenerate.

3 years agoFortran: This patch fixes comments 23 and 24 of PR96320.
Paul Thomas [Thu, 21 Jan 2021 10:00:00 +0000 (10:00 +0000)]
Fortran: This patch fixes comments 23 and 24 of PR96320.

2021-01-21  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/96320
* decl.c (gfc_match_modproc): It is not an error to find a
module procedure declaration within a contains block.
* expr.c (gfc_check_vardef_context): Pure procedure result is
assignable. Change 'own_scope' accordingly.
* resolve.c (resolve_typebound_procedure): A procedure that
has the module procedure attribute is almost certainly a
module procedure, whatever its interface.

gcc/testsuite/
PR fortran/96320
* gfortran.dg/module_procedure_5.f90 : New test.
* gfortran.dg/module_procedure_6.f90 : New test.

3 years agotestsuite/97299 - more gcc.dg/vect/slp-reduc-3.c massaging
Richard Biener [Thu, 21 Jan 2021 09:57:18 +0000 (10:57 +0100)]
testsuite/97299 - more gcc.dg/vect/slp-reduc-3.c massaging

This adds more guards to the VEC_PERM_EXPR scan, namely that
we also could end up with load-lanes and of course no vectorization
at all.  Need dependent scans (scan-if-scan-X PASSed ...).

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

PR testsuite/97299
* gcc.dg/vect/slp-reduc-3.c: Amend target selectors.

3 years agotestsuite/98241 - remove ilp32 XFAIL of gcc.dg/pr78973.c
Richard Biener [Thu, 21 Jan 2021 09:35:11 +0000 (10:35 +0100)]
testsuite/98241 - remove ilp32 XFAIL of gcc.dg/pr78973.c

XPASSes as reported.

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

PR testsuite/98241
* gcc.dg/pr78973.c: Remove ilp32 XFAIL.

3 years agotestsuite/98224 - un-XFAIL Walloca-2.c on ilp32
Richard Biener [Thu, 21 Jan 2021 09:30:56 +0000 (10:30 +0100)]
testsuite/98224 - un-XFAIL Walloca-2.c on ilp32

As reported this now XPASSes with ranger.

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

* gcc.dg/Walloca-2.c: Un-XFAIL.

3 years agoFix incorrect optimization by cprop_hardreg.
liuhongt [Mon, 18 Jan 2021 08:55:32 +0000 (16:55 +0800)]
Fix incorrect optimization by cprop_hardreg.

If SRC had been assigned a mode narrower than the copy, we can't
always link DEST into the chain even they have same
hard_regno_nregs(i.e. HImode/SImode in i386 backend).

i.e
        kmovw   %k0, %edi
        vmovd   %edi, %xmm2
vpshuflw        $0, %xmm2, %xmm0
        kmovw   %k0, %r8d
        kmovd   %k0, %r9d
...
-  movl %r9d, %r11d
+  vmovd %xmm2, %r11d

gcc/ChangeLog:

PR rtl-optimization/98694
* regcprop.c (copy_value): If SRC had been assigned a mode
narrower than the copy, we can't link DEST into the chain even
they have same hard_regno_nregs(i.e. HImode/SImode in i386
backend).

gcc/testsuite/ChangeLog:

PR rtl-optimization/98694
* gcc.target/i386/pr98694.c: New test.

3 years agoDaily bump.
GCC Administrator [Thu, 21 Jan 2021 00:16:36 +0000 (00:16 +0000)]
Daily bump.

3 years agoaix: make ctype_inline.h thread-safe and avoid _OBJ_DATA char subscript.
David Edelsohn [Wed, 20 Jan 2021 03:24:08 +0000 (22:24 -0500)]
aix: make ctype_inline.h thread-safe and avoid _OBJ_DATA char subscript.

g++.dg/warn/Wstringop-overflow-6.C tests for a bogus overflow warning in
system headers.  This testcase was generating a -Wchar-subscript warning
on AIX because ctype_inline.h was subscripting AIX _OBJ_DATA using a char.
The _M_table case cast the subscript to unsigned char, but the _OBJ_DATA
case did not.

The investigation also exposed that AIX has added a thread-safe variant
of access to __lc_type that had not been applied to the libstdc++
implementation.

This patch casts the subscript to unsigned char and adds the THREAD_SAFE
variant.  libstdc++ always is compiled with pthreads, but it is good
to make the situation explicit and to document the appropriate usage.

Bootstrapped on powerpc-ibm-aix7.2.3.0.

libstdc++-v3/ChangeLog:

* config/os/aix/ctype_inline.h (bool ctype<char>:: is): Cast
_OBJ_DATA subscript to unsigned char. Add _THREAD_SAFE access to
__lc_type.
(const char* ctype<char>:: is): Same.

3 years agoRe: trapv question
Andrew MacLeod [Wed, 20 Jan 2021 21:27:34 +0000 (16:27 -0500)]
Re: trapv question

Adjust testcase to so the ADD that is expected to overflow cannot
be optimized.

gcc/testsuite
* gcc.dg/torture/ftrapv-2.c: Make overflow instruction unremovable.

3 years agolibgomp: Fix up GOMP_task on s390x
Jakub Jelinek [Wed, 20 Jan 2021 21:09:22 +0000 (22:09 +0100)]
libgomp: Fix up GOMP_task on s390x

On Wed, Jan 20, 2021 at 05:04:39PM +0100, Florian Weimer wrote:
> Sorry, this appears to cause OpenMP task state corruption in RPM.  We
> have only seen this on s390x.

Haven't actually verified it, but my suspection is that this is a caller
stack corruption.

We play with fire with the GOMP_task API/ABI extensions, the GOMP_task
function used to be:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags);
and later:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags,
           void **depend);
and later:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags,
           void **depend, int priority);
and now:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags,
           void **depend, int priority, void *detach)
and which of those depend, priority and detach argument is present depends
on the bits in flags.
I'm afraid the compiler just decided to spill the detach = NULL store in
  if ((flags & GOMP_TASK_FLAG_DETACH) == 0)
    detach = NULL;
on s390x into the argument stack slot.  Not a problem if the caller passes
all those 10 arguments, but if not, can clobber random stack location.

This hack should fix it up.  Priority doesn't need changing, but I've
changed it anyway just to be safe.  With the patch none of the 3 arguments
are ever modified, so I'd hope gcc doesn't decide to spill something
unrelated there.

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

* task.c (GOMP_task): Rename priority argument to priority_arg,
add priority automatic variable and modify that variable.  Instead of
clearing detach argument when GOMP_TASK_FLAG_DETACH bit is not set,
check flags for that bit.

3 years agoc++: Avoid UB in signed shift [PR 98625]
Nathan Sidwell [Wed, 20 Jan 2021 17:21:02 +0000 (09:21 -0800)]
c++: Avoid UB in signed shift [PR 98625]

I'd forgotten that left shifting a negative value is UB until C++20.
Insert some casts to do unsigned shifts.

PT c++/98625
gcc/cp/
* module.cc (bytes_in::i, bytes_in::wi): Avoid left shift of
signed type.

3 years agoaarch64: Split vec_selects of bottom elements into simple move
Kyrylo Tkachov [Wed, 20 Jan 2021 18:11:20 +0000 (18:11 +0000)]
aarch64: Split vec_selects of bottom elements into simple move

In certain intrinsics use cases GCC leaves SETs of a bottom-element vec
select lying around:
        (vec_select:DI (reg:V2DI 34 v2 [orig:128 __o ] [128])
            (parallel [
                    (const_int 0 [0])
                ])))

This can be treated as a simple move in aarch64 when done between SIMD
registers for all normal widths.
These go through the aarch64_get_lane pattern.
This patch adds a splitter there to simplify these extracts to a move
that can, perhaps, be optimised a way.
Another benefit is if the destination is memory we can use a simpler STR
instruction rather than ST1-lane.

gcc/

* config/aarch64/aarch64-simd.md (aarch64_get_lane<mode>):
Convert to define_insn_and_split.  Split into simple move when moving
bottom element.

gcc/testsuite/

* gcc.target/aarch64/vdup_lane_2.c: Scan for fmov rather than
dup.

3 years agors6000: Fix rs6000_emit_le_vsx_store (PR98549)
Segher Boessenkool [Tue, 19 Jan 2021 23:43:56 +0000 (23:43 +0000)]
rs6000: Fix rs6000_emit_le_vsx_store (PR98549)

One of the advantages of LRA is that you can create new pseudos from it
just fine.  The code in rs6000_emit_le_vsx_store was not aware of this.
This patch changes that, in the process fixing PR98549 (where it is
shown that we do call rs6000_emit_le_vsx_store during LRA, which we
used to assert can not happen).

2021-01-20  Segher Boessenkool  <segher@kernel.crashing.org>

* config/rs6000/rs6000.c (rs6000_emit_le_vsx_store): Change assert.
Adjust comment.  Simplify code.

3 years agodebug: Fix up DWARF 5 -g -flto -ffat-lto-objects [PR98765]
Jakub Jelinek [Wed, 20 Jan 2021 17:51:04 +0000 (18:51 +0100)]
debug: Fix up DWARF 5 -g -flto -ffat-lto-objects [PR98765]

As mentioned in the PR, with -gdwarf-5 (or -g now) -flto -ffat-lto-objects,
users can't strip the LTO sections with
strip -p -R .gnu.lto_* -R .gnu.debuglto_* -N __gnu_lto_v1
anymore when GCC is configured against recent binutils.

The problem is that in that case .gnu.debuglto_.debug_line_str section is
then used, which is fine for references to strings in .gnu.debuglto_.*
sections, but not when those references are in .debug_info section too;
those should really reference separate strings in .debug_line_str section.

For .gnu.debuglto_.debug_str vs. .debug_str we handle it right, we
reset_indirect_string the strings and thus force creation of new labels for
the second time.
But for DW_FORM_line_strp as the patch shows, there were multiple problems.
First one was that reset_indirect_string, even when called through traverse
on debug_line_str_hash, didn't do anything at all (fixed by first hunk).
The second bug was that the DW_FORM_line_strp strings, which were supposed
to be only visible through debug_line_str_hash, leaked into debug_str_hash
(second hunk).
And the third thing is that when we reset debug_line_str_hash, we should
still make those strings DW_FORM_line_strp if they are accessed.
One could do it by reinstantiating DW_FORM_line_strp right away in
reset_indirect_string and not clear debug_line_str_hash, but that has the
disadvantage that we then force emitting .debug_line_str strings that aren't
really needed - we need those from the CU DIEs' DW_AT_name and
DW_AT_comp_dir attributes, but when emitting .debug_line section through
assembler, we don't need to emit the strings we only needed for
.gnu.debuglto_.debug_line which is always emitted by the compiler.

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

PR debug/98765
* dwarf2out.c (reset_indirect_string): Also reset indirect strings
with DW_FORM_line_strp form.
(prune_unused_types_update_strings): Don't add into debug_str_hash
indirect strings with DW_FORM_line_strp form.
(adjust_name_comp_dir): New function.
(dwarf2out_finish): Call it on CU DIEs after resetting
debug_line_str_hash.

3 years ago[PR98722] LRA: Check that target has no 3-op add insn to transform 2 plus expression.
Vladimir N. Makarov [Wed, 20 Jan 2021 16:40:14 +0000 (11:40 -0500)]
[PR98722] LRA: Check that target has no 3-op add insn to transform 2 plus expression.

Patch cf2ac1c30af0fa783c8d72e527904dda5d8cc330 for solving PR97969 was
assumed for targets with absent 3-op add insn.  But the original patch did
not check this.  This patch adds the check.

gcc/ChangeLog:

PR rtl-optimization/98722
* lra-eliminations.c (eliminate_regs_in_insn): Check that target
has no 3-op add insn to transform insns containing two pluses.

gcc/testsuite/ChangeLog:

PR rtl-optimization/98722
* g++.target/s390/pr98722.C: New.

3 years agoHandle overflow in dependence analysis lambda ops gracefully
Richard Biener [Wed, 20 Jan 2021 10:28:30 +0000 (11:28 +0100)]
Handle overflow in dependence analysis lambda ops gracefully

The following tries to handle overflow in the integer computations
done by lambda ops of dependence analysis by failing instead of
silently continuing with overflowed values.

It also avoids treating large unsigned CHREC_RIGHT as negative
unless the chrec is of pointer type and avoids the most negative
integer value to avoid excessive overflow checking (with this
the fix for PR98758 can be partly simplified as seen).

I've added add_hwi and mul_hwi functions computing HOST_WIDE_INT
signed sum and product with indicating overflow, they hopefully
get matched to the appropriate internal functions.

I don't have any testcases triggering overflow in any of the
guarded computations.

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

* hwint.h (add_hwi): New function.
(mul_hwi): Likewise.
* tree-data-ref.c (initialize_matrix_A): Properly translate
tree constants and avoid HOST_WIDE_INT_MIN.
(lambda_matrix_row_add): Avoid undefined integer overflow
and return true on such overflow.
(lambda_matrix_right_hermite): Handle overflow from
lambda_matrix_row_add gracefully.  Simplify previous fix.
(analyze_subscript_affine_affine): Likewise.

3 years agoOptimize combination of comparisons to dec+compare
Eugene Rozenfeld [Thu, 10 Dec 2020 00:44:25 +0000 (16:44 -0800)]
Optimize combination of comparisons to dec+compare

This patch adds patterns for optimizing
x < y || y == XXX_MIN to x <= y-1
x >= y && y != XXX_MIN to x > y-1
if y is an integer with TYPE_OVERFLOW_WRAPS.

This fixes pr96674.

Tested on x86_64-pc-linux-gnu.

For this function

bool f(unsigned a, unsigned b)
{
    return (b == 0) | (a < b);
}

the code without the patch is

test   esi,esi
sete   al
cmp    esi,edi
seta   dl
or     eax,edx
ret

the code with the patch is

sub    esi,0x1
cmp    esi,edi
setae  al
ret

PR tree-optimization/96674
gcc/
* match.pd: New patterns: x < y || y == XXX_MIN --> x <= y - 1
x >= y && y != XXX_MIN --> x > y - 1

gcc/testsuite
* gcc.dg/pr96674.c: New tests.

3 years agoc++: Fix tsubsting CLASS_PLACEHOLDER_TEMPLATE [PR95434]
Patrick Palka [Wed, 20 Jan 2021 14:44:33 +0000 (09:44 -0500)]
c++: Fix tsubsting CLASS_PLACEHOLDER_TEMPLATE [PR95434]

Here, during partial instantiation of the generic lambda, we do
tsubst_copy on the CLASS_PLACEHOLDER_TEMPLATE for U{0} which yields a
(level-lowered) TEMPLATE_TEMPLATE_PARM rather than the corresponding
TEMPLATE_DECL.  This later confuses do_class_deduction which expects
that a CLASS_PLACEHOLDER_TEMPLATE is always a TEMPLATE_DECL.

gcc/cp/ChangeLog:

PR c++/95434
* pt.c (tsubst) <case TEMPLATE_TYPE_PARM>: If tsubsting
CLASS_PLACEHOLDER_TEMPLATE yields a TEMPLATE_TEMPLATE_PARM,
adjust to its TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL.

gcc/testsuite/ChangeLog:

PR c++/95434
* g++.dg/cpp2a/lambda-generic9.C: New test.

3 years agoc++: Defer access checking when processing bases [PR82613]
Patrick Palka [Wed, 20 Jan 2021 14:43:48 +0000 (09:43 -0500)]
c++: Defer access checking when processing bases [PR82613]

When parsing the base-clause of a class declaration, we need to defer
access checking until the entire base-clause has been seen, so that
access can be properly checked relative to the scope of the class with
all its bases attached.  This allows us to accept the declaration of
struct D from Example 2 of [class.access.general] (access12.C below).

Similarly when substituting into the base-clause of a class template,
which is the subject of PR82613.

gcc/cp/ChangeLog:

PR c++/82613
* parser.c (cp_parser_class_head): Defer access checking when
parsing the base-clause until all bases are seen and attached
to the class type.
* pt.c (instantiate_class_template): Likewise when substituting
into dependent bases.

gcc/testsuite/ChangeLog:

PR c++/82613
* g++.dg/parse/access12.C: New test.
* g++.dg/template/access35.C: New test.

3 years agovect: Fix VLA SLP invariant optimisation [PR98535]
Richard Sandiford [Wed, 20 Jan 2021 13:16:30 +0000 (13:16 +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.

3 years agoFix gfortran.dg/gomp/task-detach-1.f90 for non 64bit pointers
Tobias Burnus [Wed, 20 Jan 2021 10:27:26 +0000 (11:27 +0100)]
Fix gfortran.dg/gomp/task-detach-1.f90 for non 64bit pointers

gcc/testsuite/ChangeLog:

PR fortran/98763
* gfortran.dg/gomp/task-detach-1.f90: Use integer(1) to avoid
missing diagnostic issues with c_intptr_t == default integer kind.

3 years agobuiltins: Fix up two bugs in access_ref::inform_access [PR98721]
Jakub Jelinek [Wed, 20 Jan 2021 08:49:24 +0000 (09:49 +0100)]
builtins: Fix up two bugs in access_ref::inform_access [PR98721]

The following patch fixes two bugs in the access_ref::inform_access function
(plus some formatting nits).

The first problem is that ref can be various things, e.g. *_DECL, or
SSA_NAME, or IDENTIFIER_NODE.  And allocfn is non-NULL only if ref is
(at least originally) an SSA_NAME initialized to the result of some
allocator function (but not e.g. __builtin_alloca_with_align which is
handled differently).

A few lines above the last hunk of this patch in builtins.c, the code uses
  if (mode == access_read_write || mode == access_write_only)
    {
      if (allocfn == NULL_TREE)
        {
          if (*offstr)
            inform (loc, "at offset %s into destination object %qE of size %s",
                    offstr, ref, sizestr);
          else
            inform (loc, "destination object %qE of size %s", ref, sizestr);
          return;
        }

      if (*offstr)
        inform (loc,
                "at offset %s into destination object of size %s "
                "allocated by %qE", offstr, sizestr, allocfn);
      else
        inform (loc, "destination object of size %s allocated by %qE",
                sizestr, allocfn);
      return;
    }
so if allocfn is NULL, it prints whatever ref is, if it is non-NULL,
it prints instead the allocation function.  But strangely the hunk
a few lines below wasn't consistent with that and instead printed the
first form only if DECL_P (ref) and would ICE if ref wasn't a decl but
still allocfn was NULL.  Fixed by making it consistent what the code does
earlier.

Another bug is that the code earlier contains an ugly hack for VLAs and was
assuming that SSA_NAME_IDENTIFIER must be non-NULL on the lhs of
__builtin_alloca_with_align.  While that is likely true for the cases where
the compiler emits this builtin for VLAs (and it will also be true that
the name of the VLA in that case can be taken from that identifier up to the
first .), the builtin is user accessible as the testcase shows, so one can
have any other SSA_NAME in there.  I think it would be better to add some
more reliable way how to identify VLA names corresponding to
__builtin_alloca_with_align allocations, perhaps internal fn or whatever,
but that is beyond the scope of this patch.

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

PR tree-optimization/98721
* builtins.c (access_ref::inform_access): Don't assume
SSA_NAME_IDENTIFIER must be non-NULL.  Print messages about
object whenever allocfn is NULL, rather than only when DECL_P
is true.  Use %qE instead of %qD for that.  Formatting fixes.

* gcc.dg/pr98721-1.c: New test.
* gcc.dg/pr98721-2.c: New test.

3 years agotree-optimization/98758 - fix integer arithmetic in data-ref analysis
Richard Biener [Wed, 20 Jan 2021 07:48:34 +0000 (08:48 +0100)]
tree-optimization/98758 - fix integer arithmetic in data-ref analysis

This fixes some int arithmetic issues and a bogus truncation.

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

PR tree-optimization/98758
* tree-data-ref.c (int_divides_p): Use lambda_int arguments.
(lambda_matrix_right_hermite): Avoid undefinedness with
signed integer abs and multiplication.
(analyze_subscript_affine_affine): Use lambda_int.

* gcc.dg/torture/pr98758.c: New testcase.

3 years agoopenmp: Don't ICE on detach clause with erroneous decl [PR98742]
Jakub Jelinek [Wed, 20 Jan 2021 07:35:20 +0000 (08:35 +0100)]
openmp: Don't ICE on detach clause with erroneous decl [PR98742]

Similarly to how we handle erroneous operands to e.g. allocate clause,
this change just removes those clauses instead of accessing TYPE_MAIN_VARIANT
of its type, which doesn't work on error_mark_node.  Also, just for good
measure, bails out if TYPE_NAME is NULL.

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

PR c++/98742
* semantics.c (finish_omp_clauses) <case OMP_CLAUSE_DETACH>: If
error_operand_p, remove clause without further checking.  Check
for non-NULL TYPE_NAME.

* c-c++-common/gomp/task-detach-2.c: New test.

3 years agoOpenMP/Fortran: Fix gfortran.dg/gomp/is_device_ptr-2.f90
Tobias Burnus [Wed, 20 Jan 2021 07:31:30 +0000 (08:31 +0100)]
OpenMP/Fortran: Fix gfortran.dg/gomp/is_device_ptr-2.f90

gcc/testsuite/ChangeLog:

PR fortran/98757
PR fortran/98476
* gfortran.dg/gomp/is_device_ptr-2.f90: Fix dg-error.

3 years agodwarf2out: reset generation count in toplev::finalize [PR98751]
David Malcolm [Wed, 20 Jan 2021 00:58:23 +0000 (19:58 -0500)]
dwarf2out: reset generation count in toplev::finalize [PR98751]

PR debug/98751 reports an issue in which most of libgccjit's tests
fails in DWARF 5 handling with
  `.Ldebug_loc2' is already defined"
asm errors.

The bogus label is being emitted at the 3rd in-process iteration, at:
  31673       ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
which on the initial iteration emits:

 145   │ .Ldebug_loc0:

on the 2nd iteration:
 145   │ .Ldebug_loc1:

and on the 3rd iteration:
 145   │ .Ldebug_loc2:

which is a duplicate of a label emitted earlier:
 138   │     .section    .debug_loclists,"",@progbits
 139   │     .long   .Ldebug_loc3-.Ldebug_loc2
 140   │ .Ldebug_loc2:
 141   │     .value  0x5
 142   │     .byte   0x8
 143   │     .byte   0
 144   │     .long   0
 145   │ .Ldebug_loc2:

The issue seems to be that init_sections_and_labels creates the label
  ASM_GENERATE_INTERNAL_LABEL (loc_section_label, DEBUG_LOC_SECTION_LABEL,
       generation);

where "generation" is a static local to init_sections_and_labels that
increments, and thus eventually hits the duplicate value.

It appears that this value is intended to be either 0 or 1, but in
the libgccjit case the compilation code can be invoked an arbitrary
number of times in-process, and hence can eventually lead to a
label name collision.

This patch adds code to dwarf2out_c_finalize (called by
toplev::finalize in libgccjit) to reset the generation counts,
fixing the issue.

gcc/ChangeLog:
PR debug/98751
* dwarf2out.c (output_line_info): Rename static variable
"generation", moving it out of the function to...
(output_line_info_generation): New.
(init_sections_and_labels): Likewise, renaming the variable to...
(init_sections_and_labels_generation): New.
(dwarf2out_c_finalize): Reset the new variables.

3 years agoDaily bump.
GCC Administrator [Wed, 20 Jan 2021 00:16:46 +0000 (00:16 +0000)]
Daily bump.

3 years agotestsuite: aix testsuite adjustments
David Edelsohn [Tue, 19 Jan 2021 19:58:35 +0000 (14:58 -0500)]
testsuite: aix testsuite adjustments

This patch re-enables the DWARF5 tests that seem to be functioning again.
It adds a comment to pr41445-7.c that any changes in lines need to be
reflected in the expected output.

The patch also allows for additional failures in ucs.c and reflects that
builtin-sprintf-warn-20.c requires 4 byte wide char support.

gcc/testsuite/ChangeLog:

* gcc.dg/cpp/ucs.c: Expect Invalid warning for 2byte wchar.
* gcc.dg/debug/dwarf2/inline6.c: Remove skip AIX.
* gcc.dg/debug/dwarf2/lang-c11.c: Remove skip AIX.
* gcc.dg/debug/dwarf2/pr41445-7.c: Remove skip AIX.
* gcc.dg/debug/dwarf2/pr41445-8.c: Remove skip AIX.
* gcc.dg/tree-ssa/builtin-sprintf-warn-20.c: Require 4byte wchar.

3 years agoUpdate gcc de.po.
Joseph Myers [Tue, 19 Jan 2021 23:29:33 +0000 (23:29 +0000)]
Update gcc de.po.

* de.po: Update.

3 years agoc++: Crash when deducing template arguments [PR98659]
Marek Polacek [Wed, 13 Jan 2021 18:12:14 +0000 (13:12 -0500)]
c++: Crash when deducing template arguments [PR98659]

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++/98659
* pt.c (maybe_instantiate_noexcept): Return false if FN is
error_mark_node.

gcc/testsuite/ChangeLog:

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

3 years agocompiler: initialize variables with go:embed directives
Ian Lance Taylor [Tue, 5 Jan 2021 06:13:40 +0000 (22:13 -0800)]
compiler: initialize variables with go:embed directives

This completes the compiler work for go:embed.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/281536

3 years agoc++: ICE with USING_DECL redeclaration [PR98687]
Marek Polacek [Fri, 15 Jan 2021 03:14:38 +0000 (22:14 -0500)]
c++: ICE with USING_DECL redeclaration [PR98687]

My recent patch that introduced push_using_decl_bindings didn't
handle USING_DECL redeclaration, therefore things broke.  This patch
amends that by breaking out a part of finish_nonmember_using_decl
out to a separate function, push_using_decl_bindings, and calling it.
It needs an overload, because name_lookup is only available inside
of name-lookup.c.

gcc/cp/ChangeLog:

PR c++/98687
* name-lookup.c (push_using_decl_bindings): New, broken out of...
(finish_nonmember_using_decl): ...here.
* name-lookup.h (push_using_decl_bindings): Update declaration.
* pt.c (tsubst_expr): Update the call to push_using_decl_bindings.

gcc/testsuite/ChangeLog:

PR c++/98687
* g++.dg/lookup/using64.C: New test.
* g++.dg/lookup/using65.C: New test.

3 years agoPR middle-end/98664 - inconsistent -Wfree-nonheap-object for inlined calls to system...
Martin Sebor [Tue, 19 Jan 2021 22:10:30 +0000 (15:10 -0700)]
PR middle-end/98664 - inconsistent -Wfree-nonheap-object for inlined calls to system headers

gcc/ChangeLog:

PR middle-end/98664
* tree-ssa-live.c (remove_unused_scope_block_p): Keep scopes for
all functions, even if they're not declared artificial or inline.
* tree.c (tree_inlined_location): Use macro expansion location
only if scope traversal fails to expose one.

gcc/testsuite/ChangeLog:

PR middle-end/98664
* gcc.dg/Wvla-larger-than-4.c: Adjust expected output.
* gcc.dg/plugin/diagnostic-test-inlining-3.c: Same.
* g++.dg/warn/Wfree-nonheap-object-5.C: New test.
* gcc.dg/Wfree-nonheap-object-4.c: New test.

3 years agoc++: Always check access during late-parsing of members [PR58993]
Patrick Palka [Tue, 19 Jan 2021 21:20:00 +0000 (16:20 -0500)]
c++: Always check access during late-parsing of members [PR58993]

This patch removes a vestigial use of dk_no_check from
cp_parser_late_parsing_for_member, which ideally should have been
removed as part of the PR41437 patch that improved access checking
inside templates.  This allows us to correctly reject f1 and f2 in
the testcase access34.C below (whereas before we'd only reject f3).

Additional testing revealed a new access issue when late-parsing a hidden
friend within a class template.  In the testcase friend68.C below, we're
tripping over the checking assert from friend_accessible_p(f, S::j, S, S)
during lookup of j in x.j (for which type_dependent_object_expression_p
returns false, which is why we're doing the lookup at parse time).  The
reason for the assert failure is that DECL_FRIENDLIST(S) contains f but
DECL_BEFRIENDING_CLASSES(f) is empty, and so friend_accessible_p (which
looks at DECL_BEFRIENDING_CLASSES) wants to return false, but is_friend
(which looks at DECL_FRIENDLIST) returns true.

For sake of symmetry one would expect that DECL_BEFRIENDING_CLASSES(f)
contains S, but add_friend avoids updating DECL_BEFRIENDING_CLASSES when
the class type (S in this case) is dependent, for some reason.

This patch works around this issue by making friend_accessible_p
consider the DECL_FRIEND_CONTEXT of the access scope.  Thus we sidestep
the DECL_BEFRIENDING_CLASSES / DECL_FRIENDLIST asymmetry issue while
correctly validating the x.j access at parse time.

A earlier version of this patch checked friend_accessible_p instead of
protected_accessible_p in the DECL_FRIEND_CONTEXT hunk below, but this
had the side effect of making us accept the ill-formed testcase friend69.C
below (ill-formed because the hidden friend g is not actually a member
of A, so g doesn't have access to B's members despite B befriending A).

gcc/cp/ChangeLog:

PR c++/41437
PR c++/58993
* search.c (friend_accessible_p): If scope is a hidden friend
defined inside a dependent class, consider access from the
class.
* parser.c (cp_parser_late_parsing_for_member): Don't push a
dk_no_check access state.

gcc/testsuite/ChangeLog:

PR c++/41437
PR c++/58993
* g++.dg/opt/pr87974.C: Adjust.
* g++.dg/template/access34.C: New test.
* g++.dg/template/friend68.C: New test.
* g++.dg/template/friend69.C: New test.

3 years agoc++: ICE when late parsing noexcept/NSDMI [PR98333]
Marek Polacek [Fri, 8 Jan 2021 20:48:41 +0000 (15:48 -0500)]
c++: ICE when late parsing noexcept/NSDMI [PR98333]

Since certain members of a class are a complete-class context
[class.mem.general]p7, we delay their parsing untile the whole class has
been parsed.  For instance, NSDMIs and noexcept-specifiers.  The order
in which we perform this delayed parsing matters; we were first parsing
NSDMIs and only they did we parse noexcept-specifiers.   That turns out
to be wrong: since NSDMIs may use noexcept-specifiers, we must process
noexcept-specifiers first.  Otherwise we'll ICE in code that doesn't
expect to see DEFERRED_PARSE.

This doesn't just shift the problem, noexcept-specifiers can use members
with a NSDMI just fine, and I've also tested a similar test with this
member function:

  bool f() { return __has_nothrow_constructor (S<true>); }

and that compiled fine too.

gcc/cp/ChangeLog:

PR c++/98333
* parser.c (cp_parser_class_specifier_1): Perform late-parsing
of NSDMIs before late-parsing of noexcept-specifiers.

gcc/testsuite/ChangeLog:

PR c++/98333
* g++.dg/cpp0x/noexcept62.C: New test.

3 years agoc++: Remove unused fn
Nathan Sidwell [Tue, 19 Jan 2021 14:49:08 +0000 (06:49 -0800)]
c++:  Remove unused fn

I had two overloads of a function, but only one was needed.  Let's keep
the constant one.

gcc/cp/
* module.cc (identifier): Merge overloads.

3 years agoc++: Fix null this pointer [PR 98624]
Nathan Sidwell [Tue, 19 Jan 2021 19:31:57 +0000 (11:31 -0800)]
c++: Fix null this pointer [PR 98624]

There's no need for this function to have an object, so make it
static and avoid UB.

PR c++/98624
gcc/cp/
* module.cc (trees_out::write_location): Make static.

3 years agoalias: Fix offset checks involving section anchors [PR92294]
Richard Sandiford [Tue, 19 Jan 2021 17:50:53 +0000 (17:50 +0000)]
alias: Fix offset checks involving section anchors [PR92294]

memrefs_conflict_p assumes that:

  [XB + XO, XB + XO + XS)

does not alias

  [YB + YO, YB + YO + YS)

whenever:

  [XO, XO + XS)

does not intersect

  [YO, YO + YS)

In other words, the accesses can alias only if XB == YB at runtime.

However, this doesn't cope correctly with section anchors.
For example, if XB is an anchor symbol and YB is at offset
XO from the anchor, then:

  [XB + XO, XB + XO + XS)

overlaps

  [YB, YB + YS)

whatever the value of XO is.  In other words, when doing the
alias check for two symbols whose local definitions are in
the same block, we should apply the known difference between
their block offsets to the intersection test above.

gcc/
PR rtl-optimization/92294
* alias.c (compare_base_symbol_refs): Take an extra parameter
and add the distance between two symbols to it.  Enshrine in
comments that -1 means "either 0 or 1, but we can't tell
which at compile time".
(memrefs_conflict_p): Update call accordingly.
(rtx_equal_for_memref_p): Likewise.  Take the distance between symbols
into account.

3 years ago[PATCH, rs6000] Update pr88233.c test (pr91799)
Will Schmidt [Wed, 13 Jan 2021 19:48:30 +0000 (13:48 -0600)]
[PATCH, rs6000] Update pr88233.c test (pr91799)

Hi,

This is a follow-up fix to clean up pr91799.  Per review of test results,
it appears that the combination of target and dg-require stanzas is
not sufficient to properly limit the test to 64-bit only on darwin.

This adds an additional dg-require clause to limit the test to 64-bit
environments.

Tested on power7 and power8 using assorted variations of
  make -k check-gcc-c "RUNTESTFLAGS=powerpc.exp=pr88233.c
  --target_board=unix/'{-mcpu=power7,-mcpu=power6,-mcpu=power8}''{-m32,-m64}'"

PR target/91799

2021-01-19  Will Schmidt <will_schmidt@vnet.ibm.com>

gcc/testsuite/ChangeLog:
* gcc.target/powerpc/pr88233.c: Update dg- stanzas.

3 years agoaarch64: Relax flags of saturation builtins
Kyrylo Tkachov [Tue, 19 Jan 2021 15:37:25 +0000 (15:37 +0000)]
aarch64: Relax flags of saturation builtins

This patch relaxes the flags for the saturating arithmetic builtins to
NONE, allowing for more optimisation.

gcc/ChangeLog

* config/aarch64/aarch64-simd-builtins.def (sqshl, uqshl,
sqrshl, uqrshl, sqadd, uqadd, sqsub, uqsub, suqadd, usqadd, sqmovn,
uqmovn, sqxtn2, uqxtn2, sqabs, sqneg, sqdmlal, sqdmlsl, sqdmlal_lane,
sqdmlsl_lane, sqdmlal_laneq, sqdmlsl_laneq, sqdmlal_n, sqdmlsl_n,
sqdmlal2, sqdmlsl2, sqdmlal2_lane, sqdmlsl2_lane, sqdmlal2_laneq,
sqdmlsl2_laneq, sqdmlal2_n, sqdmlsl2_n, sqdmull, sqdmull_lane,
sqdmull_laneq, sqdmull_n, sqdmull2, sqdmull2_lane, sqdmull2_laneq,
sqdmull2_n, sqdmulh, sqrdmulh, sqdmulh_lane, sqdmulh_laneq,
sqrdmulh_lane, sqrdmulh_laneq, sqshrun_n, sqrshrun_n, sqshrn_n,
uqshrn_n, sqrshrn_n, uqrshrn_n, sqshlu_n, sqshl_n, uqshl_n, sqrdmlah,
sqrdmlsh, sqrdmlah_lane, sqrdmlsh_lane, sqrdmlah_laneq, sqrdmlsh_laneq,
sqmovun): Use NONE flags.

3 years agoaarch64: Remove testing of saturation cumulative QC bit
Kyrylo Tkachov [Tue, 19 Jan 2021 15:36:55 +0000 (15:36 +0000)]
aarch64: Remove testing of saturation cumulative QC bit

Since we don't guarantee the ordering of the QC flag in FPSR in the
saturation intrinsics, we shouldn't be testing for it.
I want to relax the flags for some of the builtins to enable more
optimisation but that triggers the QC flag tests in
advsimd-intrinsics.exp.
We don't implement the saturation flag access intrinsics in aarch64
anyway and we don't want to.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/advsimd-intrinsics/arm-neon-ref.h
(CHECK_CUMULATIVE_SAT): Delete.
(CHECK_CUMULATIVE_SAT_NAMED): Likewise.  Deleted related
variables.
* gcc.target/aarch64/advsimd-intrinsics/binary_sat_op.inc:
Remove uses of the above.
* gcc.target/aarch64/advsimd-intrinsics/unary_sat_op.inc:
Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqabs.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqadd.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmlXl.inc: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmlXl_lane.inc:
Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmlXl_n.inc: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmlal.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmlal_lane.c:
Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmlal_n.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmlsl.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmlsl_lane.c:
Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmlsl_n.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmulh.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmulh_lane.c:
Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmulh_n.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmull.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmull_lane.c:
Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqdmull_n.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqmovn.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqmovun.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqneg.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqrdmlXh.inc: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqrdmlXh_lane.inc:
Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqrdmlah.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqrdmlah_lane.c:
Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqrdmlsh.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqrdmlsh_lane.c:
Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqrdmulh.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqrdmulh_lane.c:
Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqrdmulh_n.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqrshl.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqrshrn_n.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqrshrun_n.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqshl.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqshl_n.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqshlu_n.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqshrn_n.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqshrun_n.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vqsub.c: Likewise.

3 years ago[committed] Fix dwarf-float.c test in testsuite
Jeff Law [Tue, 19 Jan 2021 15:35:55 +0000 (08:35 -0700)]
[committed] Fix dwarf-float.c test in testsuite

gcc/testsuite
* gcc.dg/debug/dwarf2/dwarf-float.c: Force dwarf-4 generation
and update expected output.

3 years agoipa/98330 - avoid ICEing on call indirect call
Richard Biener [Tue, 19 Jan 2021 13:21:41 +0000 (14:21 +0100)]
ipa/98330 - avoid ICEing on call indirect call

The following avoids ICEing on a indirect calls with a fnspec
in modref analysis.

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

PR ipa/98330
* ipa-modref.c (analyze_stmt): Only record a summary for a
direct call.

* g++.dg/pr98330.C: New testcase.
* gcc.dg/pr98330.c: Likewise.

3 years agomiddle-end/98638 - avoid SSA reference to stmts after SSA deconstruction
Richard Biener [Tue, 19 Jan 2021 12:40:39 +0000 (13:40 +0100)]
middle-end/98638 - avoid SSA reference to stmts after SSA deconstruction

Since SSA names do leak into global tree data structures like
TYPE_SIZE or in this case GFC_DECL_SAVED_DESCRIPTOR because of
frontend bugs we have to be careful to wipe references to the
CFG when we deconstruct SSA form because we now do ggc_free that.

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

PR middle-end/98638
* tree-ssanames.c (fini_ssanames): Zero SSA_NAME_DEF_STMT.

3 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.

3 years agoipa/97673 - fix input_location leak
Richard Biener [Tue, 19 Jan 2021 11:29:18 +0000 (12:29 +0100)]
ipa/97673 - fix input_location leak

This fixes input_location leaking with an invalid BLOCK from
expand_call_inline to tree_function_versioning via clone
materialization.

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

PR ipa/97673
* tree-inline.c (tree_function_versioning): Set input_location
to UNKNOWN_LOCATION throughout the function.

* gfortran.dg/pr97673.f90: New testcase.

3 years agoOpenMP/Fortran: Fixes for {use,is}_device_ptr
Tobias Burnus [Tue, 19 Jan 2021 10:57:34 +0000 (11:57 +0100)]
OpenMP/Fortran: Fixes for {use,is}_device_ptr

gcc/fortran/ChangeLog:

PR fortran/98476
* openmp.c (resolve_omp_clauses): Change use_device_ptr
to use_device_addr for unless type(c_ptr); check all
list item for is_device_ptr.

gcc/ChangeLog:

PR fortran/98476
* omp-low.c (lower_omp_target): Handle nonpointer is_device_ptr.

libgomp/ChangeLog:

PR fortran/98476
* testsuite/libgomp.fortran/is_device_ptr-1.f90: New test.

gcc/testsuite/ChangeLog:

PR fortran/98476
* gfortran.dg/gomp/map-3.f90: Update expected scan-dump-tree.
* gfortran.dg/gomp/is_device_ptr-2.f90: New test.
* gfortran.dg/gomp/use_device_ptr-1.f90: New test.

3 years agoipa-sra: Do not remove return values needed because of non-call EH
Martin Jambor [Tue, 19 Jan 2021 10:28:48 +0000 (11:28 +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.

3 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.

3 years agoRISC-V: The 'multilib-generator' enhancement.
Geng Qi [Mon, 18 Jan 2021 06:09:27 +0000 (14:09 +0800)]
RISC-V: The 'multilib-generator' enhancement.

Think about this case:
  ./multilib-generator rv32imc-ilp32-rv32imac,rv32imacxthead-f
Here are 2 problems:
  1. A unexpected 'xtheadf' extension was made.
  2. The arch 'rv32imac' was not be created.
This modification fix these two, and also sorts 'multi-letter'.

gcc/ChangeLog:
* config/riscv/arch-canonicalize (longext_sort): New function for
 sorting 'multi-letter'.
* config/riscv/multilib-generator: Adjusting the loop of 'alt' in
'alts'. The 'arch' may not be the first of 'alts'.
(_expand_combination): Add underline for the 'ext' without '*'.
This is because, a single-letter extension can always be treated well
with a '_' prefix, but it cannot be separated out if it is appended
to a multi-letter.

3 years agocompiler: read embedcfg files, parse go:embed directives
Ian Lance Taylor [Tue, 5 Jan 2021 05:40:29 +0000 (21:40 -0800)]
compiler: read embedcfg files, parse go:embed directives

This change reads go:embed directives and attaches them to variables.
We still don't do anything with the directives.

This change also reads the file passed in the -fgo-embedcfg option.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/281533