gcc.git
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

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

3 years ago[committed] Minor fix to pr41445-7 testcase
Jeff Law [Mon, 18 Jan 2021 23:04:11 +0000 (16:04 -0700)]
[committed] Minor fix to pr41445-7 testcase

gcc/testsuite
* gcc.dg/debug/dwarf2/pr41445-7.c: Fix expected output.

3 years agolibbacktrace: don't fail tests if dwz fails
Ian Lance Taylor [Mon, 18 Jan 2021 22:45:57 +0000 (14:45 -0800)]
libbacktrace: don't fail tests if dwz fails

* Makefile.am (%_dwz): If dwz fails, use uncompressed debug info.
* Makefile.in: Regenerate.
* configure: Regenerate.

3 years agolibbacktrace: use correct directory/filename for DWARF 5
Ian Lance Taylor [Mon, 18 Jan 2021 22:38:10 +0000 (14:38 -0800)]
libbacktrace: use correct directory/filename for DWARF 5

PR debug/98716
* dwarf.c (read_v2_paths): Allocate zero entry for dirs and
filenames.
(read_line_program): Remove parameter u, change caller.  Don't
subtract one from dirs and filenames index.
(read_function_entry): Don't subtract one from filenames index.

3 years ago[PR97847] IRA: Skip abnormal critical edge splitting
Vladimir N. Makarov [Mon, 18 Jan 2021 21:41:39 +0000 (16:41 -0500)]
[PR97847] IRA: Skip abnormal critical edge splitting

PPC64 can generate jumps with clobbered pseudo-regs and a BB with
such jump can have abnormal output edges.  IRA hits an assert when trying
to split abnormal critical edge to deal with asm goto output reloads
later.  The patch just skips splitting abnormal edges.  It is assumed
that asm-goto with output reloads can not be in BB with output abnormal edges.

gcc/ChangeLog:

PR target/97847
* ira.c (ira): Skip abnormal critical edge splitting.

3 years agoc++: Add CTAD + pack expansion testcase
Patrick Palka [Mon, 18 Jan 2021 21:41:46 +0000 (16:41 -0500)]
c++: Add CTAD + pack expansion testcase

After r11-6614 made cp_walk_subtrees walk into the template of a CTAD
placeholder, we now correctly accept the below testcase.  We used to
reject it because find_parameter_packs_r would fail to find the
parameter pack Ts inside the CTAD placeholder within the pack expansion.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/class-deduction77.C: New test.

3 years agowidening_mul: Fix up signed multiplication overflow check handling [PR98727]
Jakub Jelinek [Mon, 18 Jan 2021 18:13:44 +0000 (19:13 +0100)]
widening_mul: Fix up signed multiplication overflow check handling [PR98727]

I forgot one line, which means that if the second operand of the multiplication
isn't constant, it would be just the same as the first one.

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

PR tree-optimization/98727
* tree-ssa-math-opts.c (match_arith_overflow): Fix up computation of
second .MUL_OVERFLOW operand for signed multiplication with overflow
checking if the second operand of multiplication is not constant.

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

3 years agoaix: document dwarf 4 default (and TPF default)
David Edelsohn [Mon, 18 Jan 2021 18:09:28 +0000 (13:09 -0500)]
aix: document dwarf 4 default (and TPF default)

gcc/ChangeLog:

* doc/invoke.texi (-gdwarf): TPF defaults to version 2 and AIX
defaults to version 4.

3 years agoSkip asm goto tests on hppa*-*-*.
John David Anglin [Mon, 18 Jan 2021 15:45:47 +0000 (15:45 +0000)]
Skip asm goto tests on hppa*-*-*.

gcc/testsuite/ChangeLog:

PR testsuite/97987
* gcc.c-torture/compile/asmgoto-2.c: Skip on hppa.
* gcc.c-torture/compile/asmgoto-5.c: Likewise.

3 years agoAvoid no-stack-protector-attr fails on hppa*-*-*.
John David Anglin [Mon, 18 Jan 2021 15:38:40 +0000 (15:38 +0000)]
Avoid no-stack-protector-attr fails on hppa*-*-*.

gcc/testsuite/ChangeLog:

* g++.dg/no-stack-protector-attr-3.C: Don't compile on hppa*-*-*.
* g++.dg/no-stack-protector-attr.C: Likewise.

3 years agoanalyzer: use "malloc" attribute
David Malcolm [Mon, 18 Jan 2021 14:24:46 +0000 (09:24 -0500)]
analyzer: use "malloc" attribute

In dce6c58db87ebf7f4477bd3126228e73e4eeee97 msebor extended the
"malloc" attribute to support user-defined allocator/deallocator
pairs.

This patch extends the "malloc" checker within -fanalyzer to use
these attributes.  It is based on an earlier patch:
  'RFC: add "deallocated_by" attribute for use by analyzer'
    https://gcc.gnu.org/pipermail/gcc-patches/2020-October/555544.html
which added a different attribute.  The patch needed a lot of reworking
to support multiple deallocators per allocator.

My hope was that this would provide a minimal level of markup that would
support library-checking without requiring lots of further markup.
I attempted to use this to detect a memory leak within a Linux
driver (CVE-2019-19078), by adding the attribute to mark these fns:
extern struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags);
extern void usb_free_urb(struct urb *urb);
where there is a leak of a "urb" on an error-handling path.
Unfortunately I ran into the problem that there are various other fns
that take "struct urb *" and the analyzer conservatively assumes that a
urb passed to them might or might not be freed and thus stops tracking
state for them.

Hence this will only detect issues for the simplest cases (without
adding another attribute).

