platform/upstream/gcc.git
3 years agotestsuite: Fix up strlenopt-73.c on powerpc [PR99626]
Jakub Jelinek [Thu, 18 Mar 2021 15:11:46 +0000 (16:11 +0100)]
testsuite: Fix up strlenopt-73.c on powerpc [PR99626]

As mentioned in the testcase as well as in the PR, this testcase relies on
MOVE_MAX being sufficiently large that the memcpy call is folded early into
load + store.  Some popular targets define MOVE_MAX to 8 or even 16 (e.g.
x86_64 or some options on s390x), but many other targets define it to just 4
(e.g. powerpc 32-bit), or even 2.

The testcase has already one test routine guarded on one particular target
with MOVE_MAX 16 (but does it incorrectly, __i386__ is only defined on
32-bit x86 and __SIZEOF_INT128__ is only defined on 64-bit targets), this
patch fixes that, and guards another test that relies on memcpy (, , 8)
being folded that way (which therefore needs MOVE_MAX >= 8) on a couple of
common targets that are known to have such MOVE_MAX.

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

PR testsuite/99626
* gcc.dg/strlenopt-73.c: Ifdef out test_copy_cond_unequal_length_i64
on targets other than x86, aarch64, s390 and 64-bit powerpc.  Use
test_copy_cond_unequal_length_i128 for __x86_64__ with int128 support
rather than __i386__.

3 years agoUpdate email address for primary entry
Jeff Law [Thu, 18 Mar 2021 14:33:20 +0000 (08:33 -0600)]
Update email address for primary entry

/
* MAINTAINERS: Update primary entry.

3 years agotestsuite: Skip c-c++-common/zero-scratch-regs-10.c on arm
Christophe Lyon [Thu, 18 Mar 2021 09:58:52 +0000 (09:58 +0000)]
testsuite: Skip c-c++-common/zero-scratch-regs-10.c on arm

As discussed in PR 97680, -fzero-call-used-regs is not supported on
arm.

Skip this test to avoid failure reports.

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

gcc/testsuite/
PR testsuite/97680
* c-c++-common/zero-scratch-regs-10.c: Skip on arm

3 years agoFix building the V850 port using recent versions of gcc.
Nick Clifton [Thu, 18 Mar 2021 12:57:25 +0000 (12:57 +0000)]
Fix building the V850 port using recent versions of gcc.

gcc/
* config/v850/v850.c (construct_restore_jr): Increase static
 buffer size.
(construct_save_jarl): Likewise.
* config/v850/v850.h (DWARF2_DEBUGGING_INFO): Define.

3 years agoObjective-C++ : Fix handling of unnamed message parms [PR49070].
Iain Sandoe [Fri, 26 Feb 2021 10:21:02 +0000 (10:21 +0000)]
Objective-C++ : Fix handling of unnamed message parms [PR49070].

When we are parsing an Objective-C++ message, a colon is a valid
terminator for a assignment-expression.  That is:

[receiver meth:x:x:x:x];

Is a valid, if somewhat unreadable, construction; corresponding
to a method declaration like:

- (id) meth:(id)arg0 :(id)arg1 :(id)arg2 :(id)arg3;

Where three of the message params have no selector name.

If fact, although it might be unintentional, Objective-C/C++ can
accept message selectors with all the parms unnamed (this applies
to the clang implementation too, which is taken as the reference
for the language).

For regular C++, the pattern x:x is not valid in that position an
an error is emitted with a fixit for the expected scope token.

If we simply made that error conditional on !c_dialect_objc()
that would regress Objective-C++ diagnostics for cases outside a
message selector, so we add a state flag for this.

gcc/cp/ChangeLog:

PR objc++/49070
* parser.c (cp_debug_parser): Add Objective-C++ message
state flag.
(cp_parser_nested_name_specifier_opt): Allow colon to
terminate an assignment-expression when parsing Objective-
C++ messages.
(cp_parser_objc_message_expression): Set and clear message
parsing state on entry and exit.
* parser.h (struct cp_parser): Add a context flag for
Objective-C++ message state.

gcc/testsuite/ChangeLog:

PR objc++/49070
* obj-c++.dg/pr49070.mm: New test.
* objc.dg/unnamed-parms.m: New test.

3 years agoaarch64: Improve generic SVE tuning defaults
Kyrylo Tkachov [Thu, 18 Mar 2021 08:57:01 +0000 (08:57 +0000)]
aarch64: Improve generic SVE tuning defaults

This patch adds the recently-added tweak to split some SVE VL-based scalar
operations [1] to the generic tuning used for SVE, as enabled by adding +sve
to the -march flag, for example -march=armv8.2-a+sve.

The recommendation for best performance on a particular CPU remains unchanged:
use the -mcpu option for that CPU, where possible. -mcpu=native makes this
straightforward for native compilation.

The tweak to split out SVE VL-based scalar operations is a consistent win for
the Neoverse V1 CPU and should be neutral for the Fujitsu A64FX. A run of
SPEC2017 on A64FX with this tweak on didn't show any non-noise differences.
It is also expected to be neutral on SVE2 implementations.

Therefore, the patch enables the tweak for generic +sve tuning e.g.
-march=armv8.2-a+sve. No SVE2 CPUs are expected to benefit from it,
therefore the tweak is disabled for generic tuning when +sve2 is in
-march e.g. -march=armv8.2-a+sve2.

The implementation of this approach requires a bit of custom logic in
aarch64_override_options_internal to handle these kinds of
architecture-dependent decisions, but we do believe the user-facing principle
here is important to implement.

In general, for the generic target we're using a decision framework that looks
like:

* If all cores that are known to benefit from an optimization
are of architecture X, and all other cores that implement X or above
are not impacted, or have a very slight impact, we will consider it for
generic tuning for architecture X.
* We will not enable that optimisation for generic tuning for architecture X+1
if no known cores of architecture X+1 or above will benefit.

This framework allows us to improve generic tuning for CPUs of generation X
while avoiding accumulating tweaks for future CPUs of generation X+1, X+2...
that do not need them, and thus avoid even the slight negative effects of
these optimisations if the user is willing to tell us the desired architecture
accurately.

X above can mean either annual architecture updates (Armv8.2-a, Armv8.3-a etc)
or optional architecture extensions (like SVE, SVE2).

[1] http://gcc.gnu.org/g:a65b9ad863c5fc0aea12db58557f4d286a1974d7

gcc/ChangeLog:

* config/aarch64/aarch64.c (aarch64_adjust_generic_arch_tuning): Define.
(aarch64_override_options_internal): Use it.
(generic_tunings): Add AARCH64_EXTRA_TUNE_CSE_SVE_VL_CONSTANTS to
tune_flags.

gcc/testsuite/ChangeLog:

* g++.target/aarch64/sve/aarch64-sve.exp: Add -moverride=tune=none to
sve_flags.
* g++.target/aarch64/sve/acle/aarch64-sve-acle-asm.exp: Likewise.
* g++.target/aarch64/sve/acle/aarch64-sve-acle.exp: Likewise.
* gcc.target/aarch64/sve/aarch64-sve.exp: Likewise.
* gcc.target/aarch64/sve/acle/aarch64-sve-acle-asm.exp: Likewise.
* gcc.target/aarch64/sve/acle/aarch64-sve-acle.exp: Likewise.

3 years agocoroutines: init struct members to NULL
Martin Liska [Tue, 16 Mar 2021 12:26:09 +0000 (13:26 +0100)]
coroutines: init struct members to NULL

gcc/cp/ChangeLog:

PR c++/99617
* coroutines.cc (struct var_nest_node): Init then_cl and else_cl
to NULL.

3 years agotestsuite: Fix up pr98099.c testcase for big endian [PR98099]
Jakub Jelinek [Thu, 18 Mar 2021 08:53:24 +0000 (09:53 +0100)]
testsuite: Fix up pr98099.c testcase for big endian [PR98099]

The testcase fails on big-endian without int128 support, because
due to -fsso-struct=big-endian no swapping is needed for big endian.
This patch restricts the testcase to big or little endian (but not pdp)
and uses -fsso-struct=little-endian for big endian, so that it is
swapping everywhere.

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

PR middle-end/98099
* gcc.dg/pr98099.c: Don't compile the test on pdp endian.
For big endian use -fsso-struct=little-endian dg-options.

3 years agoDaily bump.
GCC Administrator [Thu, 18 Mar 2021 00:16:24 +0000 (00:16 +0000)]
Daily bump.

3 years agoc++: ICE with real-to-int conversion in template [PR97973]
Marek Polacek [Wed, 3 Mar 2021 23:37:49 +0000 (18:37 -0500)]
c++: ICE with real-to-int conversion in template [PR97973]

In this test we are building a call in a template, but since neither
the function nor any of its arguments are dependent, we go down the
normal path in finish_call_expr.  convert_arguments sees that we're
binding a reference to int to double and therein convert_to_integer
creates a FIX_TRUNC_EXPR.  Later, we call check_function_arguments
which folds the arguments, and, in a template, fold_for_warn calls
fold_non_dependent_expr.  But tsubst_copy_and_build should not see
a FIX_TRUNC_EXPR (see the patch discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2018-March/496183.html>)
or we crash.

So let's not create a FIX_TRUNC_EXPR in a template in the first place
and instead use IMPLICIT_CONV_EXPR.

gcc/cp/ChangeLog:

PR c++/97973
* call.c (conv_unsafe_in_template_p): New.
(convert_like): Use it.

gcc/testsuite/ChangeLog:

PR c++/97973
* g++.dg/conversion/real-to-int1.C: New test.

3 years agoc++: Private parent access check for using decls [PR19377]
Anthony Sharp [Wed, 10 Mar 2021 20:36:03 +0000 (20:36 +0000)]
c++: Private parent access check for using decls [PR19377]

This bug was already mostly fixed by the patch for PR17314. This
patch continues that by ensuring that where a using decl is used,
causing an access failure to a child class because the using decl is
private, the compiler correctly points to the using decl as the
source of the problem.

gcc/cp/ChangeLog:

2021-03-10  Anthony Sharp  <anthonysharp15@gmail.com>

* semantics.c (get_class_access_diagnostic_decl): New
function that examines special cases when a parent
class causes a private access failure.
(enforce_access): Slightly modified to call function
above.

gcc/testsuite/ChangeLog:

2021-03-10  Anthony Sharp  <anthonysharp15@gmail.com>

* g++.dg/cpp1z/using9.C: New using decl test.

Co-authored-by: Jason Merrill <jason@redhat.com>
3 years agonios2: Fix format complaints and similar diagnostics.
Sandra Loosemore [Wed, 17 Mar 2021 21:37:05 +0000 (14:37 -0700)]
nios2: Fix format complaints and similar diagnostics.

The nios2 back end has not been building with newer versions of host
GCC due to several complaints about diagnostic formatting, along with
a couple other warnings.  This patch fixes the errors seen when
building with a host compiler from current mainline head.  I also made
a pass through all the error messages in this file to make them use
more consistent formatting, even where the host compiler was not
specifically complaining.

gcc/
* config/nios2/nios2.c (nios2_custom_check_insns): Clean up
error message format issues.
(nios2_option_override): Likewise.
(nios2_expand_fpu_builtin): Likewise.
(nios2_init_custom_builtins): Adjust to avoid bogus strncpy
truncation warning.
(nios2_expand_custom_builtin): More error message format fixes.
(nios2_expand_rdwrctl_builtin): Likewise.
(nios2_expand_rdprs_builtin): Likewise.
(nios2_expand_eni_builtin): Likewise.
(nios2_expand_builtin): Likewise.
(nios2_register_custom_code): Likewise.
(nios2_valid_target_attribute_rec): Likewise.
(nios2_add_insn_asm): Fix uninitialized variable warning.

3 years agoEnable gather on zen3 hardware.
Jan Hubicka [Wed, 17 Mar 2021 21:37:11 +0000 (22:37 +0100)]
Enable gather on zen3 hardware.

For TSVC it get used by 5 benchmarks with following runtime improvements:

s4114: 1.424 -> 1.209  (84.9017%)
s4115: 2.021 -> 1.065  (52.6967%)
s4116: 1.549 -> 0.854  (55.1323%)
s4117: 1.386 -> 1.193  (86.075%)
vag: 2.741 -> 1.940  (70.7771%)

there is regression in

s4112: 1.115 -> 1.184  (106.188%)

The internal loop is:

        for (int i = 0; i < LEN_1D; i++) {
            a[i] += b[ip[i]] * s;
        }

(so a standard accmulate and add with indirect addressing)

  40a400:       c5 fe 6f 24 03          vmovdqu (%rbx,%rax,1),%ymm4
  40a405:       c5 fc 28 da             vmovaps %ymm2,%ymm3
  40a409:       48 83 c0 20             add    $0x20,%rax
  40a40d:       c4 e2 65 92 04 a5 00    vgatherdps %ymm3,0x594100(,%ymm4,4),%ymm0
  40a414:       41 59 00
  40a417:       c4 e2 75 a8 80 e0 34    vfmadd213ps 0x5b34e0(%rax),%ymm1,%ymm0
  40a41e:       5b 00
  40a420:       c5 fc 29 80 e0 34 5b    vmovaps %ymm0,0x5b34e0(%rax)
  40a427:       00
  40a428:       48 3d 00 f4 01 00       cmp    $0x1f400,%rax
  40a42e:       75 d0                   jne    40a400 <s4112+0x60>

compared to:

  40a280:       49 63 14 04             movslq (%r12,%rax,1),%rdx
  40a284:       48 83 c0 04             add    $0x4,%rax
  40a288:       c5 fa 10 04 95 00 41    vmovss 0x594100(,%rdx,4),%xmm0
  40a28f:       59 00
  40a291:       c4 e2 71 a9 80 fc 34    vfmadd213ss 0x5b34fc(%rax),%xmm1,%xmm0
  40a298:       5b 00
  40a29a:       c5 fa 11 80 fc 34 5b    vmovss %xmm0,0x5b34fc(%rax)
  40a2a1:       00
  40a2a2:       48 3d 00 f4 01 00       cmp    $0x1f400,%rax
  40a2a8:       75 d6                   jne    40a280 <s4112+0x40>

Looking at instructions latencies

 - fmadd is 4 cycles
 - vgatherdps is 39

So vgather iself is 4.8 cycle per iteration and probably CPU is able to execute
rest out of order getting clos to 4 cycles per iteration (it can do 2 loads in
parallel, one store and rest fits easily to execution resources). That would
explain 20% slowdown.

gimple internal loop is:
  _2 = a[i_38];
  _3 = (long unsigned int) i_38;
  _4 = _3 * 4;
  _5 = ip_18 + _4;
  _6 = *_5;
  _7 = b[_6];
  _8 = _7 * s_19;
  _9 = _2 + _8;
  a[i_38] = _9;
  i_28 = i_38 + 1;
  ivtmp_52 = ivtmp_53 - 1;
  if (ivtmp_52 != 0)
    goto <bb 8>; [98.99%]
  else
    goto <bb 4>; [1.01%]

0x25bac30 a[i_38] 1 times scalar_load costs 12 in body
0x25bac30 *_5 1 times scalar_load costs 12 in body
0x25bac30 b[_6] 1 times scalar_load costs 12 in body
0x25bac30 _7 * s_19 1 times scalar_stmt costs 12 in body
0x25bac30 _2 + _8 1 times scalar_stmt costs 12 in body
0x25bac30 _9 1 times scalar_store costs 16 in body

so 19 cycles estimate of scalar load

0x2668630 a[i_38] 1 times vector_load costs 12 in body
0x2668630 *_5 1 times unaligned_load (misalign -1) costs 12 in body
0x2668630 b[_6] 8 times scalar_load costs 96 in body
0x2668630 _7 * s_19 1 times scalar_to_vec costs 4 in prologue
0x2668630 _7 * s_19 1 times vector_stmt costs 12 in body
0x2668630 _2 + _8 1 times vector_stmt costs 12 in body
0x2668630 _9 1 times vector_store costs 16 in body

so 40 cycles per 8x vectorized body

tsvc.c:3450:27: note:  operating only on full vectors.
tsvc.c:3450:27: note:  Cost model analysis:
  Vector inside of loop cost: 160
  Vector prologue cost: 4
  Vector epilogue cost: 0
  Scalar iteration cost: 76
  Scalar outside cost: 0
  Vector outside cost: 4
  prologue iterations: 0
  epilogue iterations: 0
  Calculated minimum iters for profitability: 1

I think this generally suffers from GIGO principle.
One problem seems to be that we do not know about fmadd yet and compute it as
two instructions (6 cycles instead of 4). More importnat problem is that we do
not account the parallelism at all.  I do not see how to disable the
vecotrization here without bumping gather costs noticeably off reality and thus
we probably can try to experiment with this if more similar problems are found.

Icc is also using gather in s1115 and s128.
For s1115 the vectorization does not seem to help and s128 gets slower.

Clang and aocc does not use gathers.

* config/i386/x86-tune-costs.h (struct processor_costs): Update costs
of gather to match reality.
* config/i386/x86-tune.def (X86_TUNE_USE_GATHER): Enable for znver3.

3 years agocompiler: copy receiver argument for go/defer of method call
Ian Lance Taylor [Wed, 17 Mar 2021 05:34:20 +0000 (22:34 -0700)]
compiler: copy receiver argument for go/defer of method call

Test case is https://golang.org/cl/302371.

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

3 years agotestsuite, Darwin : Fix the asan/strncpy-overflow-1 test.
Iain Sandoe [Wed, 17 Mar 2021 13:05:47 +0000 (13:05 +0000)]
testsuite, Darwin : Fix the asan/strncpy-overflow-1 test.

1. To be more compatible with Linux, Darwin testcases that include
string.h should set _FORTIFY_SOURCE=0 since, otherwise, it will be
defaulted on and the _chk versions of the string builtins will be
used.  This testcase fails otherwise because there's no convenient
way to disable the _chk builtins.

2. The system tool that handles symbolization (atos) is not reliable
with GCC's DWARF-2 output but, fortunately, all the platform
versions that support the current sanitizers are able to handle
dwarf-3 for this testcase.

gcc/testsuite/ChangeLog:

* c-c++-common/asan/strncpy-overflow-1.c: Add _FORTIFY_SOURCE=0 and
-gdwarf-3 to the command line options. Adjust the expected line
numbers for the revised options header.

3 years agotestsuite, Darwin : Fix match output for asan/memcmp-1.c.
Iain Sandoe [Wed, 17 Mar 2021 12:56:49 +0000 (12:56 +0000)]
testsuite, Darwin : Fix match output for asan/memcmp-1.c.

The Darwin part of libasan produces different output for memcmp
cases from other ports.  The GCC implementation does produce the
same output for this test as the clang one (modulo the two points
below).

1. To be more compatible with Linux, Darwin testcases that include
string.h should set _FORTIFY_SOURCE=0 since, otherwise, it will be
defaulted on and the _chk versions of the string builtins will be
used.

2. The system tool that handles symbolization (atos) is not reliable
with GCC's DWARF-2 output but, fortunately, all the platform
versions that support the current sanitizers are able to handle
dwarf-3 for this testcase.

gcc/testsuite/ChangeLog:

* c-c++-common/asan/memcmp-1.c: Add _FORTIFY_SOURCE=0 and
-gdwarf-3 to the command line options.  Provide Darwin-
specific match lines for the expected output.

3 years agoaarch64: Fix status return logic in RNG intrinsics
Kyrylo Tkachov [Wed, 17 Mar 2021 18:21:05 +0000 (18:21 +0000)]
aarch64: Fix status return logic in RNG intrinsics

There is a bug with the RNG intrinsics in their return code. The definition says:

"Stores a 64-bit random number into the object pointed to by the argument and returns zero.
If the implementation could not generate a random number within a reasonable period of time
the object pointed to by the input is set to zero and a non-zero value is returned."

This means we should be testing whether to return non-zero with:
CSET W0, EQ
rather than NE.

This patch fixes that.

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.c (aarch64_expand_rng_builtin): Use EQ
to compare against CC_REG rather than NE.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/acle/rng_2.c: New test.

3 years agox86: Update 'P' operand modifier for -fno-plt
H.J. Lu [Thu, 11 Mar 2021 14:48:24 +0000 (06:48 -0800)]
x86: Update 'P' operand modifier for -fno-plt

Update 'P' operand modifier for -fno-plt to support inline assembly
statements.  In 64-bit, we can always load function address with
@GOTPCREL.  In 32-bit, we load function address with @GOT only for
non-PIC since PIC register may not be available at call site.

gcc/

PR target/99504
* config/i386/i386.c (ix86_force_load_from_GOT_p): Support
inline assembly statements.
(ix86_print_operand): Update 'P' handling for -fno-plt.

gcc/testsuite/

PR target/99504
* gcc.target/i386/pr99530-1.c: New test.
* gcc.target/i386/pr99530-2.c: Likewise.
* gcc.target/i386/pr99530-3.c: Likewise.
* gcc.target/i386/pr99530-4.c: Likewise.
* gcc.target/i386/pr99530-5.c: Likewise.
* gcc.target/i386/pr99530-6.c: Likewise.

3 years agoAArch64: Fix -Werror issue in aarch64_simd_clone_compute_vecsize_and_simdlen
Tamar Christina [Wed, 17 Mar 2021 11:12:25 +0000 (11:12 +0000)]
AArch64: Fix -Werror issue in aarch64_simd_clone_compute_vecsize_and_simdlen

g:fcefc59befd396267b824c170b6a37acaf10874e introduced a new variable named
arg_type which shadows the function scoped one.

The function scoped one is now unused and so causes bootstrap to fail due to
-Werror.

This patch removes the unused variable.

gcc/ChangeLog:

PR target/99542
* config/aarch64/aarch64.c
(aarch64_simd_clone_compute_vecsize_and_simdlen): Remove unused var.

3 years agoDaily bump.
GCC Administrator [Wed, 17 Mar 2021 00:16:25 +0000 (00:16 +0000)]
Daily bump.

3 years agoaarch64: Fix up aarch64_simd_clone_compute_vecsize_and_simdlen [PR99542]
Christophe Lyon [Tue, 16 Mar 2021 21:48:10 +0000 (21:48 +0000)]
aarch64: Fix up aarch64_simd_clone_compute_vecsize_and_simdlen [PR99542]

The gcc.dg/declare-simd.c test does not emit a warning with
-mabi=ilp32.

2021-03-16  Christophe Lyon  <christophe.lyon@linaro.org>

PR target/99542
gcc/testsuite/
* gcc.dg/declare-simd.c (fn2): Expect a warning only under lp64.

3 years agoc++: Fix NaN as C++20 template argument
Jason Merrill [Tue, 16 Mar 2021 20:06:27 +0000 (16:06 -0400)]
c++: Fix NaN as C++20 template argument

C++20 allows floating-point types for non-type template parameters;
floating-point values are considered to be equivalent template arguments if
they are "identical", which conveniently seems to map onto an existing GCC
predicate.

gcc/cp/ChangeLog:

* tree.c (cp_tree_equal): Use real_identical.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-float1.C: New test.

3 years agoc++: Ensure correct destruction order of local statics [PR99613]
Jakub Jelinek [Tue, 16 Mar 2021 20:17:44 +0000 (21:17 +0100)]
c++: Ensure correct destruction order of local statics [PR99613]

As mentioned in the PR, if end of two constructions of local statics
is strongly ordered, their destructors should be run in the reverse order.
As we run __cxa_guard_release before calling __cxa_atexit, it is possible
that we have two threads that access two local statics in the same order
for the first time, one thread wins the __cxa_guard_acquire on the first
one but is rescheduled in between the __cxa_guard_release and __cxa_atexit
calls, then the other thread is scheduled and wins __cxa_guard_acquire
on the second one and calls __cxa_quard_release and __cxa_atexit and only
afterwards the first thread calls its __cxa_atexit.  This means a variable
whose completion of the constructor strongly happened after the completion
of the other one will be destructed after the other variable is destructed.

The following patch fixes that by swapping the __cxa_guard_release and
__cxa_atexit calls.

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

PR c++/99613
* decl.c (expand_static_init): For thread guards, call __cxa_atexit
before calling __cxa_guard_release rather than after it.  Formatting
fixes.