gcc/analyzer/ChangeLog:
* analyzer.h (is_std_named_call_p): New decl.
* diagnostic-manager.cc (path_builder::get_sm): New.
(state_change_event_creator::state_change_event_creator): Add "pb"
param.
(state_change_event_creator::on_global_state_change): Don't consider
state changes affecting other state_machines.
(state_change_event_creator::on_state_change): Likewise.
(state_change_event_creator::m_pb): New field.
(diagnostic_manager::add_events_for_eedge): Pass pb to visitor
ctor.
* region-model-impl-calls.cc
(region_model::impl_deallocation_call): New.
* region-model.cc: Include "attribs.h".
(region_model::on_call_post): Handle fndecls referenced by
__attribute__((deallocated_by(FOO))).
* region-model.h (region_model::impl_deallocation_call): New decl.
* sm-malloc.cc: Include "stringpool.h" and "attribs.h".  Add
leading comment.
(class api): Delete.
(enum resource_state): Update comment for change from api to
deallocator and deallocator_set.
(allocation_state::allocation_state): Drop api param.  Add
"deallocators" and "deallocator".
(allocation_state::m_api): Drop field in favor of...
(allocation_state::m_deallocators): New field.
(allocation_state::m_deallocator): New field.
(enum wording): Add WORDING_DEALLOCATED.
(struct deallocator): New.
(struct standard_deallocator): New.
(struct custom_deallocator): New.
(struct deallocator_set): New.
(struct custom_deallocator_set): New.
(struct standard_deallocator_set): New.
(struct deallocator_set_map_traits): New.
(malloc_state_machine::m_malloc): Drop field
(malloc_state_machine::m_scalar_new): Likewise.
(malloc_state_machine::m_vector_new): Likewise.
(malloc_state_machine::m_free): New field
(malloc_state_machine::m_scalar_delete): Likewise.
(malloc_state_machine::m_vector_delete): Likewise.
(malloc_state_machine::deallocator_map_t): New typedef.
(malloc_state_machine::m_deallocator_map): New field.
(malloc_state_machine::deallocator_set_cache_t): New typedef.
(malloc_state_machine::m_custom_deallocator_set_cache): New field.
(malloc_state_machine::custom_deallocator_set_map_t): New typedef.
(malloc_state_machine::m_custom_deallocator_set_map): New field.
(malloc_state_machine::m_dynamic_sets): New field.
(malloc_state_machine::m_dynamic_deallocators): New field.
(api::api): Delete.
(deallocator::deallocator): New ctor.
(deallocator::hash): New.
(deallocator::dump_to_pp): New.
(deallocator::cmp): New.
(deallocator::cmp_ptr_ptr): New.
(standard_deallocator::standard_deallocator): New ctor.
(deallocator_set::deallocator_set): New ctor.
(deallocator_set::dump): New.
(custom_deallocator_set::custom_deallocator_set): New ctor.
(custom_deallocator_set::contains_p): New.
(custom_deallocator_set::maybe_get_single): New.
(custom_deallocator_set::dump_to_pp): New.
(standard_deallocator_set::standard_deallocator_set): New ctor.
(standard_deallocator_set::contains_p): New.
(standard_deallocator_set::maybe_get_single): New.
(standard_deallocator_set::dump_to_pp): New.
(start_p): New.
(class mismatching_deallocation): Update for conversion from api
to deallocator_set and deallocator.
(double_free::emit): Use %qs.
(class use_after_free): Update for conversion from api to
deallocator_set and deallocator.
(malloc_leak::describe_state_change): Only emit "allocated here" on
a start->nonnull transition, rather than on other transitions to
nonnull.
(allocation_state::dump_to_pp): Update for conversion from api to
deallocator_set.
(allocation_state::get_nonnull): Likewise.
(malloc_state_machine::malloc_state_machine): Likewise.
(malloc_state_machine::~malloc_state_machine): New.
(malloc_state_machine::add_state): Update for conversion from api
to deallocator_set.
(malloc_state_machine::get_or_create_custom_deallocator_set): New.
(malloc_state_machine::maybe_create_custom_deallocator_set): New.
(malloc_state_machine::get_or_create_deallocator): New.
(malloc_state_machine::on_stmt): Update for conversion from api
to deallocator_set.  Handle "__attribute__((malloc(FOO)))", and
the special attribute set on FOO.
(malloc_state_machine::on_allocator_call): Update for conversion
from api to deallocator_set.  Add "returns_nonnull" param and use
it to affect which state to transition to.
(malloc_state_machine::on_deallocator_call): Update for conversion
from api to deallocator_set.

gcc/ChangeLog:
* attribs.h (fndecl_dealloc_argno): New decl.
* builtins.c (call_dealloc_argno): Split out second half of
function into...
(fndecl_dealloc_argno): New.
* doc/extend.texi (Common Function Attributes): Document the
interaction between the analyzer and the malloc attribute.
* doc/invoke.texi (Static Analyzer Options): Likewise.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/attr-malloc-1.c: New test.
* gcc.dg/analyzer/attr-malloc-2.c: New test.
* gcc.dg/analyzer/attr-malloc-4.c: New test.
* gcc.dg/analyzer/attr-malloc-5.c: New test.
* gcc.dg/analyzer/attr-malloc-6.c: New test.
* gcc.dg/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c: New test.
* gcc.dg/analyzer/attr-malloc-misuses.c: New test.

3 years agolibstdc++: Only test writing to wostream if supported [PR 98725]
Jonathan Wakely [Mon, 18 Jan 2021 14:23:13 +0000 (14:23 +0000)]
libstdc++: Only test writing to wostream if supported [PR 98725]

libstdc++-v3/ChangeLog:

PR libstdc++/98725
* testsuite/20_util/unique_ptr/io/lwg2948.cc:  Do not try to
write to a wide character stream if wide character support is
disabled in the library.

3 years agotestsuite/97494 - adjust gcc.dg/vect/slp-11b.c
Richard Biener [Mon, 18 Jan 2021 14:18:15 +0000 (15:18 +0100)]
testsuite/97494 - adjust gcc.dg/vect/slp-11b.c

Support for loop SLP splitting exposed that slp-11b.c has
folding that breaks SLP discovery which isn't what was intended
when the testcase was written.  The following makes it SLP-able
and "only" run into the issue that a load permutation is required.

And tries to adjust the target selectors accordingly.

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

PR testsuite/97494
* gcc.dg/vect/slp-11b.c: Adjust.

3 years agolibgomp: enable linux-futex on riscv64
Andreas Schwab [Sun, 17 Jan 2021 16:19:46 +0000 (17:19 +0100)]
libgomp: enable linux-futex on riscv64

Regtested on riscv64-suse-linux.

libgomp/
* configure.tgt (riscv64*-*-linux*): Add linux to config_path.

3 years ago[arm,testsuite]: Fix options for vceqz_p64.c and vceqzq_p64.c
Christophe Lyon [Mon, 18 Jan 2021 13:55:04 +0000 (13:55 +0000)]
[arm,testsuite]: Fix options for vceqz_p64.c and vceqzq_p64.c

These two tests need:
dg-require-effective-target arm_crypto_ok
dg-add-options arm_crypto
because they use intrinsics that need -mfpu=crypto-neon-fp-armv8.

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

gcc/testsuite/
PR target/71233
* gcc.target/arm/simd/vceqz_p64.c: Use arm_crypto options.
* gcc.target/arm/simd/vceqzq_p64.c: Likewise.

3 years agotestsuite/97299 - fix test condition of gcc.dg/vect/slp-reduc-3.c
Richard Biener [Mon, 18 Jan 2021 13:51:00 +0000 (14:51 +0100)]
testsuite/97299 - fix test condition of gcc.dg/vect/slp-reduc-3.c

This avoids looking for permute optimization when SLP cannot be applied.

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

PR testsuite/97299
* gcc.dg/vect/slp-reduc-3.c: Guard VEC_PERM_EXPR scan.

3 years agolibstdc++: Fix narrow char test to use stringbuf not wstringbuf
Jonathan Wakely [Mon, 18 Jan 2021 12:44:27 +0000 (12:44 +0000)]
libstdc++: Fix narrow char test to use stringbuf not wstringbuf

This seems to be a copy & paste error.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_stringstream/cons/char/1.cc: Use
stringbuf not wstringbuf.

3 years agolibstd++: : Add workaround for as Error: file number less than one error [PR98708]
Jakub Jelinek [Mon, 18 Jan 2021 10:28:17 +0000 (11:28 +0100)]
libstd++: : Add workaround for as Error: file number less than one error [PR98708]

As mentioned in the PR, since the switch to DWARF5 by default instead of
DWARF4, gcc fails to build when configured against recent binutils.