3 years agors6000: Workaround for PR98092
Segher Boessenkool [Tue, 16 Mar 2021 18:29:11 +0000 (18:29 +0000)]
rs6000: Workaround for PR98092

The bcdinvalid_<mode> RTL instruction uses the "unordered" comparison,
which cannot be used if we have -ffinite-math-only.  We really need
CCMODEs that describe what bits in a CR field are set by other insns
than just comparisons, but that is a lot more surgery, and it is stage 4
now.  This patch does a simple workaround.

2021-03-16  Segher Boessenkool  <segher@kernel.crashing.org>

PR target/98092
* config/rs6000/predicates.md (branch_comparison_operator): Allow
ordered and unordered for CCFPmode, if flag_finite_math_only.

gcc/testsuite/
PR target/98092
* gcc.target/powerpc/pr98092.c: New.

3 years agoi386: Avoid mutual recursion between two peephole2s [PR99600]
Jakub Jelinek [Tue, 16 Mar 2021 17:46:20 +0000 (18:46 +0100)]
i386: Avoid mutual recursion between two peephole2s [PR99600]

As the testcase shows, the compiler hangs and eats all memory when compiling
it.  This is because in r11-7274-gdecd8fb0128870d0d768ba53dae626913d6d9c54
I have changed the ix86_avoid_lea_for_addr splitting from a splitter
into a peephole2 (because during splitting passes we don't have guaranteed
df, while during peephole2 we do).
The problem is we have another peephole2 that works in the opposite way,
when seeing split lea (in particular ASHIFT followed by PLUS) it attempts
to turn it back into a lea.
In the past, they were fighting against each other, but as they were in
different passes, simply the last one won.  So, split after reload
split the lea into shift left and plus, peephole2 reverted that (but, note
not perfectly, the peephole2 doesn't understand that something can be placed
into lea disp; to be fixed for GCC12) and then another split pass split the
lea appart again.
But my changes and the way peephole2 works means that we endlessly iterate
over those two, the first peephole2 splits the lea, the second one reverts
it, the first peephole2 splits the new lea back into new 2 insns and so
forth forever.
So, we need to break the cycle somehow.  This patch does that by not emitting
an ASHIFT insn from ix86_split_lea_for_addr but emitting a corresponding
MULT by constant instead, and splitting that later back into ASHIFT.

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

PR target/99600
* config/i386/i386-expand.c (ix86_split_lea_for_addr): Emit a MULT
rather than ASHIFT.
* config/i386/i386.md (mult by 1248 into ashift): New splitter.

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

3 years agoc++: support target attr for DECL_LOCAL_DECL_P fns [PR99108]
Martin Liska [Wed, 3 Mar 2021 08:38:55 +0000 (09:38 +0100)]
c++: support target attr for DECL_LOCAL_DECL_P fns [PR99108]

We crash when target attribute get_function_versions_dispatcher is called
for a function that is not registered in call graph.  This was happening
because we were calling it for the function-local decls that aren't in the
symbol table, instead of the corresponding namespace-scope decls that are.

gcc/cp/ChangeLog:

PR c++/99108
* call.c (get_function_version_dispatcher): Handle
DECL_LOCAL_DECL_P.
* decl.c (maybe_version_functions): Likewise.
(maybe_mark_function_versioned): New.
* name-lookup.c (push_local_extern_decl_alias): No longer static.
* name-lookup.h (push_local_extern_decl_alias): Adjust.

gcc/testsuite/ChangeLog:

PR c++/99108
* g++.target/i386/pr99108.C: New test.

Co-authored-by: Jason Merrill <jason@redhat.com>
3 years agoFix potentially undefined behaviour when computing a sha1 value.
Nick Clifton [Tue, 16 Mar 2021 14:43:17 +0000 (14:43 +0000)]
Fix potentially undefined behaviour when computing a sha1 value.

libiberty/
* sha1.c (sha1_process_bytes): Use memmove in place of memcpy.

3 years agooptions: ignore flag_ipa_ra in cl_optimization_compare
Martin Liska [Tue, 16 Mar 2021 13:42:01 +0000 (14:42 +0100)]
options: ignore flag_ipa_ra in cl_optimization_compare

gcc/ChangeLog:

PR target/99592
* optc-save-gen.awk: Add flag_ipa_ra to exceptions for
cl_optimization_compare function.

gcc/testsuite/ChangeLog:

PR target/99592
* gcc.target/arm/pr99592.c: New test.

3 years agoIBM Z: Fix "+fvm" constraint with long doubles
Ilya Leoshkevich [Thu, 10 Dec 2020 14:43:59 +0000 (15:43 +0100)]
IBM Z: Fix "+fvm" constraint with long doubles

When a long double is passed to an asm statement with a "+fvm"
constraint, a LRA loop occurs.  This happens, because LRA chooses the
widest register class in this case (VEC_REGS), but the code generated
by s390_md_asm_adjust() always wants FP_REGS.  Mismatching register
classes cause infinite reloading.

Fix by treating "fv" constraints as "v" in s390_md_asm_adjust().

gcc/ChangeLog:

* config/s390/s390.c (f_constraint_p): Treat "fv" constraints
as "v".

gcc/testsuite/ChangeLog:

* gcc.target/s390/vector/long-double-asm-fprvrmem.c: New test.

3 years agolibstdc++: Remove symbols for new std::call_once implementation [PR 99341]
Jonathan Wakely [Fri, 12 Mar 2021 11:47:20 +0000 (11:47 +0000)]
libstdc++: Remove symbols for new std::call_once implementation [PR 99341]

This removes the new symbols added for the new futex-based
std::call_once implementation. These symbols were new on trunk, so not
in any released version. However, they are already present in some
beta distro releases (Fedora Linux 34) and in Fedora Linux rawhide. This
change can be locally reverted by distros that need to keep the symbols
present until affected packages have been rebuilt.

libstdc++-v3/ChangeLog:

PR libstdc++/99341
* config/abi/post/aarch64-linux-gnu/baseline_symbols.txt: Remove
std::once_flag symbols.
* config/abi/post/ia64-linux-gnu/baseline_symbols.txt: Likewise.
* config/abi/post/m68k-linux-gnu/baseline_symbols.txt: Likewise.
* config/abi/post/riscv64-linux-gnu/baseline_symbols.txt:
Likewise.
* config/abi/pre/gnu.ver: Likewise.
* src/c++11/mutex.cc [_GLIBCXX_HAVE_LINUX_FUTEX]
(struct __once_flag_compat): Remove.
(_ZNSt9once_flag11_M_activateEv): Remove.
(_ZNSt9once_flag9_M_finishEb): Remove.

3 years agolibstdc++: Revert to old std::call_once implementation [PR 99341]
Jonathan Wakely [Fri, 12 Mar 2021 11:47:20 +0000 (11:47 +0000)]
libstdc++: Revert to old std::call_once implementation [PR 99341]

The new std::call_once implementation is not backwards compatible,
contrary to my intention. Because std::once_flag::_M_active() doesn't
write glibc's "fork generation" into the pthread_once_t object, it's
possible for glibc and libstdc++ to run two active executions
concurrently. This violates the primary invariant of the feature!

This patch reverts std::once_flag and std::call_once to the old
implementation that uses pthread_once. This means PR 66146 is a problem
again, but glibc has been changed to solve that. A new API similar to
pthread_once but supporting failure and resetting the pthread_once_t
will be proposed for inclusion in glibc and other C libraries.

This change doesn't simply revert r11-4691 because I want to retain the
new implementation for non-ghtreads targets (which didn't previously
support std::call_once at all, so there's no backwards compatibility
concern). This also leaves the new std::call_once::_M_activate() and
std::call_once::_M_finish(bool) symbols present in libstdc++.so.6 so
that code already compiled against GCC 11 can still use them. Those
symbols will be removed in a subsequent commit (which distros can choose
to temporarily revert if needed).

libstdc++-v3/ChangeLog:

PR libstdc++/99341
* include/std/mutex [_GLIBCXX_HAVE_LINUX_FUTEX] (once_flag):
Revert to pthread_once_t implementation.
[_GLIBCXX_HAVE_LINUX_FUTEX] (call_once): Likewise.
* src/c++11/mutex.cc [_GLIBCXX_HAVE_LINUX_FUTEX]
(struct __once_flag_compat): New type matching the reverted
implementation of once_flag using futexes.
(once_flag::_M_activate): Remove, replace with ...
(_ZNSt9once_flag11_M_activateEv): ... alias symbol.
(once_flag::_M_finish): Remove, replace with ...
(_ZNSt9once_flag9_M_finishEb): ... alias symbol.
* testsuite/30_threads/call_once/66146.cc: Removed.

3 years agoc++: Incorrect type equivalence [PR 99496]
Nathan Sidwell [Mon, 15 Mar 2021 18:25:46 +0000 (11:25 -0700)]
c++: Incorrect type equivalence [PR 99496]

This bug was caused by not marking dependent template aliases
correctly -- these things look like typedefs, but are not
(necessarily) equivalent to the canonical type.  We need to record that.

PR c++/99496
gcc/cp/
* module.cc (trees_out::decl_value): Adjust typedef streaming,
indicate whether it is a dependent alias.
(trees_in::decl_value): Likewise.  Set as dependent alias, if it
is one.
gcc/testsuite/
* g++.dg/modules/pr99496_a.H: New.
* g++.dg/modules/pr99496_b.C: New.

3 years agoDaily bump.
GCC Administrator [Tue, 16 Mar 2021 10:55:35 +0000 (10:55 +0000)]
Daily bump.

3 years agogcc-changelog: skip broken commit in git_update_version.py.
Martin Liska [Tue, 16 Mar 2021 08:35:32 +0000 (09:35 +0100)]
gcc-changelog: skip broken commit in git_update_version.py.

contrib/ChangeLog:

* gcc-changelog/git_update_version.py: Skip one problematic
commit.

3 years agoi386: Fix up _mm256_vzeroupper() handling [PR99563]
Jakub Jelinek [Tue, 16 Mar 2021 10:16:15 +0000 (11:16 +0100)]
i386: Fix up _mm256_vzeroupper() handling [PR99563]

My r10-6451-gb7b3378f91c0641f2ef4d88db22af62a571c9359 fix for
vzeroupper vs. ms ABI apparently broke the explicit vzeroupper handling
when the implicit vzeroupper handling is disabled.
The epilogue_completed splitter for vzeroupper now adds clobbers for all
registers which don't have explicit sets in the pattern and the sets are
added during vzeroupper pass.  Before my changes, for explicit user
vzeroupper, we just weren't modelling its effects at all, it was just
unspec that didn't tell that it clobbers the upper parts of all XMM < %xmm16
registers.  But now the splitter will even for those add clobbers and as
it has no sets, it will add clobbers for all registers, which means
we optimize away anything that lived across that vzeroupper.

The vzeroupper pass has two parts, one is the mode switching that computes
where to put the implicit vzeroupper calls and puts them there, and then
another that uses df to figure out what sets to add to all the vzeroupper.
The former part should be done only under the conditions we have in the
gate, but the latter as this PR shows needs to happen either if we perform
the implicit vzeroupper additions, or if there are (or could be) any
explicit vzeroupper instructions.  As that function does df_analyze and
walks the whole IL, I think it would be too expensive to run it always
whenever TARGET_AVX, so this patch remembers if we've expanded at least
one __builtin_ia32_vzeroupper in the function and runs that part of the
vzeroupper pass both when the old condition is true or when this new
flag is set.

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

PR target/99563
* config/i386/i386.h (struct machine_function): Add
has_explicit_vzeroupper bitfield.
* config/i386/i386-expand.c (ix86_expand_builtin): Set
cfun->machine->has_explicit_vzeroupper when expanding
IX86_BUILTIN_VZEROUPPER.
* config/i386/i386-features.c (rest_of_handle_insert_vzeroupper):
Do the mode switching only when TARGET_VZEROUPPER, expensive
optimizations turned on and not optimizing for size.
(pass_insert_vzeroupper::gate): Enable even when
cfun->machine->has_explicit_vzeroupper is set.

* gcc.target/i386/avx-pr99563.c: New test.

3 years agoaarch64: Fix up aarch64_simd_clone_compute_vecsize_and_simdlen [PR99542]
Jakub Jelinek [Tue, 16 Mar 2021 09:34:44 +0000 (10:34 +0100)]
aarch64: Fix up aarch64_simd_clone_compute_vecsize_and_simdlen [PR99542]

As the patch shows, there are several bugs in
aarch64_simd_clone_compute_vecsize_and_simdlen.
One is that unlike for function declarations that aren't definitions
it completely ignores argument types.  Such decls don't have DECL_ARGUMENTS,
but we can walk TYPE_ARG_TYPES instead, like the i386 backend does or like
the simd cloning code in the middle end does too.

Another problem is that it checks types of uniform arguments.  That is
unnecessary, uniform arguments are passed the way it normally is, it is
a scalar argument rather than vector, so there is no reason not to support
uniform argument of different size, or long double, structure etc.

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

PR target/99542
* config/aarch64/aarch64.c
(aarch64_simd_clone_compute_vecsize_and_simdlen): If not a function
definition, walk TYPE_ARG_TYPES list if non-NULL for argument types
instead of DECL_ARGUMENTS.  Ignore types for uniform arguments.

* gcc.dg/gomp/pr99542.c: New test.
* gcc.dg/gomp/pr59669-2.c (bar): Don't expect a warning on aarch64.
* gcc.dg/gomp/simd-clones-2.c (setArray): Likewise.
* g++.dg/vect/simd-clone-7.cc (bar): Likewise.
* g++.dg/gomp/declare-simd-1.C (f37): Expect a different warning
on aarch64.
* gcc.dg/declare-simd.c (fn2): Expect a new warning on aarch64.

3 years agotestsuite: Fix up target selector syntax errors in modules/builtin-3*.C [PR99601]
Jakub Jelinek [Mon, 15 Mar 2021 23:24:15 +0000 (00:24 +0100)]
testsuite: Fix up target selector syntax errors in modules/builtin-3*.C [PR99601]

Without this patch I'm seeing:
ERROR: tcl error sourcing /home/jakub/src/gcc/gcc/testsuite/g++.dg/modules/modules.exp.
ERROR: unmatched open brace in list
    while executing