The problem is that cxx11-ios_failure* is built in separate steps,
-S compilation (with -g -O2) followed by some sed and followed by
-c -g -O2 -g0 assembly.  When gcc is configured against recent binutils
and DWARF5 is the default, we emit .file 0 "..." directive on which the
assembler then fails (unless --gdwarf-5 is passed to it, but we don't want
that generally because on the other side older assemblers don't like -g*
passed to it when invoked on *.s file with compiler generated debug info.

I hope the bug will be fixed soon on the binutils side, but it would be nice
to have a workaround.

The following patch is one of the possibilities, another one is to do that
but add configure check for whether it is needed,
essentially
echo 'int main () { return 0; }' > conftest.c
${CXX} ${CXXFLAGS} -g -O2 -S conftest.c -o conftest.s
${CXX} ${CXXFLAGS} -g -O2 -g0 -c conftest.s -o conftest.o
and if the last command fails, we need that -gno-as-loc-support.
Or yet another option would be I think do a different check, whether
${CXX} ${CXXFLAGS} -g -O2 -S conftest.c -o conftest.s
${CXX} ${CXXFLAGS} -g -O2 -c conftest.s -o conftest.o
works and if yes, don't add the -g0 to cxx11-ios_failure*.s assembly.

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

PR debug/98708
* src/c++11/Makefile.am (cxx11-ios_failure-lt.s, cxx11-ios_failure.s):
Compile with -gno-as-loc-support.
* src/c++11/Makefile.in: Regenerated.

3 years agoRTEMS: Fix libgomp build
Sebastian Huber [Mon, 18 Jan 2021 06:23:46 +0000 (07:23 +0100)]
RTEMS: Fix libgomp build

libgomp/

* config/rtems/sem.h (gomp_sem_getcount): New function.

3 years agolibgomp: Don't access gomp_sem_t as int using atomics unconditionally
Jakub Jelinek [Mon, 18 Jan 2021 06:18:46 +0000 (07:18 +0100)]
libgomp: Don't access gomp_sem_t as int using atomics unconditionally

This patch introduces gomp_sem_getcount wrapper, which uses sem_getvalue
for POSIX and atomic loads for linux futex and accel.  rtems for now
remains broken.

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

* config/linux/sem.h (gomp_sem_getcount): New function.
* config/posix/sem.h (gomp_sem_getcount): New function.
* config/posix/sem.c (gomp_sem_getcount): New function.
* config/accel/sem.h (gomp_sem_getcount): New function.
* task.c (task_fulfilled_p): Use gomp_sem_getcount.
(omp_fulfill_event): Likewise.

3 years agotestsuite: powerpc fold-vec and sse updates.
David Edelsohn [Mon, 18 Jan 2021 00:33:04 +0000 (19:33 -0500)]
testsuite: powerpc fold-vec and sse updates.

Recent code generation changes have affected the count of some instructions.
This patch updates the instruction count for fold-vec-extract on P7 and P8.

Also, some of SSE emulation intrinsics only work on LE systems.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/fold-vec-extract-char.p7.c: Adjust addi count.
* gcc.target/powerpc/fold-vec-extract-double.p7.c: Same.
* gcc.target/powerpc/fold-vec-extract-float.p7.c: Same.
* gcc.target/powerpc/fold-vec-extract-float.p8.c: Same.
* gcc.target/powerpc/fold-vec-extract-int.p7.c: Same.
* gcc.target/powerpc/fold-vec-extract-int.p8.c: Same.
* gcc.target/powerpc/fold-vec-extract-short.p7.c: Same.
* gcc.target/powerpc/fold-vec-extract-short.p8.c: Same.
* gcc.target/powerpc/sse-andnps-1.c: Restrict to LE.
* gcc.target/powerpc/sse-movhps-1.c: Restrict to LE.
* gcc.target/powerpc/sse-movlps-1.c: Restrict to LE.
* gcc.target/powerpc/sse2-andnpd-1.c: Restrict to LE.

3 years agoFix ChangeLog entries.
Jerry DeLisle [Mon, 18 Jan 2021 02:27:02 +0000 (18:27 -0800)]
Fix ChangeLog entries.

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

3 years agotestsuite: Skip DWARF 5 testcases on AIX.
David Edelsohn [Sun, 17 Jan 2021 23:18:56 +0000 (18:18 -0500)]
testsuite: Skip DWARF 5 testcases on AIX.

AIX does not support DWARF 5.

This patch skips the DWARF 5-specific testcases.

gcc/testsuite/ChangeLog:

* g++.dg/debug/dwarf2/inline-ns-2.C: Skip on AIX.
* g++.dg/debug/dwarf2/inline-var-2.C: Skip on AIX.
* g++.dg/debug/dwarf2/inline-var-3.C: Skip on AIX.
* g++.dg/debug/dwarf2/lang-cpp11.C: Skip on AIX.
* g++.dg/debug/dwarf2/lang-cpp14.C: Skip on AIX.
* g++.dg/debug/dwarf2/lang-cpp17.C: Skip on AIX.
* g++.dg/debug/dwarf2/lang-cpp20.C: Skip on AIX.
* gcc.dg/debug/dwarf2/inline6.c: Skip on AIX.
* gcc.dg/debug/dwarf2/lang-c11.c: Skip on AIX.
* gcc.dg/debug/dwarf2/pr41445-7.c: Skip on AIX.
* gcc.dg/debug/dwarf2/pr41445-8.c: Skip on AIX.

3 years agoaix: default to DWARF 4.
David Edelsohn [Sun, 17 Jan 2021 20:39:46 +0000 (15:39 -0500)]
aix: default to DWARF 4.

GCC now defaults to DWARF 5.  AIX only supports DWARF 4 (3.5).

This patch overrides the default DWARF version to 4 unless explicitly
stated.

gcc/ChangeLog:

* config/rs6000/aix71.h (SUBTARGET_OVERRIDE_OPTIONS): Override
dwarf_version to 4.
* config/rs6000/aix72.h (SUBTARGET_OVERRIDE_OPTIONS): Same.

3 years agoAvoid assuming SSA_NAME_IDENTIFIER is nonnull.
Martin Sebor [Sun, 17 Jan 2021 22:27:08 +0000 (15:27 -0700)]
Avoid assuming SSA_NAME_IDENTIFIER is nonnull.

gcc/c-family/ChangeLog:

* c-pretty-print.c (c_pretty_printer::primary_expression): Don't
assume SSA_NAME_IDENTIFIER evaluates to nonzero.

3 years agoipa: Adjust cgraph verifier to materialization on demand (PR 98222)
Martin Jambor [Sun, 17 Jan 2021 21:31:09 +0000 (22:31 +0100)]
ipa: Adjust cgraph verifier to materialization on demand (PR 98222)

after switching to materialization of clones on demand, the verifier
can happen to see edges leading to a clone of a materialized clone.
This means its clone_of is NULL and former_clone_of needs to be
checked in order to verify that the callee is a clone of the original
decl, which it did not do and reported edges to pointing to a wrong
place.

Fixed with the following patch, which has been pre-approved by Honza.
Bootstrapped and tested on x86_64-linux, pushed to master.

Martin

gcc/ChangeLog:

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

PR ipa/98222
* cgraph.c (clone_of_p): Check also former_clone_of as we climb
the clone tree.

gcc/testsuite/ChangeLog:

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

PR ipa/98222
* gcc.dg/ipa/pr98222.c: New test.

3 years agoDefault to DWARF5
Mark Wielaard [Tue, 29 Sep 2020 13:52:44 +0000 (15:52 +0200)]
Default to DWARF5

gcc/ChangeLog:

* common.opt (gdwarf-): Init(5).
* doc/invoke.texi (-gdwarf): Document default to 5.

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

3 years agotestsuite: Fix up a testcase to find the right ISO_Fortran_binding.h.
Jakub Jelinek [Sat, 16 Jan 2021 21:52:43 +0000 (22:52 +0100)]
testsuite: Fix up a testcase to find the right ISO_Fortran_binding.h.

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

* gfortran.dg/iso_fortran_binding_uint8_array_driver.c: Include
../../../libgfortran/ISO_Fortran_binding.h rather than
ISO_Fortran_binding.h.

3 years agoopenmp: Add support for the OpenMP 5.0 task detach clause
Kwok Cheung Yeung [Sat, 16 Jan 2021 20:58:13 +0000 (12:58 -0800)]
openmp: Add support for the OpenMP 5.0 task detach clause

2021-01-16  Kwok Cheung Yeung  <kcy@codesourcery.com>

gcc/
* builtin-types.def
(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT): Rename
to...
(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR):
...this.  Add extra argument.
* gimplify.c (omp_default_clause): Ensure that event handle is
firstprivate in a task region.
(gimplify_scan_omp_clauses): Handle OMP_CLAUSE_DETACH.
(gimplify_adjust_omp_clauses): Likewise.
* omp-builtins.def (BUILT_IN_GOMP_TASK): Change function type to
BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR.
* omp-expand.c (expand_task_call): Add GOMP_TASK_FLAG_DETACH to flags
if detach clause specified.  Add detach argument when generating
call to GOMP_task.
* omp-low.c (scan_sharing_clauses): Setup data environment for detach
clause.
(finish_taskreg_scan): Move field for variable containing the event
handle to the front of the struct.
* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_DETACH.  Fix
ordering.
* tree-nested.c (convert_nonlocal_omp_clauses): Handle
OMP_CLAUSE_DETACH clause.
(convert_local_omp_clauses): Handle OMP_CLAUSE_DETACH clause.
* tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_DETACH.
* tree.c (omp_clause_num_ops): Add entry for OMP_CLAUSE_DETACH.
Fix ordering.
(omp_clause_code_name): Add entry for OMP_CLAUSE_DETACH.  Fix
ordering.
(walk_tree_1): Handle OMP_CLAUSE_DETACH.

gcc/c-family/
* c-pragma.h (pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_DETACH.
Redefine PRAGMA_OACC_CLAUSE_DETACH.

gcc/c/
* c-parser.c (c_parser_omp_clause_detach): New.
(c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH clause.
(OMP_TASK_CLAUSE_MASK): Add mask for PRAGMA_OMP_CLAUSE_DETACH.
* c-typeck.c (c_finish_omp_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH
clause.  Prevent use of detach with mergeable and overriding the
data sharing mode of the event handle.

gcc/cp/
* parser.c (cp_parser_omp_clause_detach): New.
(cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH.
(OMP_TASK_CLAUSE_MASK): Add mask for PRAGMA_OMP_CLAUSE_DETACH.
* pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_DETACH clause.
* semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_DETACH clause.
Prevent use of detach with mergeable and overriding the data sharing
mode of the event handle.

gcc/fortran/
* dump-parse-tree.c (show_omp_clauses): Handle detach clause.
* frontend-passes.c (gfc_code_walker): Walk detach expression.
* gfortran.h (struct gfc_omp_clauses): Add detach field.
(gfc_c_intptr_kind): New.
* openmp.c (gfc_free_omp_clauses): Free detach clause.
(gfc_match_omp_detach): New.
(enum omp_mask1): Add OMP_CLAUSE_DETACH.
(enum omp_mask2): Remove OMP_CLAUSE_DETACH.
(gfc_match_omp_clauses): Handle OMP_CLAUSE_DETACH for OpenMP.
(OMP_TASK_CLAUSES): Add OMP_CLAUSE_DETACH.
(resolve_omp_clauses): Prevent use of detach with mergeable and
overriding the data sharing mode of the event handle.
* trans-openmp.c (gfc_trans_omp_clauses): Handle detach clause.
* trans-types.c (gfc_c_intptr_kind): New.
(gfc_init_kinds): Initialize gfc_c_intptr_kind.
* types.def
(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT): Rename
to...
(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR):
...this.  Add extra argument.

gcc/testsuite/
* c-c++-common/gomp/task-detach-1.c: New.
* g++.dg/gomp/task-detach-1.C: New.
* gcc.dg/gomp/task-detach-1.c: New.
* gfortran.dg/gomp/task-detach-1.f90: New.

include/
* gomp-constants.h (GOMP_TASK_FLAG_DETACH): New.

libgomp/
* fortran.c (omp_fulfill_event_): New.
* libgomp.h (struct gomp_task): Add detach and completion_sem fields.
(struct gomp_team): Add task_detach_queue and task_detach_count
fields.
* libgomp.map (OMP_5.0.1): Add omp_fulfill_event and omp_fulfill_event_.
* libgomp_g.h (GOMP_task): Add extra argument.
* omp.h.in (enum omp_event_handle_t): New.
(omp_fulfill_event): New.
* omp_lib.f90.in (omp_event_handle_kind): New.
(omp_fulfill_event): New.
* omp_lib.h.in (omp_event_handle_kind): New.
(omp_fulfill_event): Declare.
* priority_queue.c (priority_tree_find): New.
(priority_list_find): New.
(priority_queue_find): New.
* priority_queue.h (priority_queue_predicate): New.
(priority_queue_find): New.
* task.c (gomp_init_task): Initialize detach field.
(task_fulfilled_p): New.
(GOMP_task): Add detach argument.  Ignore detach argument if
GOMP_TASK_FLAG_DETACH not set in flags.  Initialize completion_sem
field. Copy address of completion_sem into detach argument and
into the start of the data record.  Wait for detach event if task
not deferred.
(gomp_barrier_handle_tasks): Queue tasks with unfulfilled events.
Remove completed tasks and requeue dependent tasks.
(omp_fulfill_event): New.
* team.c (gomp_new_team): Initialize task_detach_queue and
task_detach_count fields.
(free_team): Free task_detach_queue field.
* testsuite/libgomp.c-c++-common/task-detach-1.c: New testcase.
* testsuite/libgomp.c-c++-common/task-detach-2.c: New testcase.
* testsuite/libgomp.c-c++-common/task-detach-3.c: New testcase.
* testsuite/libgomp.c-c++-common/task-detach-4.c: New testcase.
* testsuite/libgomp.c-c++-common/task-detach-5.c: New testcase.
* testsuite/libgomp.c-c++-common/task-detach-6.c: New testcase.
* testsuite/libgomp.fortran/task-detach-1.f90: New testcase.
* testsuite/libgomp.fortran/task-detach-2.f90: New testcase.
* testsuite/libgomp.fortran/task-detach-3.f90: New testcase.
* testsuite/libgomp.fortran/task-detach-4.f90: New testcase.
* testsuite/libgomp.fortran/task-detach-5.f90: New testcase.
* testsuite/libgomp.fortran/task-detach-6.f90: New testcase.

3 years agoRTEMS: Add -mcustom-fpu-cfg=fph2 multilib
Sebastian Huber [Thu, 14 Jan 2021 19:09:49 +0000 (20:09 +0100)]
RTEMS: Add -mcustom-fpu-cfg=fph2 multilib

This multilib supports Nios II configurations with the "Nios II Floating
Point Hardware 2 Component".

gcc/

* config/nios2/t-rtems: Reset all MULTILIB_* variables.  Shorten
multilib directory names.  Use MULTILIB_REQUIRED instead of
MULTILIB_EXCEPTIONS.  Add -mhw-mul -mhw-mulx -mhw-div
-mcustom-fpu-cfg=fph2 multilib.

3 years agonios2: Add -mcustom-fpu-cfg=fph2
Sebastian Huber [Thu, 14 Jan 2021 18:09:36 +0000 (19:09 +0100)]
nios2: Add -mcustom-fpu-cfg=fph2

The new -mcustom-fpu-cfg=fph2 option variant is useful to build a
multilib for the "Nios II Floating Point Hardware 2 Component":

https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/ug/ug_nios2_custom_instruction.pdf

Directly using the corresponding -mcustom-insn=N options for this
floating-point unit leads to a combinatorial explosion in the potential
count of multilibs which may break the build.

gcc/

* config/nios2/nios2.c (NIOS2_FPU_CONFIG_NUM): Adjust value.
(nios2_init_fpu_configs): Provide register values for new
-mcustom-fpu-cfg=fph2 option variant.
* doc/invoke.texi (-mcustom-fpu-cfg=fph2): Document new option
variant.

3 years agonios2: Remove custom instruction warnings
Sebastian Huber [Sat, 16 Jan 2021 08:00:23 +0000 (09:00 +0100)]
nios2: Remove custom instruction warnings

Do not warn if custom instructions are not used due to missing
optimization flags.  This prevents build errors with -Werror which
cannot be disabled via a dedicated warning option.

One reason to remove these warnings is to enable a multilib for the
"Nios II Floating Point Hardware 2 Component".  For example, the
libatomic target library in GCC is built with -Werror and the warnings
removed by this patch resulted in errors like:

cc1: error: switch '-mcustom-fmins' has no effect unless '-ffinite-math-only' is specified [-Werror]
cc1: error: switch '-mcustom-fmaxs' has no effect unless '-ffinite-math-only' is specified [-Werror]
cc1: error: switch '-mcustom-round' has no effect unless '-fno-math-errno' is specified [-Werror]

gcc/

* config/nios2/nios2.c (nios2_custom_check_insns): Remove
custom instruction warnings.

3 years agomatch.pd: Optimize ((cst << x) & 1) [PR96669]
Jakub Jelinek [Sat, 16 Jan 2021 08:21:52 +0000 (09:21 +0100)]
match.pd: Optimize ((cst << x) & 1) [PR96669]

While we had a ((1 << x) & 1) != 0 to x == 0 optimization already,
this patch adds ((cst << x) & 1) optimization too, this time the
second constant must be 1 though, not some power of two, but the first
one can be any constant.  If it is even, the result is false, if it is
odd, the result is x == 0.

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

PR tree-optimization/96669
* match.pd ((CST << x) & 1 -> x == 0): New simplification.

* gcc.dg/tree-ssa/pr96669-1.c: Adjust regexp.
* gcc.dg/tree-ssa/pr96669-2.c: New test.

3 years agocd_dce: Return TODO_update_address_taken from last cd_dce [PR96271]
Jakub Jelinek [Sat, 16 Jan 2021 08:17:38 +0000 (09:17 +0100)]
cd_dce: Return TODO_update_address_taken from last cd_dce [PR96271]

On the following testcase, handle_builtin_memcmp in the strlen pass folds
the memcmp into comparison of two MEM_REFs.  But nothing triggers updating
of addressable vars afterwards, so even when the parameters are no longer
address taken, we force the parameters to stack and back anyway.

This patch causes TODO_update_address_taken to happen right before last forwprop
pass (at the end of last cd_dce), so after strlen1 too.

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

PR tree-optimization/96271
* passes.def: Pass false argument to first two pass_cd_dce
instances and true to last instance.  Add comment that
last instance rewrites no longer addressed locals.
* tree-ssa-dce.c (pass_cd_dce): Add update_address_taken_p member and
initialize it.
(pass_cd_dce::set_pass_param): New method.
(pass_cd_dce::execute): Return TODO_update_address_taken from
last cd_dce instance.

* gcc.target/i386/pr96271.c: New test.

3 years agolibstdc++-v3: Add -fcf-protection=none to -march=i486
H.J. Lu [Sat, 16 Jan 2021 01:27:53 +0000 (17:27 -0800)]
libstdc++-v3: Add -fcf-protection=none to -march=i486

-fcf-protection is automatically enabled in libstdc++ on Linux/x86.
Starting from

commit 77d372abec0fbf2cfe922e3140ee3410248f979e
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Jan 14 05:56:46 2021 -0800

    x86: Error on -fcf-protection with incompatible target

GCC issues an error on -fcf-protection with incompatible target:

... -fcf-protection ... libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/explicit-hle.cc  -m32   -O2 -g0 -fno-exceptions -fno-asynchronous-unwind-tables -march=i486 ...
cc1plus: error: '-fcf-protection' is not compatible with this target
FAIL: 29_atomics/atomic_flag/test_and_set/explicit-hle.cc (test for excess errors)

Add -fcf-protection=none to -march=i486 to compile explicit-hle.cc.

* testsuite/29_atomics/atomic_flag/test_and_set/explicit-hle.cc:
Add -fcf-protection=none to -march=i486.

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

3 years agors6000, vector integer multiply/divide/modulo instructions
Carl Love [Sat, 5 Sep 2020 00:24:22 +0000 (19:24 -0500)]
rs6000, vector integer multiply/divide/modulo instructions

2021-01-15  Carl Love  <cel@us.ibm.com>

gcc/ChangeLog:
* config/rs6000/altivec.h (vec_mulh, vec_div, vec_dive, vec_mod):
New defines.
* config/rs6000/altivec.md (VIlong): Move define to file vsx.md.
* config/rs6000/rs6000-builtin.def (DIVES_V4SI, DIVES_V2DI,
DIVEU_V4SI, DIVEU_V2DI, DIVS_V4SI, DIVS_V2DI, DIVU_V4SI,
DIVU_V2DI, MODS_V2DI, MODS_V4SI, MODU_V2DI, MODU_V4SI,
MULHS_V2DI, MULHS_V4SI, MULHU_V2DI, MULHU_V4SI, MULLD_V2DI):
Add builtin define.
(MULH, DIVE, MOD):  Add new BU_P10_OVERLOAD_2 definitions.
* config/rs6000/rs6000-call.c (VSX_BUILTIN_VEC_DIV,
VSX_BUILTIN_VEC_DIVE, P10_BUILTIN_VEC_MOD, P10_BUILTIN_VEC_MULH):
New overloaded definitions.
(builtin_function_type) [P10V_BUILTIN_DIVEU_V4SI,
P10V_BUILTIN_DIVEU_V2DI, P10V_BUILTIN_DIVU_V4SI,
P10V_BUILTIN_DIVU_V2DI, P10V_BUILTIN_MODU_V2DI,
P10V_BUILTIN_MODU_V4SI, P10V_BUILTIN_MULHU_V2DI,
P10V_BUILTIN_MULHU_V4SI]: Add case
statement for builtins.
* config/rs6000/rs6000.md (bits): Add new attribute sizes V4SI, V2DI.
* config/rs6000/vsx.md (VIlong): Moved from config/rs6000/altivec.md.
(UNSPEC_VDIVES, UNSPEC_VDIVEU): New unspec definitions.
(vsx_mul_v2di): Add if TARGET_POWER10 statement.
(vsx_udiv_v2di): Add if TARGET_POWER10 statement.
(dives_<mode>, diveu_<mode>, div<mode>3, uvdiv<mode>3,
mods_<mode>, modu_<mode>, mulhs_<mode>, mulhu_<mode>, mulv2di3):
Add define_insn, mode is VIlong.
* doc/extend.texi (vec_mulh, vec_mul, vec_div, vec_dive, vec_mod):
Add builtin descriptions.

gcc/testsuite/ChangeLog:
* gcc.target/powerpc/builtins-1-p10-runnable.c: New test file.

3 years agoReset force_source_line in final.c
Eric Botcazou [Fri, 15 Jan 2021 21:50:48 +0000 (22:50 +0100)]
Reset force_source_line in final.c

Unlike the other global variables, it is not reset at the beginning of a
function so can leak into the next one.

gcc/ChangeLog:
* final.c (final_start_function_1): Reset force_source_line.

3 years agofortran: Fixes a bug in ISO_Fortran_binding.c.
Jerry DeLisle [Fri, 15 Jan 2021 21:48:42 +0000 (13:48 -0800)]
fortran: Fixes a bug in ISO_Fortran_binding.c.

libgfortran/ChangeLog:

* runtime/ISO_Fortran_binding.c (CFI_establish): Fixed signed
  char arrays. Signed char or uint8_t arrays would cause
  crashes unless an element size is specified.

gcc/testsuite/ChangeLog:

* gfortran.dg/iso_fortran_binding_uint8_array.f90: New test.
* gfortran.dg/iso_fortran_binding_uint8_array_driver.c: New test.

3 years agoc++: Fix qualified array-type construction [PR 98538]
Nathan Sidwell [Fri, 15 Jan 2021 19:38:43 +0000 (11:38 -0800)]
c++: Fix qualified array-type construction [PR 98538]

This was an assert that was too picky.  The reason I had to alter
array construction was that on stream in, we cannot dynamically determine
a type's dependentness.  Thus on stream out of the 'problematic' types,
we save the dependentness for reconstruction.  Fortunately the paths into
cp_build_qualified_type_real from streamin with arrays do have the array's
dependentess set as needed.

PR c++/98538
gcc/cp/
* tree.c (cp_build_qualified_type_real): Propagate an array's
dependentness to the copy, if known.
gcc/testsuite/
* g++.dg/template/pr98538.C: New.

3 years agopreprocessor: Make quoting : [PR 95253]
Nathan Sidwell [Fri, 15 Jan 2021 19:02:38 +0000 (11:02 -0800)]
preprocessor: Make quoting : [PR 95253]

I missed some testsuite fall out with my patch to fix mkdeps file
mangling.

PR preprocessor/95253
gcc/testsuite/
* g++.dg/modules/dep-1_a.C: Adjust expected output.
* g++.dg/modules/dep-1_b.C: Likewise.
* g++.dg/modules/dep-2.C: Likewise.

3 years agomatch.pd: Generalize the PR64309 simplifications [PR96669]
Jakub Jelinek [Fri, 15 Jan 2021 20:12:14 +0000 (21:12 +0100)]
match.pd: Generalize the PR64309 simplifications [PR96669]

The following patch generalizes the PR64309 simplifications, so that instead
of working only with constants 1 and 1 it works with any two power of two
constants, and works also for right shift (in that case it rules out the
first one being negative, as it is arithmetic shift then).

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

PR tree-optimization/96669
* match.pd (((1 << A) & 1) != 0 -> A == 0,
((1 << A) & 1) == 0 -> A != 0): Generalize for 1s replaced by
possibly different power of two constants and to right shift too.

* gcc.dg/tree-ssa/pr96669-1.c: New test.

3 years agomatch.pd: Optimize (x < 0) ^ (y < 0) to (x ^ y) < 0 etc. [PR96681]
Jakub Jelinek [Fri, 15 Jan 2021 20:10:44 +0000 (21:10 +0100)]
match.pd: Optimize (x < 0) ^ (y < 0) to (x ^ y) < 0 etc. [PR96681]

This patch simplifies comparisons that test the sign bit xored together.
If the comparisons are both < 0 or both >= 0, then we should xor the operands
together and compare the result to < 0, if the comparisons are different,
we should compare to >= 0.

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

PR tree-optimization/96681
* match.pd ((x < 0) ^ (y < 0) to (x ^ y) < 0): New simplification.
((x >= 0) ^ (y >= 0) to (x ^ y) < 0): Likewise.
((x < 0) ^ (y >= 0) to (x ^ y) >= 0): Likewise.
((x >= 0) ^ (y < 0) to (x ^ y) >= 0): Likewise.

* gcc.dg/tree-ssa/pr96681.c: New test.

3 years agodrop -dumpbase-ext from producer string
Alexandre Oliva [Fri, 15 Jan 2021 19:22:54 +0000 (16:22 -0300)]
drop -dumpbase-ext from producer string

The -dumpbase and -dumpdir options are excluded from the producer
string output in debug information, but -dumpbase-ext was not.  This
patch excludes it as well.

for  gcc/ChangeLog

* opts.c (gen_command_line_string): Exclude -dumpbase-ext.

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

This patch does a lot of refactoring of unsafe_copy_elision_p and adds
make_safe_copy_elision that will also try to do the base constructor
rewriting from the last patch.

gcc/cp/ChangeLog:

PR c++/98642
* call.c (unsafe_return_slot_p): Return int.
(init_by_return_slot_p): Split out from...
(unsafe_copy_elision_p): ...here.
(unsafe_copy_elision_p_opt): New name for old meaning.
(build_over_call): Adjust.
(make_safe_copy_elision): New.
* typeck2.c (split_nonconstant_init_1): Elide copy from safe
list-initialization.
* cp-tree.h: Adjust.

gcc/testsuite/ChangeLog:

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

3 years agoc++: Fix copy elision for base initialization
Jason Merrill [Wed, 13 Jan 2021 18:27:53 +0000 (13:27 -0500)]
c++: Fix copy elision for base initialization

While working on PR98642 I noticed that in this testcase we were eliding the
copy, calling the complete default constructor to initialize the B base
subobject, and therefore wrongly initializing the non-existent A subobject
of B.  The test doesn't care whether the copy is elided or not, but checks
that we are actually calling a base constructor for B.

The patch preserves the elision, but changes the initializer to call the
base constructor instead of the complete constructor.

gcc/cp/ChangeLog:

* call.c (base_ctor_for, make_base_init_ok): New.
(build_over_call): Use make_base_init_ok.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/elide4.C: New test.

3 years agoAArch64: Add NEON, SVE and SVE2 RTL patterns for Multiply, FMS and FMA.
Tamar Christina [Fri, 15 Jan 2021 18:50:27 +0000 (18:50 +0000)]
AArch64: Add NEON, SVE and SVE2 RTL patterns for Multiply, FMS and FMA.

This adds implementation for the optabs for complex operations.  With this the
following C code:

  void g (float complex a[restrict N], float complex b[restrict N],
  float complex c[restrict N])
  {
    for (int i=0; i < N; i++)
      c[i] =  a[i] * b[i];
  }

generates

NEON:

g:
        movi    v3.4s, 0
        mov     x3, 0
        .p2align 3,,7
.L2:
        mov     v0.16b, v3.16b
        ldr     q2, [x1, x3]
        ldr     q1, [x0, x3]
        fcmla   v0.4s, v1.4s, v2.4s, #0
        fcmla   v0.4s, v1.4s, v2.4s, #90
        str     q0, [x2, x3]
        add     x3, x3, 16
        cmp     x3, 1600
        bne     .L2
        ret

SVE:

g:
        mov     x3, 0
        mov     x4, 400
        ptrue   p1.b, all
        whilelo p0.s, xzr, x4
        mov     z3.s, #0
        .p2align 3,,7
.L2:
        ld1w    z1.s, p0/z, [x0, x3, lsl 2]
        ld1w    z2.s, p0/z, [x1, x3, lsl 2]
        movprfx z0, z3
        fcmla   z0.s, p1/m, z1.s, z2.s, #0
        fcmla   z0.s, p1/m, z1.s, z2.s, #90
        st1w    z0.s, p0, [x2, x3, lsl 2]
        incw    x3
        whilelo p0.s, x3, x4
        b.any   .L2
        ret

SVE2 (with int instead of float)
g:
        mov     x3, 0
        mov     x4, 400
        mov     z3.b, #0
        whilelo p0.s, xzr, x4
        .p2align 3,,7
.L2:
        ld1w    z1.s, p0/z, [x0, x3, lsl 2]
        ld1w    z2.s, p0/z, [x1, x3, lsl 2]
        movprfx z0, z3
        cmla    z0.s, z1.s, z2.s, #0
        cmla    z0.s, z1.s, z2.s, #90
        st1w    z0.s, p0, [x2, x3, lsl 2]
        incw    x3
        whilelo p0.s, x3, x4
        b.any   .L2
        ret

gcc/ChangeLog:

* config/aarch64/aarch64-simd.md (cml<fcmac1><conj_op><mode>4,
cmul<conj_op><mode>3): New.
* config/aarch64/iterators.md (UNSPEC_FCMUL,
UNSPEC_FCMUL180, UNSPEC_FCMLA_CONJ, UNSPEC_FCMLA180_CONJ,
UNSPEC_CMLA_CONJ, UNSPEC_CMLA180_CONJ, UNSPEC_CMUL, UNSPEC_CMUL180,
FCMLA_OP, FCMUL_OP, conj_op, rotsplit1, rotsplit2, fcmac1, sve_rot1,
sve_rot2, SVE2_INT_CMLA_OP, SVE2_INT_CMUL_OP, SVE2_INT_CADD_OP): New.
(rot): Add UNSPEC_FCMUL, UNSPEC_FCMUL180.
(rot_op): Renamed to conj_op.
* config/aarch64/aarch64-sve.md (cml<fcmac1><conj_op><mode>4,
cmul<conj_op><mode>3): New.
* config/aarch64/aarch64-sve2.md (cml<fcmac1><conj_op><mode>4,
cmul<conj_op><mode>3): New.

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

3 years agogcc.dg/analyzer tests: use __builtin_alloca, not alloca.h
Alexandre Oliva [Fri, 15 Jan 2021 18:36:22 +0000 (15:36 -0300)]
gcc.dg/analyzer tests: use __builtin_alloca, not alloca.h

Use __builtin_alloca.  Some systems don't have alloca.h or alloca.

Co-Authored-By: Olivier Hainque <hainque@adacore.com>
for  gcc/testsuite/ChangeLog

* gcc.dg/analyzer/alloca-leak.c: Drop alloca.h, use builtin.
* gcc.dg/analyzer/data-model-1.c: Likewise.
* gcc.dg/analyzer/malloc-1.c: Likewise.
* gcc.dg/analyzer/malloc-paths-8.c: Likewise.

3 years agotestsuite: Add testcase coverage for already fixed [PR96671]
Jakub Jelinek [Fri, 15 Jan 2021 18:26:01 +0000 (19:26 +0100)]
testsuite: Add testcase coverage for already fixed [PR96671]

The fix for this PR didn't come with any test coverage, I've added
tests that make sure we optimize it no matter what order of the x ^ y ^ z
operands is used.

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

PR tree-optimization/96671
* gcc.dg/tree-ssa/pr96671-1.c: New test.
* gcc.dg/tree-ssa/pr96671-2.c: New test.

3 years agobootstrap: fix failing diagnostic selftest on Windows [PR98696]
David Malcolm [Fri, 15 Jan 2021 18:26:39 +0000 (13:26 -0500)]
bootstrap: fix failing diagnostic selftest on Windows [PR98696]

In one of the selftests in g:f10960558540636800cf5d3d6355969621fbc17e
I didn't consider that paths can contain backslashes, which happens
for the tempfiles on Windows hosts.

gcc/ChangeLog:
PR bootstrap/98696
* diagnostic.c
(selftest::test_print_parseable_fixits_bytes_vs_display_columns):
Escape the tempfile name when constructing the expected output.

3 years agoc-family: Improve MEM_REF printing for diagnostics [PR98597]
Jakub Jelinek [Fri, 15 Jan 2021 18:20:29 +0000 (19:20 +0100)]
c-family: Improve MEM_REF printing for diagnostics [PR98597]

Ok, here is an updated patch which fixes what I found, and implements what
has been discussed on the mailing list and on IRC, i.e. if the types
are compatible as well as alias sets are same, then it prints
what c_fold_indirect_ref_for_warn managed to create, otherwise it uses
that info for printing offsets using offsetof (except when it starts
with ARRAY_REFs, because one can't have offsetof (struct T[2][2], [1][0].x.y)

The uninit-38.c test (which was the only one I believe which had tests on the
exact spelling of MEM_REF printing) contains mainly changes to have space
before * for pointer types (as that is how the C pretty-printers normally
print types, int * rather than int*), plus what might be considered a
regression from what Martin printed, but it is actually a correctness fix.

When the arg is a pointer with type pointer to VLA with char element type
(let's say the pointer is p), which is what happens in several of the
uninit-38.c tests, omitting the (char *) cast is incorrect, as p + 1
is not the 1 byte after p, but pointer to the end of the VLA.
It only happened to work because of the hacks (which I don't like at all
and are dangerous, DECL_ARTIFICIAL var names with dot inside can be pretty
much anything, e.g. a lot of passes construct their helper vars from some
prefix that designates intended use of the var plus numeric suffix), where
the a.1 pointer to VLA is printed as a which if one is lucky happens to be
a variable with VLA type (rather than pointer to it), and for such vars
a + 1 is indeed &a[0] + 1 rather than &a + 1.  But if we want to do this
reliably, we'd need to make sure it comes from VLA (e.g. verify that the
SSA_NAME is defined to __builtin_alloca_with_align and that there exists
a corresponding VAR_DECL with DECL_VALUE_EXPR that has the a.1 variable
in it).

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

PR tree-optimization/98597
* c-pretty-print.c: Include options.h.
(c_fold_indirect_ref_for_warn): New function.
(print_mem_ref): Use it.  If it returns something that has compatible
type and is TBAA compatible with zero offset, print it and return,
otherwise print it using offsetof syntax or array ref syntax.  Fix up
printing if MEM_REFs first operand is ADDR_EXPR, or when the first
argument has pointer to array type.  Print pointers using the standard
formatting.

* gcc.dg/uninit-38.c: Expect a space in between type name and asterisk.
Expect for now a (char *) cast for VLAs.
* gcc.dg/uninit-40.c: New test.

3 years agoopenmp: Change the way of building of reduction array type
Jakub Jelinek [Fri, 15 Jan 2021 18:17:53 +0000 (19:17 +0100)]
openmp: Change the way of building of reduction array type

The PR98597 patch regresses on _Atomic-3.c, as in the C FE building an
array type with qualified elements results in a type incompatible with
when an array type with unqualified elements is qualified afterwards.
This patch adds a workaround for that.

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

* c-typeck.c (c_finish_omp_clauses): For reduction build array with
unqualified element type and then call c_build_qualified_type on the
ARRAY_TYPE.

3 years ago[PATCH] aarch64: Implement vmlsl[_high]* intrinsics using builtins
Kyrylo Tkachov [Fri, 15 Jan 2021 17:55:57 +0000 (17:55 +0000)]
[PATCH] aarch64: Implement vmlsl[_high]* intrinsics using builtins

This patch reimplements some more intrinsics using RTL builtins in the
straightforward way.
Thankfully most of the RTL infrastructure is already in place for it.

gcc/
* config/aarch64/aarch64-simd.md (*aarch64_<su>mlsl_hi<mode>):
Rename to...
(aarch64_<su>mlsl_hi<mode>): ... This.
(aarch64_<su>mlsl_hi<mode>): Define.
(*aarch64_<su>mlsl<mode): Rename to...
(aarch64_<su>mlsl<mode): ... This.
* config/aarch64/aarch64-simd-builtins.def (smlsl, umlsl,
smlsl_hi, umlsl_hi): Define builtins.
* config/aarch64/arm_neon.h (vmlsl_high_s8, vmlsl_high_s16,
vmlsl_high_s32, vmlsl_high_u8, vmlsl_high_u16, vmlsl_high_u32,
vmlsl_s8, vmlsl_s16, vmlsl_s32, vmlsl_u8,
vmlsl_u16, vmlsl_u32): Reimplement with builtins.

3 years agoi386: Use cpp_define_formatted for __SIZEOF_FLOAT80__ definition
Uros Bizjak [Fri, 15 Jan 2021 17:15:26 +0000 (18:15 +0100)]
i386: Use cpp_define_formatted for __SIZEOF_FLOAT80__ definition

2021-01-15  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
* config/i386/i386-c.c (ix86_target_macros):
Use cpp_define_formatted for __SIZEOF_FLOAT80__ definition.

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

3 years agoc++: Fix langspecs with -fsyntax-only [PR98591]
Nathan Sidwell [Fri, 15 Jan 2021 16:48:54 +0000 (08:48 -0800)]
c++: Fix langspecs with -fsyntax-only [PR98591]

-fsyntax-only is handled specially in the driver and causes it to add
 '-o /dev/null' (or a suitable OS-specific variant thereof).  PCH is
 handled in the language driver.  I'd not sufficiently protected the
 -fmodule-only action of adding a dummy assembler from the actions of
 -fsyntax-only, so we ended up with two -o options.

PR c++/98591
gcc/cp/
* lang-specs.h: Fix handling of -fmodule-only with -fsyntax-only.

3 years agoaarch64: Add a minipass for fusing CC insns [PR88836]
Richard Sandiford [Fri, 15 Jan 2021 16:45:42 +0000 (16:45 +0000)]
aarch64: Add a minipass for fusing CC insns [PR88836]

This patch adds a small target-specific pass to remove redundant SVE
PTEST instructions.  There are two important uses of this:

- Removing PTESTs after WHILELOs (PR88836).  The original testcase
  no longer exhibits the problem due to more recent optimisations,
  but it can still be seen in simple cases like the one in the patch.
  It also shows up in 450.soplex.

- Removing PTESTs after RDFFRs in ACLE code.

This is just an interim “solution” for GCC 11.  I hope to replace
it with something generic and target-independent for GCC 12.
However, the use cases above are very important for performance,
so I'd rather not leave the bug unfixed for yet another release cycle.

Since the pass is intended to be short-lived, I've not added
a command-line option for it.  The pass can be disabled using
-fdisable-rtl-cc_fusion if necessary.

Although what the pass does is independent of SVE, it's motivated
only by SVE cases and doesn't trigger for any non-SVE test I've seen.
I've therefore gated it on TARGET_SVE and restricted it to PTEST
patterns.

gcc/
PR target/88836
* config.gcc (aarch64*-*-*): Add aarch64-cc-fusion.o to extra_objs.
* Makefile.in (RTL_SSA_H): New variable.
* config/aarch64/t-aarch64 (aarch64-cc-fusion.o): New rule.
* config/aarch64/aarch64-protos.h (make_pass_cc_fusion): Declare.
* config/aarch64/aarch64-passes.def: Add pass_cc_fusion after
pass_combine.
* config/aarch64/aarch64-cc-fusion.cc: New file.

gcc/testsuite/
PR target/88836
* gcc.target/aarch64/sve/acle/general/ldff1_8.c: New test.
* gcc.target/aarch64/sve/ptest_1.c: Likewise.

3 years agorecog: Fix insn_change_watermark destructor
Richard Sandiford [Fri, 15 Jan 2021 16:45:41 +0000 (16:45 +0000)]
recog: Fix insn_change_watermark destructor

Noticed while working on something else that the insn_change_watermark
destructor could call cancel_changes for changes that no longer exist.
The loop in cancel_changes is a nop in that case, but:

  num_changes = num;

can mess things up.

I think this would only affect nested uses of insn_change_watermark.

gcc/
* recog.h (insn_change_watermark::~insn_change_watermark): Avoid
calling cancel_changes for changes that no longer exist.

3 years agortl-ssa: Fix a silly typo
Richard Sandiford [Fri, 15 Jan 2021 16:45:40 +0000 (16:45 +0000)]
rtl-ssa: Fix a silly typo

s/ref/reg/ on a previously unused function name.

gcc/
* rtl-ssa/functions.h (function_info::ref_defs): Rename to...
(function_info::reg_defs): ...this.
* rtl-ssa/member-fns.inl (function_info::ref_defs): Rename to...
(function_info::reg_defs): ...this.

3 years agoIBM Z: Fix linking to libatomic in target test cases
Marius Hillenbrand [Fri, 15 Jan 2021 13:07:44 +0000 (14:07 +0100)]
IBM Z: Fix linking to libatomic in target test cases

One of the test cases failed to link because of missing paths to
libatomic. Reuse procedures in lib/atomic-dg.exp to gather these paths.

gcc/testsuite/ChangeLog:

2021-01-15  Marius Hillenbrand  <mhillen@linux.ibm.com>

* gcc.target/s390/s390.exp: Call lib atomic-dg.exp to link
libatomic into testcases in gcc.target/s390/md.
* gcc.target/s390/md/atomic_exchange-1.c: Remove no unnecessary
-latomic.

3 years agoarm: Implement vceqq_p64, vceqz_p64 and vceqzq_p64 intrinsics
Christophe Lyon [Thu, 15 Oct 2020 17:13:59 +0000 (17:13 +0000)]
arm: Implement vceqq_p64, vceqz_p64 and vceqzq_p64 intrinsics

This patch adds implementations for vceqq_p64, vceqz_p64 and
vceqzq_p64 intrinsics.

vceqq_p64 uses the existing vceq_p64 after splitting the input vectors
into their high and low halves.

vceqz[q] simply call the vceq and vceqq with a second argument equal
to zero.

The added (executable) testcases make sure that the poly64x2_t
variants have results with one element of all zeroes (false) and the
other element with all bits set to one (true).

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

gcc/
PR target/71233
* config/arm/arm_neon.h (vceqz_p64, vceqq_p64, vceqzq_p64): New.

gcc/testsuite/
PR target/71233
* gcc.target/aarch64/advsimd-intrinsics/p64_p128.c: Add tests for
vceqz_p64, vceqq_p64 and vceqzq_p64.
* gcc.target/arm/simd/vceqz_p64.c: New test.
* gcc.target/arm/simd/vceqzq_p64.c: New test.

3 years agoRevert "arm: Implement vceqq_p64, vceqz_p64 and vceqzq_p64 intrinsics"
Christophe Lyon [Fri, 15 Jan 2021 14:09:32 +0000 (14:09 +0000)]
Revert "arm: Implement vceqq_p64, vceqz_p64 and vceqzq_p64 intrinsics"

This reverts commit 1a6306420090409cb397e2e042256eb1905f415f.

3 years agotree-optimization/96376 - do not check alignment for invariant loads
Richard Biener [Fri, 15 Jan 2021 13:20:43 +0000 (14:20 +0100)]
tree-optimization/96376 - do not check alignment for invariant loads

The testcases show that we fail to disregard alignment for invariant
loads.  The patch handles them like we handle gather and scatter.

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

PR tree-optimization/96376
* tree-vect-stmts.c (get_load_store_type): Disregard alignment
for VMAT_INVARIANT.

3 years agoPytest in tests: improve
Martin Liska [Thu, 14 Jan 2021 08:09:32 +0000 (09:09 +0100)]
Pytest in tests: improve

gcc/ChangeLog:

* doc/install.texi: Document that some tests need pytest module.
* doc/sourcebuild.texi: Likewise.

gcc/testsuite/ChangeLog:

* lib/gcov.exp: Use 'env python3' for execution of pytests.
Check that pytest accepts all needed options first.
Improve formatting of PASS/FAIL lines.

3 years agotestsuite/96147 - align vector access
Richard Biener [Fri, 15 Jan 2021 13:03:37 +0000 (14:03 +0100)]
testsuite/96147 - align vector access

This aligns p so that the testcase is meaningful for targets
without a hw misaligned access.

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

PR testsuite/96147
* gcc.dg/vect/bb-slp-32.c: Align p.

3 years agotestsuite/96147 - scan for vectorized load
Richard Biener [Fri, 15 Jan 2021 13:02:06 +0000 (14:02 +0100)]
testsuite/96147 - scan for vectorized load

This changes gcc.dg/vect/bb-slp-9.c to scan for a vectorized load
instead of a vectorized BB which then correctly captures the
unaligned load we try to test and not some intermediate built
from scalar vector.

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

PR testsuite/96147
* gcc.dg/vect/bb-slp-9.c: Scan for a vector load transform.

3 years agotestsuite/96147 - key scanning on vect_hw_misalign
Richard Biener [Fri, 15 Jan 2021 12:52:12 +0000 (13:52 +0100)]
testsuite/96147 - key scanning on vect_hw_misalign

gcc.dg/vect/slp-45.c failed to key the vectorization capability
scanning on vect_hw_misalign.  Since the stores are strided
they cannot be (all) analyzed to be aligned.

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

PR testsuite/96147
* gcc.dg/vect/slp-45.c: Key scanning on
vect_hw_misalign.