"foreach op $tmp {
        switch [lindex $op 0] {
            "dg-options" {
                set std_prefix "-std=gnu++"
                if { [string match "*-std=*" [lindex $op 2]] } {
                    ..."
    (procedure "module-init" line 7)
    invoked from within
"module-init $src"
    invoked from within
"if [runtest_file_p $runtests $src] {
        set tests [lsort [find [file dirname $src]  [regsub {_a.[CHX]$} [file tail $src] {_[a-z].[CHX]}]]]

        set std_lis..."
    ("foreach" body line 3)
    invoked from within
"foreach src [lsort [find $srcdir/$subdir {*_a.[CHX}]] {
    # use the FOO_a.C name as the parallelization key
    if [runtest_file_p $runtests $src] {..."
    (file "/home/jakub/src/gcc/gcc/testsuite/g++.dg/modules/modules.exp" line 304)
    invoked from within
"source /home/jakub/src/gcc/gcc/testsuite/g++.dg/modules/modules.exp"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 source /home/jakub/src/gcc/gcc/testsuite/g++.dg/modules/modules.exp"
    invoked from within
"catch "uplevel #0 source $test_file_name""

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

PR c++/99601
* g++.dg/modules/builtin-3_a.C: Fix target selector syntax errors.
* g++.dg/modules/builtin-3_b.C: Likewise.

3 years agolibgo: update to Go 1.16.2 release
Ian Lance Taylor [Sat, 13 Mar 2021 03:44:12 +0000 (19:44 -0800)]
libgo: update to Go 1.16.2 release

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

3 years agoUpdate gcc sv.po.
Joseph Myers [Mon, 15 Mar 2021 20:30:40 +0000 (20:30 +0000)]
Update gcc sv.po.

* sv.po: Update.

3 years agoc++: Fix 2 testcases [PR 99601]
Nathan Sidwell [Mon, 15 Mar 2021 19:25:32 +0000 (15:25 -0400)]
c++: Fix 2 testcases [PR 99601]

I'd failed to correctly restrict some checks to lp64 x86 targets.

PR c++/99601
gcc/testsuite/
* g++.dg/modules/builtin-3_a.C: Fix lp64 x86 detection.
* g++.dg/modules/builtin-3_b.C: Fix lp64 x86 detection.

3 years agolibstdc++-v3: Update VTV vars for libtool link commands [PR99172]
Caroline Tice [Fri, 12 Mar 2021 15:34:36 +0000 (07:34 -0800)]
libstdc++-v3: Update VTV vars for libtool link commands [PR99172]

This fixes PR 99172

Currently when GCC is configured with --enable-vtable-verify, the
libstdc++-v3 Makefiles add "-fvtable-verify=std
-Wl,-u_vtable_map_vars_start,-u_vtable_map_vars_end" to libtool link
commands. The "-fvtable-verify=std" piece causes alternate versions of
libtool (such as slibtool) to fail, unable to find "-lvtv" (GNU
libtool just removes that piece).

This patch updates the libstdc++-v3 Makefiles to not pass
"-fvtable-verify=std" to the libtool link commands.

3 years agocoroutines : Convert await_ready () expressions to bool [PR99047].
Iain Sandoe [Sun, 14 Mar 2021 14:42:52 +0000 (14:42 +0000)]
coroutines : Convert await_ready () expressions to bool [PR99047].

The awaiter.await_ready() should be converted per [expr.await]/3

(3.6) await-ready is the expression e.await_ready(), contextually
      converted to bool.

gcc/cp/ChangeLog:

PR c++/99047
* coroutines.cc (expand_one_await_expression): If the
await_ready() expression is not a boolean then convert it
as required.

gcc/testsuite/ChangeLog:

PR c++/99047
* g++.dg/coroutines/pr99047.C: New test.

3 years agocoroutines : Handle rethrow from unhandled_exception [PR98704].
Iain Sandoe [Thu, 11 Mar 2021 17:04:14 +0000 (17:04 +0000)]
coroutines : Handle rethrow from unhandled_exception [PR98704].

Although there is still some discussion in CWG 2451 on this, the
implementors are agreed on the intent.

When promise.unhandled_exception () is entered, the coroutine is
considered to be still running - returning from the method will
cause the final await expression to be evaluated.

If the method throws, that action is considered to make the
coroutine suspend (since, otherwise, it would be impossible to
reclaim its resources, since one cannot destroy a running coro).

The wording issue is to do with how to represent the place at
which the coroutine should be considered suspended.

For the implementation here, that place is immediately before the
promise life-time ends. A handler for the rethrown exception, can
thus call xxxx.destroy() which will run DTORs for the promise and
any parameter copies [as needed] then the coroutine frame will be
deallocated.

At present, we also set "done=true" in this case (for compatibility
with other current implementations).  One might consider 'done()'
to be misleading in the case of an abnormal termination - that is
also part of the CWG 2451 discussion.

gcc/cp/ChangeLog:

PR c++/98704
* coroutines.cc (build_actor_fn): Make destroy index 1
correspond to the abnormal unhandled_exception() exit.
Substitute the proxy for the resume index.
(coro_rewrite_function_body): Arrange to reset the resume
index and make done = true for a rethrown exception from
unhandled_exception ().
(morph_fn_to_coro): Adjust calls to build_actor_fn and
coro_rewrite_function_body.

gcc/testsuite/ChangeLog:

PR c++/98704
* g++.dg/coroutines/torture/pr98704.C: New test.

3 years agocoroutines : Handle for await expressions in for stmts [PR98480].
Iain Sandoe [Thu, 11 Mar 2021 14:22:37 +0000 (14:22 +0000)]
coroutines : Handle for await expressions in for stmts [PR98480].

The handling of await expressions in the init, condition and iteration
expressions of for loops had been omitted.  Fixed thus.

gcc/cp/ChangeLog:

PR c++/98480
* coroutines.cc (replace_continue): Rewrite continue into
'goto label'.
(await_statement_walker): Handle await expressions in the
initializer, condition and iteration expressions of for
loops.

gcc/testsuite/ChangeLog:

PR c++/98480
* g++.dg/coroutines/pr98480.C: New test.
* g++.dg/coroutines/torture/co-await-24-for-init.C: New test.
* g++.dg/coroutines/torture/co-await-25-for-condition.C: New test.
* g++.dg/coroutines/torture/co-await-26-for-iteration-expr.C: New test.

3 years agocoroutines : Avoid generating empty statements [PR96749].
Iain Sandoe [Tue, 2 Mar 2021 10:12:58 +0000 (10:12 +0000)]
coroutines : Avoid generating empty statements [PR96749].

In the compiler-only idiom:
" a = (target expr creats temp, op uses temp) "
the target expression variable needs to be promoted to a frame one
(if the expression has a suspend point).  However, the only uses of
the var are in the second part of the compound expression - and we
were creating an empty statement corresponding to the (now unused)
first arm.  This then produces the spurious warnings noted.

Fixed by avoiding generation of a separate variable nest for
isolated target expressions (or similarly isolated co_awaits used
in a function call).

gcc/cp/ChangeLog:

PR c++/96749
* coroutines.cc (flatten_await_stmt): Allow for the case
where a target expression variable only has uses in the
second part of a compound expression.
(maybe_promote_temps): Avoid emiting empty statements.

gcc/testsuite/ChangeLog:

PR c++/96749
* g++.dg/coroutines/pr96749-1.C: New test.
* g++.dg/coroutines/pr96749-2.C: New test.

3 years agolibstdc++, testsuite, Darwin : Adjust for names used in system headers.
Iain Sandoe [Mon, 15 Mar 2021 00:34:27 +0000 (00:34 +0000)]
libstdc++, testsuite, Darwin : Adjust for names used in system headers.

For all current Darwin SDKs inttypes.h has:
extern intmax_t imaxabs(intmax_t j);

So we need to exclude j from the defined test symbols.

libstdc++-v3/ChangeLog:

* testsuite/17_intro/names.cc: Exclude j from the list
of test symbols for Darwin.

3 years agolibstdc++, Darwin, ppc : Add new long double symbols.
Iain Sandoe [Mon, 15 Mar 2021 00:30:07 +0000 (00:30 +0000)]
libstdc++, Darwin, ppc : Add new long double symbols.

We need to add the symbols for to_chars and from_chars for the
long double cases.

libstdc++-v3/ChangeLog:

* config/os/bsd/darwin/ppc-extra.ver: Add matching for
to_chars and from_chars for long double.

3 years agotree-optimization/98834 - fix optimization regression with _b_c_p
Richard Biener [Mon, 15 Mar 2021 12:44:07 +0000 (13:44 +0100)]
tree-optimization/98834 - fix optimization regression with _b_c_p

The following makes FRE optimize a load we formerly required
SRA + CCP for which now run after we get rid of all __builtin_constant_p
calls.

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

PR tree-optimization/98834
* tree-ssa-sccvn.c (vn_reference_lookup_3): Handle missing
subsetting by truncating the access size.

* g++.dg/opt/pr98834.C: New testcase.

3 years agolibstdc++: Implement missing operator overloads in max_size_type.h
Patrick Palka [Mon, 15 Mar 2021 14:31:45 +0000 (10:31 -0400)]
libstdc++: Implement missing operator overloads in max_size_type.h

This implements operator++, operator-- and operator<=> for the
integer-class types defined in max_size_type.h, which I overlooked
when originally implementing the class.

libstdc++-v3/ChangeLog:

* include/bits/max_size_type.h (__max_size_type::operator _Tp):
Fix formatting.
(__max_size_type::operator++): Define.
(__max_size_type::operator--): Likewise.
(__max_size_type::operator<=>): Conditionally define (in place
of the other comparison operators).
(__max_diff_type::operator _Tp): Fix formatting.
(__max_diff_type::operator++): Define.
(__max_diff_type::operator--): Likewise.
(__max_diff_type::operator<=>): Conditionally define (in place
of the other comparison operators).
* testsuite/std/ranges/iota/max_size_type.cc (test01): Test
these operator overloads.

3 years agoanalyzer: fix missing comma in initializer
Martin Liska [Mon, 15 Mar 2021 08:29:48 +0000 (09:29 +0100)]
analyzer: fix missing comma in initializer

Fixes the following valid warning:

gcc/analyzer/sm-file.cc:250:5: warning: suspicious concatenation of string literals in an array initialization;
did you mean to separate the elements with a comma? [-Wstring-concatenation]

gcc/analyzer/ChangeLog:

* sm-file.cc (get_file_using_fns): Add missing comma in initializer.

3 years agoznver3 tuning part 1
Jan Hubicka [Mon, 15 Mar 2021 10:36:52 +0000 (11:36 +0100)]
znver3 tuning part 1

2021-03-15  Jan Hubicka  <hubicka@ucw.cz>

* config/i386/i386-options.c (processor_cost_table): Add znver3_cost.
* config/i386/x86-tune-costs.h (znver3_cost): New gobal variable; copy
of znver2_cost.

3 years agoHandle EXEC_IOLENGTH in doloop_contained_procedure_code.
Thomas Koenig [Mon, 15 Mar 2021 10:02:02 +0000 (11:02 +0100)]
Handle EXEC_IOLENGTH in doloop_contained_procedure_code.

This rather obvious patch fixes an ICE on valid which came about
because I did not handle EXEC_IOLENGTH as start of an I/O statement
when checking for the DO loop variable.  This is an 11 regression.

gcc/fortran/ChangeLog:

PR fortran/99345
* frontend-passes.c (doloop_contained_procedure_code):
Properly handle EXEC_IOLENGTH.

gcc/testsuite/ChangeLog:

PR fortran/99345
* gfortran.dg/do_check_16.f90: New test.
* gfortran.dg/do_check_17.f90: New test.

3 years agoFortran: Fix problem with allocate initialization [PR99545].
Paul Thomas [Mon, 15 Mar 2021 09:32:52 +0000 (09:32 +0000)]
Fortran: Fix problem with allocate initialization [PR99545].

2021-03-15  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran/ChangeLog

PR fortran/99545
* trans-stmt.c (gfc_trans_allocate): Mark the initialization
assignment by setting init_flag.

gcc/testsuite/ChangeLog

PR fortran/99545
* gfortran.dg/pr99545.f90: New test.

3 years agoOpenMP: Fix 'omp declare target' handling for vars [PR99509]
Tobias Burnus [Mon, 15 Mar 2021 09:12:58 +0000 (10:12 +0100)]
OpenMP: Fix 'omp declare target' handling for vars [PR99509]

For variables with 'declare target' attribute,
varpool_node::get_create marks variables as offload; however,
if the node already exists, it is not updated. C/C++ may tag
decl with 'declare target implicit', which may only be after
varpool creation turned into 'declare target' or 'declare target link';
in this case, the tagging has to happen in the FE.

gcc/c/ChangeLog:

PR c++/99509
* c-decl.c (finish_decl): For 'omp declare target implicit' vars,
ensure that the varpool node is marked as offloadable.

gcc/cp/ChangeLog:

PR c++/99509
* decl.c (cp_finish_decl): For 'omp declare target implicit' vars,
ensure that the varpool node is marked as offloadable.

libgomp/ChangeLog:

PR c++/99509
* testsuite/libgomp.c-c++-common/declare_target-1.c: New test.

3 years agoFix -Wstring-concatenation warning.
Martin Liska [Mon, 15 Mar 2021 08:27:32 +0000 (09:27 +0100)]
Fix -Wstring-concatenation warning.

Fix the following clang warning:
gcc/spellcheck.c:477:3: warning: suspicious concatenation of string literals in an array initialization;
did you mean to separate the elements with a comma? [-Wstring-concatenation]

gcc/ChangeLog:

* spellcheck.c: Add missing comma in initialization.

3 years agotestsuite: fix typo in testcase pr99492.c
David Edelsohn [Mon, 15 Mar 2021 00:29:14 +0000 (20:29 -0400)]
testsuite: fix typo in testcase pr99492.c

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr99492.c: Fix typo.

3 years agoDaily bump.
GCC Administrator [Mon, 15 Mar 2021 00:16:26 +0000 (00:16 +0000)]
Daily bump.

3 years agoPR fortran/99112 - ICE with runtime diagnostics for SIZE intrinsic function
Harald Anlauf [Sun, 14 Mar 2021 19:39:58 +0000 (20:39 +0100)]
PR fortran/99112 - ICE with runtime diagnostics for SIZE intrinsic function

Add/fix handling of runtime checks for CLASS arguments with ALLOCATABLE
or POINTER attribute.

gcc/fortran/ChangeLog:

* trans-expr.c (gfc_conv_procedure_call): Fix runtime checks for
CLASS arguments.
* trans-intrinsic.c (gfc_conv_intrinsic_size): Likewise.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr99112.f90: New test.

Co-authored-by: Paul Thomas <pault@gcc.gnu.org>
3 years agoi386: Some more -mavx512vl -mno-avx512bw fixes [PR99321]
Uros Bizjak [Sun, 14 Mar 2021 17:51:14 +0000 (18:51 +0100)]
i386: Some more -mavx512vl -mno-avx512bw fixes [PR99321]

2021-03-14  UroÅ¡ Bizjak  <ubizjak@gmail.com>

gcc/
* config/i386/sse.md (*vec_extract<mode>): Merge alternative 0 with
alternative 2 and alternative 1 with alternative 3 using
YW register constraint.
(*vec_extract<PEXTR_MODE12:mode>_zext): Merge alternatives
using YW register constraint.
(*vec_extractv16qi_zext): Ditto.
(*vec_extractv4si): Merge alternatives 4 and 5
using Yw register constraint.
(*ssse3_palignr<mode>_perm): Use Yw instead of v for alternative 3.

3 years agoDaily bump.
GCC Administrator [Sun, 14 Mar 2021 00:16:18 +0000 (00:16 +0000)]
Daily bump.

3 years agoPR tree-optimization/99489 - ICE calling strncat after strcat
Martin Sebor [Tue, 9 Mar 2021 22:02:35 +0000 (15:02 -0700)]
PR tree-optimization/99489 - ICE calling strncat after strcat

gcc/ChangeLog:

PR tree-optimization/99489
* builtins.c (gimple_call_alloc_size): Fail gracefully when argument
is not a call statement.

gcc/testsuite/ChangeLog:

PR tree-optimization/99489
* gcc.dg/Wstringop-truncation-9.c: New test.

3 years agoFortran: Fix for class defined operators [PR99125].
Paul Thomas [Sat, 13 Mar 2021 11:39:57 +0000 (11:39 +0000)]
Fortran: Fix for class defined operators [PR99125].

2021-03-13  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/99125
* trans-array.c (gfc_conv_expr_descriptor): For deferred length
length components use the ss_info string length instead of
gfc_get_expr_charlen. Make sure that the deferred string length
is a variable before assigning to it. Otherwise use the expr.
* trans-expr.c (gfc_conv_string_length): Make sure that the
deferred string length is a variable before assigning to it.

gcc/testsuite/
PR fortran/99125
* gfortran.dg/alloc_deferred_comp_1.f90: New test.

3 years agomatch.pd: Don't optimize vector X + (X << C) -> X * (1 + (1 << C)) if there is no...
Jakub Jelinek [Sat, 13 Mar 2021 07:56:15 +0000 (08:56 +0100)]
match.pd: Don't optimize vector X + (X << C) -> X * (1 + (1 << C)) if there is no mult support [PR99544]

E.g. on aarch64, the target has V2DImode addition and shift by scalar
optabs, but doesn't have V2DImode multiply.  The following testcase
ICEs because this simplification is done after last lowering, but
generally, even if it is done before that, turning it into a multiplication
will not be an improvement because that means scalarization, while the former
can be done in vectors.

It would be nice if we added expansion support for vector multiplication
by uniform constants using shifts and additions like we have for scalar
multiplication, but that is something that can be done in stage1.

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

PR tree-optimization/99544
* match.pd (X + (X << C) -> X * (1 + (1 << C))): Don't simplify
if for vector types multiplication can't be done in type's mode.

* gcc.dg/gomp/pr99544.c: New test.

3 years agomisc/cgo/testcarchive: don't use == for string equality in C code
Ian Lance Taylor [Sat, 13 Mar 2021 03:17:09 +0000 (19:17 -0800)]
misc/cgo/testcarchive: don't use == for string equality in C code

Backport of https://golang.org/cl/300993.

For PR go/99553

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

3 years agoMAINTAINERS: Add myself for write after approval
Eugene Rozenfeld [Sat, 13 Mar 2021 01:34:54 +0000 (17:34 -0800)]
MAINTAINERS: Add myself for write after approval

ChangeLog:

2021-03-12  Eugene Rozenfeld  <erozen@microsoft.com>

* MAINTAINERS (Write After Approval): Add myself.

3 years agosim: drop dep on configure-gdb
Mike Frysinger [Sun, 28 Feb 2021 06:43:21 +0000 (01:43 -0500)]
sim: drop dep on configure-gdb

I'm not entirely sure why this is here since the sim doesn't use
anything from the gdb/ dir directly, and the commit that added it
included a bunch more changes and doesn't seem to call out this
dep specifically.

ChangeLog:

* Makefile.def: Remove all-sim dependency on configure-gdb.
* Makefile.in: Regenerated.

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

3 years agoc++: ICE with using-decl [PR 99238]
Nathan Sidwell [Fri, 12 Mar 2021 17:02:41 +0000 (09:02 -0800)]
c++: ICE with using-decl [PR 99238]

This ICE was caused by a stray TREE_VISITED marker.  The lookup
machinery was leaving it there due to the way I'd arranged for it to
be cleared.  That was presuming the name_lookup::value field didn't
change, and that wasn't always true in the using-decl processing.  I
took the opportunity to break out a helper, and then call it
immediately after lookups, rather than wait until destructor time.
Added some asserts the module machinery to catch further cases of
this.

PR c++/99238
gcc/cp/
* module.cc (depset::hash::add_binding_entity): Assert not
visited.
(depset::add::add_specializations): Likewise.
* name-lookup.c (name_lookup::dedup): New.
(name_lookup::~name_lookup): Assert not deduping.
(name_lookup::restore_state): Likewise.
(name_lookup::add_overload): Replace outlined code with dedup
call.
(name_lookup::add_value): Likewise.
(name_lookup::search_namespace_only): Likewise.
(name_lookup::adl_namespace_fns): Likewise.
(name_lookup::adl_class_fns): Likewise.
(name_lookup::search_adl): Likewise.  Add clearing dedup call.
(name_lookup::search_qualified): Likewise.
(name_lookup::search_unqualified): Likewise.
gcc/testsuite/
* g++.dg/modules/pr99238.h: New.
* g++.dg/modules/pr99238_a.H: New.
* g++.dg/modules/pr99238_b.H: New.

3 years agoFix memory constraint bug in SPARC back-end
Eric Botcazou [Fri, 12 Mar 2021 16:07:20 +0000 (17:07 +0100)]
Fix memory constraint bug in SPARC back-end

It's a bug exposed by the recent LRA changes, whereby the T constraint
fails to behave properly when LRA is enabled (unlike when reload is
enabled).  The patch also gets rid of the awkward W constraint, which
is strictly equivalent to m in 64-bit mode and, as a result, renames
the w constraint into W.

gcc/
PR target/99422
* config/sparc/constraints.md (w): Rename to...
(W): ... this and ditch previous implementation.
* config/sparc/sparc.md (*movdi_insn_sp64): Replace W with m.
(*movdf_insn_sp64): Likewise.
(*mov<VM64:mode>_insn_sp64): Likewise.
* config/sparc/sync.md (*atomic_compare_and_swap<mode>_1): Replace
w with W.
(atomic_compare_and_swap_leon3_1): Likewise.
(*atomic_compare_and_swapdi_v8plus): Likewise.
* config/sparc/sparc.c (memory_ok_for_ldd): Remove useless test on
architecture and add missing address validity check during LRA.

3 years agoFortran/OpenMP: Accept implicit-save DATA vars for threadprivate [PR99514]
Tobias Burnus [Fri, 12 Mar 2021 15:34:10 +0000 (16:34 +0100)]
Fortran/OpenMP: Accept implicit-save DATA vars for threadprivate [PR99514]

gcc/fortran/ChangeLog:

PR fortran/99514
* resolve.c (resolve_symbol): Accept vars which are in DATA
and hence (either) implicit SAVE (or in common).

gcc/testsuite/ChangeLog:

PR fortran/99514
* gfortran.dg/gomp/threadprivate-1.f90: New test.

3 years agoFortran/OpenMP: Fix use_device_{ptr,addr} with assumed-size array [PR98858]
Tobias Burnus [Fri, 12 Mar 2021 15:33:02 +0000 (16:33 +0100)]
Fortran/OpenMP: Fix use_device_{ptr,addr} with assumed-size array [PR98858]

gcc/ChangeLog:

PR fortran/98858
* gimplify.c (omp_add_variable): Handle NULL_TREE as size
occuring for assumed-size arrays in use_device_{ptr,addr}.

libgomp/ChangeLog:

PR fortran/98858
* testsuite/libgomp.fortran/use_device_ptr-3.f90: New test.

3 years agoFortran: Fix libgfortran I/O race with newunit_free [PR99529]
Tobias Burnus [Fri, 12 Mar 2021 15:31:32 +0000 (16:31 +0100)]
Fortran: Fix libgfortran I/O race with newunit_free [PR99529]

libgfortran/ChangeLog:

* io/transfer.c (st_read_done_worker, st_write_done_worker):
Call unlock_unit here, add unit_lock lock around newunit_free call.
(st_read_done, st_write_done): Only call unlock_unit when not
calling the worker function.
* io/unit.c (set_internal_unit): Don't reset the unit_number
to the same number as this cause race warnings.

3 years agoi386: Hopefully last set of -mavx512vl -mno-avx512bw fixes [PR99321]
Jakub Jelinek [Fri, 12 Mar 2021 13:34:32 +0000 (14:34 +0100)]
i386: Hopefully last set of -mavx512vl -mno-avx512bw fixes [PR99321]

This is the final patch of the series started with
https://gcc.gnu.org/pipermail/gcc-patches/2021-March/566139.html
and continued with
https://gcc.gnu.org/pipermail/gcc-patches/2021-March/566356.html
This time, I went through all the remaining instructions marked
by gas as requiring both AVX512BW and AVX512VL and for each checked
tmp-mddump.md, figure out if it ever could be a problem (e.g. instructions
that require AVX512BW+AVX512VL, but didn't exist before AVX512F are usually
fine, the patterns have the right conditions, the bugs are typically on
pre-AVX512F patterns where we have just blindly added v while they actually
can't access those unless AVX512BW+AVX512VL), added test where possible
(the test doesn't cover MMX though)and fixed md bugs.

For mmx pextr[bw]/pinsr[bw] patterns it introduces per discussions
a new YW constraint that only requires AVX512BW and not AVX512VL, because
those instructions only require the former and not latter when using EVEX
encoding.

There are some other interesting details, e.g. most of the 8 interleave
patterns (vpunck[hl]{bw,wd}) had correctly
&& <mask_avx512vl_condition> && <mask_avx512bw_condition>
in the conditions because for masking it needs to be always EVEX encoded
and then it needs both VL+BW, but 2 of those 8 had just
&& <mask_avx512vl_condition>
and so again would run into the -mavx512vl -mno-avx512bw problems.

Another problem different from others was mmx eq/gt comparisons, that was
using Yv constraints, so would happily accept %xmm16+ registers for
-mavx512vl, but there actually are no such EVEX encoded instructions,
as AVX512 comparisons work with %k* registers instead.

The newly added testcase without the patch fails with:
/tmp/ccVROLo2.s: Assembler messages:
/tmp/ccVROLo2.s:9: Error: unsupported instruction `vpabsb'
/tmp/ccVROLo2.s:20: Error: unsupported instruction `vpabsb'
/tmp/ccVROLo2.s:31: Error: unsupported instruction `vpabsw'
/tmp/ccVROLo2.s:42: Error: unsupported instruction `vpabsw'
/tmp/ccVROLo2.s:53: Error: unsupported instruction `vpaddsb'
/tmp/ccVROLo2.s:64: Error: unsupported instruction `vpaddsb'
/tmp/ccVROLo2.s:75: Error: unsupported instruction `vpaddsw'
/tmp/ccVROLo2.s:86: Error: unsupported instruction `vpaddsw'
/tmp/ccVROLo2.s:97: Error: unsupported instruction `vpsubsb'
/tmp/ccVROLo2.s:108: Error: unsupported instruction `vpsubsb'
/tmp/ccVROLo2.s:119: Error: unsupported instruction `vpsubsw'
/tmp/ccVROLo2.s:130: Error: unsupported instruction `vpsubsw'
/tmp/ccVROLo2.s:141: Error: unsupported instruction `vpaddusb'
/tmp/ccVROLo2.s:152: Error: unsupported instruction `vpaddusb'
/tmp/ccVROLo2.s:163: Error: unsupported instruction `vpaddusw'
/tmp/ccVROLo2.s:174: Error: unsupported instruction `vpaddusw'
/tmp/ccVROLo2.s:185: Error: unsupported instruction `vpsubusb'
/tmp/ccVROLo2.s:196: Error: unsupported instruction `vpsubusb'
/tmp/ccVROLo2.s:207: Error: unsupported instruction `vpsubusw'
/tmp/ccVROLo2.s:218: Error: unsupported instruction `vpsubusw'
/tmp/ccVROLo2.s:258: Error: unsupported instruction `vpaddusw'
/tmp/ccVROLo2.s:269: Error: unsupported instruction `vpavgb'
/tmp/ccVROLo2.s:280: Error: unsupported instruction `vpavgb'
/tmp/ccVROLo2.s:291: Error: unsupported instruction `vpavgw'
/tmp/ccVROLo2.s:302: Error: unsupported instruction `vpavgw'
/tmp/ccVROLo2.s:475: Error: unsupported instruction `vpmovsxbw'
/tmp/ccVROLo2.s:486: Error: unsupported instruction `vpmovsxbw'
/tmp/ccVROLo2.s:497: Error: unsupported instruction `vpmovzxbw'
/tmp/ccVROLo2.s:508: Error: unsupported instruction `vpmovzxbw'
/tmp/ccVROLo2.s:548: Error: unsupported instruction `vpmulhuw'
/tmp/ccVROLo2.s:559: Error: unsupported instruction `vpmulhuw'
/tmp/ccVROLo2.s:570: Error: unsupported instruction `vpmulhw'
/tmp/ccVROLo2.s:581: Error: unsupported instruction `vpmulhw'
/tmp/ccVROLo2.s:592: Error: unsupported instruction `vpsadbw'
/tmp/ccVROLo2.s:603: Error: unsupported instruction `vpsadbw'
/tmp/ccVROLo2.s:643: Error: unsupported instruction `vpshufhw'
/tmp/ccVROLo2.s:654: Error: unsupported instruction `vpshufhw'
/tmp/ccVROLo2.s:665: Error: unsupported instruction `vpshuflw'
/tmp/ccVROLo2.s:676: Error: unsupported instruction `vpshuflw'
/tmp/ccVROLo2.s:687: Error: unsupported instruction `vpslldq'
/tmp/ccVROLo2.s:698: Error: unsupported instruction `vpslldq'
/tmp/ccVROLo2.s:709: Error: unsupported instruction `vpsrldq'
/tmp/ccVROLo2.s:720: Error: unsupported instruction `vpsrldq'
/tmp/ccVROLo2.s:899: Error: unsupported instruction `vpunpckhbw'
/tmp/ccVROLo2.s:910: Error: unsupported instruction `vpunpckhbw'
/tmp/ccVROLo2.s:921: Error: unsupported instruction `vpunpckhwd'
/tmp/ccVROLo2.s:932: Error: unsupported instruction `vpunpckhwd'
/tmp/ccVROLo2.s:943: Error: unsupported instruction `vpunpcklbw'
/tmp/ccVROLo2.s:954: Error: unsupported instruction `vpunpcklbw'
/tmp/ccVROLo2.s:965: Error: unsupported instruction `vpunpcklwd'
/tmp/ccVROLo2.s:976: Error: unsupported instruction `vpunpcklwd'

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

PR target/99321
* config/i386/constraints.md (YW): New internal constraint.
* config/i386/sse.md (v_Yw): Add V4TI, V2TI, V1TI and TI cases.
(*<sse2_avx2>_<insn><mode>3<mask_name>,
*<sse2_avx2>_uavg<mode>3<mask_name>, *abs<mode>2,
*<s>mul<mode>3_highpart<mask_name>): Use <v_Yw> instead of v in
constraints.
(<sse2_avx2>_psadbw): Use YW instead of v in constraints.
(*avx2_pmaddwd, *sse2_pmaddwd, *<code>v8hi3, *<code>v16qi3,
avx2_pmaddubsw256, ssse3_pmaddubsw128): Merge last two alternatives
into one, use Yw instead of former x,v.
(ashr<mode>3, <insn><mode>3): Use <v_Yw> instead of x in constraints of
the last alternative.
(<sse2_avx2>_packsswb<mask_name>, <sse2_avx2>_packssdw<mask_name>,
<sse2_avx2>_packuswb<mask_name>, <sse4_1_avx2>_packusdw<mask_name>,
*<ssse3_avx2>_pmulhrsw<mode>3<mask_name>, <ssse3_avx2>_palignr<mode>,
<ssse3_avx2>_pshufb<mode>3<mask_name>): Merge last two alternatives
into one, use <v_Yw> instead of former x,v.
(avx2_interleave_highv32qi<mask_name>,
vec_interleave_highv16qi<mask_name>): Use Yw instead of v in
constraints.  Add && <mask_avx512bw_condition> to condition.
(avx2_interleave_lowv32qi<mask_name>,
vec_interleave_lowv16qi<mask_name>,
avx2_interleave_highv16hi<mask_name>,
vec_interleave_highv8hi<mask_name>,
avx2_interleave_lowv16hi<mask_name>, vec_interleave_lowv8hi<mask_name>,
avx2_pshuflw_1<mask_name>, sse2_pshuflw_1<mask_name>,
avx2_pshufhw_1<mask_name>, sse2_pshufhw_1<mask_name>,
avx2_<code>v16qiv16hi2<mask_name>, sse4_1_<code>v8qiv8hi2<mask_name>,
*sse4_1_<code>v8qiv8hi2<mask_name>_1, <sse2_avx2>_<insn><mode>3): Use
Yw instead of v in constraints.
* config/i386/mmx.md (Yv_Yw): New define_mode_attr.
(*mmx_<insn><mode>3, mmx_ashr<mode>3, mmx_<insn><mode>3): Use <Yv_Yw>
instead of Yv in constraints.
(*mmx_<insn><mode>3, *mmx_mulv4hi3, *mmx_smulv4hi3_highpart,
*mmx_umulv4hi3_highpart, *mmx_pmaddwd, *mmx_<code>v4hi3,
*mmx_<code>v8qi3, mmx_pack<s_trunsuffix>swb, mmx_packssdw,
mmx_punpckhbw, mmx_punpcklbw, mmx_punpckhwd, mmx_punpcklwd,
*mmx_uavgv8qi3, *mmx_uavgv4hi3, mmx_psadbw): Use Yw instead of Yv in
constraints.
(*mmx_pinsrw, *mmx_pinsrb, *mmx_pextrw, *mmx_pextrw_zext, *mmx_pextrb,
*mmx_pextrb_zext): Use YW instead of Yv in constraints.
(*mmx_eq<mode>3, mmx_gt<mode>3): Use x instead of Yv in constraints.
(mmx_andnot<mode>3, *mmx_<code><mode>3): Split last alternative into
two, one with just x, another isa avx512vl with v.

* gcc.target/i386/avx512vl-pr99321-2.c: New test.

3 years agoc++: Fix up calls to immediate functions returning reference [PR99507]
Jakub Jelinek [Fri, 12 Mar 2021 09:11:24 +0000 (10:11 +0100)]
c++: Fix up calls to immediate functions returning reference [PR99507]

build_cxx_call calls convert_from_reference at the end, so if an immediate
function returns a reference, we were constant evaluating not just that
call, but that call wrapped in an INDIRECT_REF.  That unfortunately means
it can constant evaluate to something non-addressable, so if code later
needs to take its address it will fail.

The following patch fixes that by undoing the convert_from_reference
wrapping for the cxx_constant_value evaluation and readdding it ad the end.

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

PR c++/99507
* call.c (build_over_call): For immediate evaluation of functions
that return references, undo convert_from_reference effects before
calling cxx_constant_value and call convert_from_reference
afterwards.

* g++.dg/cpp2a/consteval19.C: New test.

3 years agoanalyzer: document new param
Martin Liska [Fri, 12 Mar 2021 08:43:54 +0000 (09:43 +0100)]
analyzer: document new param

gcc/ChangeLog:

* doc/invoke.texi: Add missing param documentation.

3 years agogcc-changelog: allow ChangeLog deletion in a commit
Martin Liska [Fri, 12 Mar 2021 08:08:36 +0000 (09:08 +0100)]
gcc-changelog: allow ChangeLog deletion in a commit

contrib/ChangeLog:

* gcc-changelog/git_commit.py: Allow deletion of ChangeLog
files.
* gcc-changelog/setup.cfg: Set line limit to 120 characters.
* gcc-changelog/test_email.py: Add test.
* gcc-changelog/test_patches.txt: Likewise.
* gcc-changelog/git_email.py: Fix parsing of deleted files.

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

3 years agocompiler: create temporaries for heap variables
Ian Lance Taylor [Thu, 11 Mar 2021 03:38:21 +0000 (19:38 -0800)]
compiler: create temporaries for heap variables

The compiler generally doesn't create a temporary for an expression
that is a variable, because it's normally valid to simply reload the
value from the variable.  However, if the variable is in the heap,
then loading the value is a pointer indirection.  The process of
creating GCC IR can cause the variable load and the pointer
indirection to be split, such that the second evaluation only does the
pointer indirection.  If there are conditionals in between the two
uses, this can cause the second use to load the pointer from an
uninitialized register.

Avoid this by introducing a new Expression method that returns whether
it is safe to evaluate an expression multiple times, and use it
everywhere.

The test case is https://golang.org/cl/300789.

Fixes golang/go#44383

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

3 years agoanalyzer: new implementation of shortest feasible path [PR96374]
David Malcolm [Thu, 11 Mar 2021 22:46:37 +0000 (17:46 -0500)]
analyzer: new implementation of shortest feasible path [PR96374]

The analyzer builds an exploded graph of (point,state) pairs and when
it finds a problem, records a diagnostic at the relevant exploded node.
Once it has finished exploring the graph, the analyzer needs to generate
the shortest feasible path through the graph to each diagnostic's node.
This is used:
- for rejecting diagnostics that are infeasible (due to impossible sets
  of constraints),
- for use in determining which diagnostic to use in each deduplication
  set (the one with the shortest path), and
- for building checker_paths for the "winning" diagnostics, giving a
  list of events

Prior to this patch the analyzer simply found the shortest path to the
node, and then checked it for feasibility, which could lead to falsely
rejecting diagnostics: "the shortest path, if feasible" is not the same
as "the shortest feasible path" (PR analyzer/96374).
An example is PR analyzer/93355, where this issue causes the analyzer
to fail to emit a leak warning for a missing fclose on an error-handling
path in intl/localealias.c.

This patch implements a new algorithm for finding the shortest feasible
path to an exploded node: instead of simply finding the shortest path,
the new algorithm uses a worklist to iteratively build a tree of path
prefixes, which are feasible paths by construction, until a path to the
target node is found.  The worklist is prioritized, so that the first
feasible path discovered is the shortest possible feasible path.  The
algorithm continues trying paths until the target node is reached or a
limit is exceeded, in which case the diagnostic is treated as being
infeasible (which could still be a false negative, but is much less
likely to happen than before).  Iteratively building a tree of paths
allows for work to be reused, and the tree can be dumped in .dot form
(via a new -fdump-analyzer-feasibility option), making it much easier to
debug compared to other approaches I tried.

Doing so fixes the missing leak warning for PR analyzer/93355 and
various other test cases.

Testing:
- I manually verified that the behavior is determistic using 50 builds
  of pr93355-localealias.c.  All dumps were identical.
- I manually verified that it still builds with --disable-analyzer.
- Lightly tested with valgrind; no additional issues.
- Lightly performance tested, showing a slight speed regression to the
  analyzer relative to before the patch, but correctness for this issue
  is more important than the slight performance hit for the analyzer.

gcc/ChangeLog:
PR analyzer/96374
* Makefile.in (ANALYZER_OBJS): Add analyzer/feasible-graph.o and
analyzer/trimmed-graph.o.
* doc/analyzer.texi (Analyzer Paths): Rewrite description of
feasibility checking to reflect new implementation.
* doc/invoke.texi (-fdump-analyzer-feasibility): Document new
option.
* shortest-paths.h (shortest_paths::get_shortest_distance): New.

gcc/analyzer/ChangeLog:
PR analyzer/96374
* analyzer.opt (-param=analyzer-max-infeasible-edges=): New param.
(fdump-analyzer-feasibility): New flag.
* diagnostic-manager.cc: Include "analyzer/trimmed-graph.h" and
"analyzer/feasible-graph.h".
(epath_finder::epath_finder): Convert m_sep to a pointer and
only create it if !flag_analyzer_feasibility.
(epath_finder::~epath_finder): New.
(epath_finder::m_sep): Convert to a pointer.
(epath_finder::get_best_epath): Add param "diag_idx" and use it
when logging.  Rather than finding the shortest path and then
checking feasibility, instead use explore_feasible_paths unless
!flag_analyzer_feasibility, in which case simply use the shortest
path, and note if it is infeasible.  Update for m_sep becoming a
pointer.
(class feasible_worklist): New.
(epath_finder::explore_feasible_paths): New.
(epath_finder::process_worklist_item): New.
(class dump_eg_with_shortest_path): New.
(epath_finder::dump_trimmed_graph): New.
(epath_finder::dump_feasible_graph): New.
(saved_diagnostic::saved_diagnostic): Add "idx" param, using it
on new field m_idx.
(saved_diagnostic::to_json): Dump m_idx.
(saved_diagnostic::calc_best_epath): Pass m_idx to get_best_epath.
Remove assertion that m_problem was set when m_best_epath is NULL.
(diagnostic_manager::add_diagnostic): Pass an index when created
saved_diagnostic instances.
* diagnostic-manager.h (saved_diagnostic::saved_diagnostic): Add
"idx" param.
(saved_diagnostic::get_index): New accessor.
(saved_diagnostic::m_idx): New field.
* engine.cc (exploded_node::dump_dot): Call args.dump_extra_info.
Move code to...
(exploded_node::dump_processed_stmts): ...this new function and...
(exploded_node::dump_saved_diagnostics): ...this new function.
Add index of each diagnostic.
(exploded_edge::dump_dot):  Move bulk of code to...
(exploded_edge::dump_dot_label): ...this new function.
* exploded-graph.h (eg_traits::dump_args_t::dump_extra_info): New
vfunc.
(exploded_node::dump_processed_stmts): New decl.
(exploded_node::dump_saved_diagnostics): New decl.
(exploded_edge::dump_dot_label): New decl.
* feasible-graph.cc: New file.
* feasible-graph.h: New file.
* trimmed-graph.cc: New file.
* trimmed-graph.h: New file.

gcc/testsuite/ChangeLog:
PR analyzer/96374
* gcc.dg/analyzer/dot-output.c: Add -fdump-analyzer-feasibility
to options.
* gcc.dg/analyzer/feasibility-1.c (test_6): Remove xfail.
(test_7): New.
* gcc.dg/analyzer/pr93355-localealias-feasibility-2.c: Remove xfail.
* gcc.dg/analyzer/pr93355-localealias-feasibility-3.c: Remove xfails.
* gcc.dg/analyzer/pr93355-localealias-feasibility.c: Remove
-fno-analyzer-feasibility from options.
* gcc.dg/analyzer/pr93355-localealias.c: Likewise.
* gcc.dg/analyzer/unknown-fns-4.c: Remove xfail.

3 years agoanalyzer: support reverse direction in shortest-paths.h
David Malcolm [Thu, 11 Mar 2021 22:45:10 +0000 (17:45 -0500)]
analyzer: support reverse direction in shortest-paths.h

This patch generalizes shortest-path.h so that it can be used to
find the shortest path from each node to a given target node (on top
of the existing support for finding the shortest path from a given
origin node to each node).

I've marked this as "analyzer" as this is the only code using
shortest-paths.h.

This patch is required by followup work to fix PR analyzer/96374.

gcc/analyzer/ChangeLog:
* diagnostic-manager.cc (epath_finder::epath_finder):
Update shortest_paths init for new param.

gcc/ChangeLog:
* digraph.cc (selftest::test_shortest_paths): Update
shortest_paths init for new param.  Add test of
SPS_TO_GIVEN_TARGET.
* shortest-paths.h (enum shortest_path_sense): New.
(shortest_paths::shortest_paths): Add "sense" param.
Update for renamings.  Generalize to use "sense" param.
(shortest_paths::get_shortest_path): Rename param.
(shortest_paths::m_sense): New field.
(shortest_paths::m_prev): Rename...
(shortest_paths::m_best_edge): ...to this.
(shortest_paths::get_shortest_path): Update for renamings.
Conditionalize flipping of path on sense of traversal.

3 years agoanalyzer: gracefully handle impossible paths in shortest-paths.h
David Malcolm [Thu, 11 Mar 2021 22:43:39 +0000 (17:43 -0500)]
analyzer: gracefully handle impossible paths in shortest-paths.h

This bulletproofs the shortest_paths code against unreachable nodes,
gracefully handling them, rather than failing an assertion.

I've marked this as "analyzer" as this is the only code using
shortest-paths.h.

This patch is required by followup work to fix PR analyzer/96374.

gcc/ChangeLog:
* digraph.cc (selftest::test_shortest_paths): Add test coverage
for paths from B and C.
* shortest-paths.h (shortest_paths::shortest_paths): Handle
unreachable nodes, rather than asserting.

3 years agolibstdc++: Add a fallback 128-bit integer class type and use it
Patrick Palka [Thu, 11 Mar 2021 22:02:27 +0000 (17:02 -0500)]
libstdc++: Add a fallback 128-bit integer class type and use it

This implements a minimal integer class type that emulates 128-bit
unsigned arithmetic using a pair of 64-bit integers, which the
floating-point std::to_chars implementation then uses as a drop-in
replacement for unsigned __int128 on targets that lack the latter.
After this patch, we now fully support formatting of large long double
types on such targets.

Since Ryu performs 128-bit division/modulus only by 2, 5 and 10, this
integer class type supports only these divisors rather than general
division/modulus.

libstdc++-v3/ChangeLog:

* src/c++17/floating_to_chars.cc: Simplify the file as if
__SIZEOF_INT128__ is always defined.
[!defined __SIZEOF_INT128__]: Include "uint128_t.h".  Define
a base-10 to_chars overload for the uint128_t class type.
* src/c++17/uint128_t.h: New file.
* testsuite/20_util/to_chars/long_double.cc: No longer expect an
execution FAIL on targets that have a large long double type
but lack __int128.

3 years agolibstdc++: Remove Ryu's uint128_t aliases
Patrick Palka [Thu, 11 Mar 2021 21:59:15 +0000 (16:59 -0500)]
libstdc++: Remove Ryu's uint128_t aliases

This makes Ryu consistently use the uint128_t alias that's defined in
floating_to_chars.cc.

libstdc++-v3/ChangeLog:

* src/c++17/ryu/LOCAL_PATCHES: Update.
* src/c++17/ryu/d2s_intrinsics.h: Don't define uint128_t.
* src/c++17/ryu/generic_128.h: Likewise.
* src/c++17/ryu/ryu_generic_128.h (struct floating_decimal_128):
Use uint128_t instead of __uint128_t.
(generic_binary_to_decimal): Likewise.

3 years agolibstdc++: Add a LOCAL_PATCHES file to Ryu source directory
Patrick Palka [Thu, 11 Mar 2021 21:58:28 +0000 (16:58 -0500)]
libstdc++: Add a LOCAL_PATCHES file to Ryu source directory

This file keeps track of the local modifications we've made to our
copy of Ryu.

libstdc++-v3/ChangeLog:

* src/c++17/ryu/LOCAL_PATCHES: New file.

3 years agolibstdc++: Factor out uses of __int128 into a type alias
Patrick Palka [Thu, 11 Mar 2021 21:57:49 +0000 (16:57 -0500)]
libstdc++: Factor out uses of __int128 into a type alias

Since Ryu has the alias uint128_t for this same purpose, it seems best
for us to use this name as well, so as to minimize the amount of local
modifications we'd need to make to our copy of Ryu.  (In a subsequent
patch, we're going to remove Ryu's aliases so that it uses this one
defined in floating_to_chars.cc.)

libstdc++-v3/ChangeLog:

* src/c++17/floating_to_chars.cc (uint128_t): New conditionally
defined alias of unsigned __int128.
(floating_type_traits_binary128::mantissa_t): Use uint128_t
instead of unsigned __int128.
(floating_type_traits<long double>::mantissa_t)
[LONG_DOUBLE_KIND == LDK_IBM128]: Likewise.
(get_ieee_repr): Likewise.  Make casts from uint_t to mantissa_t
and uint32_t explicit.  Simplify the extraction of mantissa,
exponent and sign bit.

3 years agoaix: Use lcomm for TLS static data.
David Edelsohn [Thu, 11 Mar 2021 16:41:24 +0000 (11:41 -0500)]
aix: Use lcomm for TLS static data.

GCC on AIX generates thread local uninitialized data in the common section,
which could conflict with another module.

This patch changes the code generation to place static uninitialized
thread local data into the local common section specified with .lcomm.
This change also removes the need to create a file-local name for the TBSS
data.

gcc/ChangeLog:

2021-03-11  David Edelsohn  <dje.gcc@gmail.com>

PR target/99094
* config/rs6000/rs6000.c (rs6000_xcoff_file_start): Don't create
xcoff_tbss_section_name.
* config/rs6000/xcoff.h (ASM_OUTPUT_TLS_COMMON): Use .lcomm.
* xcoffout.c (xcoff_tbss_section_name): Delete.
* xcoffout.h (xcoff_tbss_section_name): Delete.

3 years agoc++: Fix unhiding friend with imports [PR 99248]
Nathan Sidwell [Thu, 11 Mar 2021 21:06:36 +0000 (13:06 -0800)]
c++: Fix unhiding friend with imports [PR 99248]

This was a simple thinko about which object held the reference to the
binding vector.  I also noticed stale code in the tree dumper, as I
recently removed the flags from a lazy number.

PR c++/99248
gcc/cp/
* name-lookup.c (lookup_elaborated_type_1): Access slot not bind
when there's a binding vector.
* ptree.c (cxx_print_xnode): Lazy flags are no longer a thing.
gcc/testsuite/
* g++.dg/modules/pr99248.h: New.
* g++.dg/modules/pr99248_a.H: New.
* g++.dg/modules/pr99248_b.H: New.

3 years agolibstdc++: Make barrier::arrival_token a move-only class type
Jonathan Wakely [Thu, 11 Mar 2021 16:57:20 +0000 (16:57 +0000)]
libstdc++: Make barrier::arrival_token a move-only class type

The standard only specifies that barrier::arrival_token is a move
constructible and move assignable type. We originally used a scoped enum
type, but that means we do not diagnose non-portable code that makes
copies of arrival tokens (or compares them for equality, or uses them as
keys in map!) This wraps the enum in a move-only class type, so that
users are forced to pass it correctly.

The move constructor and move assignment operator of the new class do
not zero out the moved-from token, as that would add additional
instructions. That means that passing a moved-from token will work with
our implementation, despite being a bug in the user code. We could
consider doing that zeroing out in debug mode.

libstdc++-v3/ChangeLog:

* include/std/barrier (barrier::arrival_token): New move-only
class that encapsulates the underlying token value.

3 years agolibstdc++: Fix find_type helper to work consistently
Jonathan Wakely [Thu, 11 Mar 2021 16:48:32 +0000 (16:48 +0000)]
libstdc++: Fix find_type helper to work consistently

The find_type helper function sometimes results in "class X::name" and
lookup for that fails. For more details see "Problem 1" in
https://gcc.gnu.org/pipermail/libstdc++/2021-March/052132.html and the
example at https://sourceware.org/bugzilla/show_bug.cgi?id=27510#c2

This patch replaces typ.unqualified() with typ.tag, which is never
qualified, and will never include the 'class' or 'struct' keywords.
Using the .tag attribute should be safe here because we know we are
looking at a class type and we've already used strip_typedefs().

libstdc++-v3/ChangeLog:

* python/libstdcxx/v6/printers.py (find_type): Use tag attribute
instead of unqualified() method.

3 years agolibstdc++: Use acq_rel memory ordering [PR 99537]
Jonathan Wakely [Thu, 11 Mar 2021 16:44:57 +0000 (16:44 +0000)]
libstdc++: Use acq_rel memory ordering [PR 99537]

As Lewis Baker wrote in the PR:

> The 'fetch_sub()' operation in _M_release_ownership() should be using
> memory_order::acq_rel instead of memory_order::release. The use of
> 'release' only is insufficient as it does not synchronise with any
> corresponding 'acquire' operation.

> With the current implementation, it's possible that a prior write to
> one of the _M_value or _M_head data-members by a thread releasing the
> second-to-last reference might not be visible to another thread that
> releases the last reference and frees the memory, resulting in
> potential write to freed memory.

This simply changes the memory order to acq_rel as suggested.

libstdc++-v3/ChangeLog:

PR libstdc++/99537
* include/std/stop_token (_Stop_state_t::_M_release_ownership):
Use acq_rel memory ordering.

3 years agolibstdc++: Handle EPERM for filesystem access errors on MacOS [PR 99537]
Jonathan Wakely [Thu, 11 Mar 2021 16:43:51 +0000 (16:43 +0000)]
libstdc++: Handle EPERM for filesystem access errors on MacOS [PR 99537]

Contrary to what POSIX says, some directory operations on MacOS can fail
with EPERM instead of EACCES, so we need to handle both.

libstdc++-v3/ChangeLog:

PR libstdc++/99537
* src/c++17/fs_dir.cc (recursive_directory_iterator): Use new
helper function to check for permission denied errors.
* src/filesystem/dir.cc (recursive_directory_iterator):
Likewise.
* src/filesystem/dir-common.h (is_permission_denied_error): New
helper function.

3 years agolibstdc++: Initialize std::normal_distribution::_M_saved [PR 99536]
Jonathan Wakely [Thu, 11 Mar 2021 16:43:51 +0000 (16:43 +0000)]
libstdc++: Initialize std::normal_distribution::_M_saved [PR 99536]

This avoids a false positive -Wmaybe-uninitialized warning, by
initializing _M_saved on construction.

libstdc++-v3/ChangeLog:

PR libstdc++/99536
* include/bits/random.h (normal_distribution): Use
default-initializer for _M_saved and _M_saved_available.

3 years agoc++: template partial instantiation mismatch [PR 99528]
Nathan Sidwell [Thu, 11 Mar 2021 13:39:11 +0000 (05:39 -0800)]
c++: template partial instantiation mismatch [PR 99528]

This turned out to be an existing problem, which had been hidden by
other bugs.  Templated members of templated classes can end up
instantiating the template itself, and we were not handling the
mergeableness of that correctly.

PR c++/99528
gcc/cp/
* module.cc (enum merge_kind): Delete MK_type_tmpl_spec,
MK_decl_tmpl_spec.
(trees_in::decl_value): Adjust add_mergeable_specialization call.
(trees_out::get_merge_kind): Adjust detecting a partial template
instantiation.
(trees_out::key_mergeable): Adjust handling same.
(trees_in::key_mergeabvle): Likewise.
gcc/testsuite/
* g++.dg/modules/pr99528.h: New.
* g++.dg/modules/pr99528_a.H: New.
* g++.dg/modules/pr99528_b.H: New.
* g++.dg/modules/pr99528_c.C: New.

3 years agoMAINTAINERS updates for ex-ImgTec employees
Jeff Law [Thu, 11 Mar 2021 16:28:50 +0000 (09:28 -0700)]
MAINTAINERS updates for ex-ImgTec employees

/
* MAINTAINERS: Update entries for a few ex-ImgTec employees

3 years agoAdd -fprofile-reproducible=parallel-runs to STAGEfeedback_CFLAGS to Makefile.tpl.
Martin Liska [Thu, 11 Mar 2021 15:17:41 +0000 (16:17 +0100)]
Add -fprofile-reproducible=parallel-runs to STAGEfeedback_CFLAGS to Makefile.tpl.

ChangeLog:

* Makefile.tpl: The change was done Makefile.in which
is generated file.

3 years agotestsuite/98245 - adjust dump scanning of gcc.dg/vect/bb-slp-46.c
Richard Biener [Thu, 11 Mar 2021 13:25:16 +0000 (14:25 +0100)]
testsuite/98245 - adjust dump scanning of gcc.dg/vect/bb-slp-46.c

Checking the number of pluses is unreliable since the vector size
isn't known.  Instead see that the unwanted scalar compute is not
there.

2021-03-11  Richard Biener  <rguenther@suse.de>

PR testsuite/98245
* gcc.dg/vect/bb-slp-46.c: Scan for the scalar compute
instead of verifying the total number of adds.

3 years agotestsuite/97494 - XFAIL gcc.dg/vect/pr97428.c on !vect_hw_misalign
Richard Biener [Thu, 11 Mar 2021 13:11:08 +0000 (14:11 +0100)]
testsuite/97494 - XFAIL gcc.dg/vect/pr97428.c on !vect_hw_misalign

While we could at least vectorize it on targets which support
re-alignment tokens we fail to do this because of imperfections in
alignment analysis.  XFAIL when the HW cannot deal with misaligned
vector accesses for now.

2021-03-11  Richard Biener  <rguenther@suse.de>

PR testsuite/97494
* gcc.dg/vect/pr97428.c: XFAIL on !vect_hw_misalign.

3 years agotestsuite/97494 - XFAIL gcc.dg/vect/vect-complex-5.c on !vect_hw_misalign
Richard Biener [Thu, 11 Mar 2021 13:03:55 +0000 (14:03 +0100)]
testsuite/97494 - XFAIL gcc.dg/vect/vect-complex-5.c on !vect_hw_misalign

This is a missed optimization due to bogus alignment analysis.

2021-03-11  Richard Biener  <rguenther@suse.de>

PR testsuite/97494
* gcc.dg/vect/vect-complex-5.c: XFAIL on !vect_hw_misalign.

3 years agotestsuite/97494 - amend gcc.dg/vect/slp-21.c
Richard Biener [Thu, 11 Mar 2021 12:30:56 +0000 (13:30 +0100)]
testsuite/97494 - amend gcc.dg/vect/slp-21.c

As reported in the PR all powerpc64 targets fail

FAIL: gcc.dg/vect/slp-21.c scan-tree-dump-times vect "vectorizing stmts using SLP" 2

because like on arm we now vectorize 4 opportunities.  This adjusts
the testcase to follow the arm example.

2021-03-11  Richard Biener  <rguenther@suse.de>

PR testsuite/97494
* gcc.dg/vect/slp-21.c: Adjust for powerpc64*-*-*.

3 years agotree-optimization/99523 - missing SSA decls in dumps
Richard Biener [Thu, 11 Mar 2021 09:09:43 +0000 (10:09 +0100)]
tree-optimization/99523 - missing SSA decls in dumps

This makes sure to dump SSA names without identifier in the
declaration part of a function dump.  While we dump the
anonymous variable decls the SSA names referencing them appear
without a clear reference as to what anonymous variable is used
(_3 vs. D.1234).

2021-03-11  Richard Biener  <rguenther@suse.de>

PR tree-optimization/99523
* tree-cfg.c (dump_function_to_file): Dump SSA names
w/o identifier to the decls section as well, not only those
without a VAR_DECL.