platform/upstream/gcc.git
2 years agoloongarch: exclude LARCH_PROLOGUE_TEMP from SIBCALL_REGS [PR 106096]
Xi Ruoyao [Tue, 28 Jun 2022 08:00:14 +0000 (16:00 +0800)]
loongarch: exclude LARCH_PROLOGUE_TEMP from SIBCALL_REGS [PR 106096]

The epilogue may clobber LARCH_PROLOGUE_TEMP ($r13/$t1), so it cannot be
used for sibcalls.

gcc/ChangeLog:

PR target/106096
* config/loongarch/loongarch.h (REG_CLASS_CONTENTS): Exclude
$r13 from SIBCALL_REGS.
* config/loongarch/loongarch.cc (loongarch_regno_to_class):
Change $r13 to JIRL_REGS.

gcc/testsuite/ChangeLog:

PR target/106096
* g++.target/loongarch/loongarch.exp: New test support file.
* g++.target/loongarch/pr106096.C: New test.

2 years agoAllow all types supported by ranger in loop-ch.
Aldy Hernandez [Mon, 27 Jun 2022 18:50:03 +0000 (20:50 +0200)]
Allow all types supported by ranger in loop-ch.

This converts the ranger use in loop-ch to allow any types allowed by
the ranger infrastructure.  Since the range of a GIMPLE_COND is always an
integer we can remove the check because the only temporary is already
an int_range.

gcc/ChangeLog:

* tree-ssa-loop-ch.cc (entry_loop_condition_is_static): Remove
irange::supports_p.

2 years agomiddle-end/106053 - fold_sign_changed_comparison and large bools
Richard Biener [Tue, 28 Jun 2022 08:50:34 +0000 (10:50 +0200)]
middle-end/106053 - fold_sign_changed_comparison and large bools

The following fixes a latent issue in the match.pd variant of
fold_sign_changed_comparison which replaces an unsigned integer
comparison with a signed boolean comparison of the same precision
despite the fact that we treat BOOLEAN_TYPEs as only having two
valid values.

2022-06-28  Richard Biener  <rguenther@suse.de>

PR middle-end/106053
* match.pd ((T)a == (T)b): Avoid folding away sign
changes in a comparison if we'd truncate to a boolean.

* gcc.target/i386/pr106053.c: New testcase.

2 years agolibgomp: fix typo in mold linker detection
Martin Liska [Tue, 28 Jun 2022 08:34:56 +0000 (10:34 +0200)]
libgomp: fix typo in mold linker detection

libgomp/ChangeLog:

* acinclude.m4: Fix typo in mold linker detection.
* Makefile.in: Regenerate.
* configure: Regenerate.

2 years agolibstdc++: testsuite: Guard use of C99 std::log2
Jonathan Wakely [Tue, 28 Jun 2022 08:17:06 +0000 (09:17 +0100)]
libstdc++: testsuite: Guard use of C99 std::log2

This prevents the test from failing if the only thing not supported is
the text printed to the log about the size of the floating-point type.

libstdc++-v3/ChangeLog:

* testsuite/20_util/from_chars/4.cc: Only use log2 if C99 math
functions are available.

2 years agoMAINTAINERS: Add myself for write after approval
konglin1 [Mon, 27 Jun 2022 09:28:10 +0000 (17:28 +0800)]
MAINTAINERS: Add myself for write after approval

ChangeLog:

* MAINTAINERS (Write After Approval): Add myself.

2 years agors6000: Simplify *rotl<mode>3_insert_4 by removing DImode
Kewen Lin [Tue, 28 Jun 2022 02:50:26 +0000 (21:50 -0500)]
rs6000: Simplify *rotl<mode>3_insert_4 by removing DImode

define_insn *rotl<mode>3_insert_4 use mode iterator GPR which
consists of SImode and conditional DImode, but the condition
of this define_insn requires the mode should be SImode.  By
further checking, it's found that the rldimi instruction can
not be used for this pattern since the required mask can not
be represented correctly.  We can have the fixed mask end 31
with rlwimi, but can not have the fixed mask end 63 with
rldimi as it has to be (63 - SH) always.

So this patch simplifies this define_insn to use SImode only.

gcc/ChangeLog:

* config/rs6000/rs6000.md (*rotl<mode>3_insert_4): Replace mode
iterator GPR with SImode, adjust the condition and output template,
rename to ...
(*rotlsi3_insert_4): ... this.

2 years agoDaily bump.
GCC Administrator [Tue, 28 Jun 2022 00:16:58 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: avoid <memory> poisoning on musl [PR106102]
Sergei Trofimovich [Mon, 27 Jun 2022 12:27:24 +0000 (13:27 +0100)]
c++: avoid <memory> poisoning on musl [PR106102]

On musl <pthread.h> uses calloc() (via <sched.h>). <memory> includes
it indirectly and exposes use of poisoned calloc() when module code
is built:

    /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc
        In file included from /<<NIX>>/musl-1.2.3-dev/include/pthread.h:30,
                 from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/x86_64-unknown-linux-musl/bits/gthr-default.h:35,
                 ....
                 from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/memory:77,
                 from ../../gcc-13-20220626/gcc/../libcody/cody.hh:24,
                 from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.h:25,
                 from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.cc:23,
                 from ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc:32:
    /<<NIX>>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc"
       84 | void *calloc(size_t, size_t);
          |       ^
    /<<NIX>>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc"
      124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
          |                                    ^

gcc/cp/

PR c++/106102
* mapper-client.cc: Include <memory> via "system.h".
* mapper-resolver.cc: Ditto.
* module.cc: Ditto.

libcc1/

PR c++/106102
* libcc1plugin.cc: Include <memory> via "system.h".
* libcp1plugin.cc: Ditto.

2 years agoAdd 'final' and 'override' in various places
David Malcolm [Mon, 27 Jun 2022 21:00:34 +0000 (17:00 -0400)]
Add 'final' and 'override' in various places

gcc/cp/ChangeLog:
* cxx-pretty-print.h: Add "final" and "override" to various vfunc
implementations, removing redundant "virtual" as appropriate.
* module.cc: Likewise.

gcc/ChangeLog:
* genmatch.cc: Add "final" and "override" to various vfunc
implementations, removing redundant "virtual" as appropriate.
* gensupport.cc: Likewise.
* gimple-range-cache.h: Likewise.
* ipa-icf-gimple.h: Likewise.
* ipa-icf.h: Likewise.
* read-md.h: Likewise.
* read-rtl-function.cc: Likewise.
* tree-ssa-loop-ch.cc: Likewise.
* tree-ssa-sccvn.cc: Likewise.

gcc/lto/ChangeLog:
* lto-dump.cc: Add "final" and "override" to various vfunc
implementations, removing redundant "virtual" as appropriate.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoi386: add 'final' and 'override' to scalar_chain vfunc impls
David Malcolm [Mon, 27 Jun 2022 21:00:34 +0000 (17:00 -0400)]
i386: add 'final' and 'override' to scalar_chain vfunc impls

gcc/ChangeLog:
* config/i386/i386-features.h: Add "final" and "override" to
scalar_chain vfunc implementations as appropriate.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agotree-switch-conversion.h: use final/override for cluster vfunc impls
David Malcolm [Mon, 27 Jun 2022 21:00:33 +0000 (17:00 -0400)]
tree-switch-conversion.h: use final/override for cluster vfunc impls

gcc/ChangeLog:
* tree-switch-conversion.h: Add "final" and "override" to cluster
vfunc implementations as appropriate.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoexpr.cc: use final/override on op_by_pieces_d vfuncs
David Malcolm [Mon, 27 Jun 2022 21:00:33 +0000 (17:00 -0400)]
expr.cc: use final/override on op_by_pieces_d vfuncs

gcc/ChangeLog:
* expr.cc: Add "final" and "override" to op_by_pieces_d vfunc
implementations as appropriate.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoAdd 'final' and 'override' on dom_walker vfunc impls
David Malcolm [Mon, 27 Jun 2022 21:00:33 +0000 (17:00 -0400)]
Add 'final' and 'override' on dom_walker vfunc impls

gcc/ChangeLog:
* compare-elim.cc: Add "final" and "override" to dom_walker vfunc
implementations, removing redundant "virtual" as appropriate.
* gimple-ssa-strength-reduction.cc: Likewise.
* ipa-prop.cc: Likewise.
* rtl-ssa/blocks.cc: Likewise.
* tree-into-ssa.cc: Likewise.
* tree-ssa-dom.cc: Likewise.
* tree-ssa-math-opts.cc: Likewise.
* tree-ssa-phiopt.cc: Likewise.
* tree-ssa-propagate.cc: Likewise.
* tree-ssa-sccvn.cc: Likewise.
* tree-ssa-strlen.cc: Likewise.
* tree-ssa-uncprop.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoAdd 'final' and 'override' to opt_pass vfunc impls
David Malcolm [Mon, 27 Jun 2022 21:00:33 +0000 (17:00 -0400)]
Add 'final' and 'override' to opt_pass vfunc impls

gcc/ChangeLog:
* adjust-alignment.cc: Add "final" and "override" to opt_pass
vfunc implementations, removing redundant "virtual" as
appropriate.
* asan.cc: Likewise.
* auto-inc-dec.cc: Likewise.
* auto-profile.cc: Likewise.
* bb-reorder.cc: Likewise.
* cfgcleanup.cc: Likewise.
* cfgexpand.cc: Likewise.
* cfgrtl.cc: Likewise.
* cgraphbuild.cc: Likewise.
* combine-stack-adj.cc: Likewise.
* combine.cc: Likewise.
* compare-elim.cc: Likewise.
* config/i386/i386-features.cc: Likewise.
* coroutine-passes.cc: Likewise.
* cprop.cc: Likewise.
* cse.cc: Likewise.
* dce.cc: Likewise.
* df-core.cc: Likewise.
* dse.cc: Likewise.
* dwarf2cfi.cc: Likewise.
* early-remat.cc: Likewise.
* except.cc: Likewise.
* final.cc: Likewise.
* function.cc: Likewise.
* fwprop.cc: Likewise.
* gcse.cc: Likewise.
* gimple-harden-conditionals.cc: Likewise.
* gimple-if-to-switch.cc: Likewise.
* gimple-isel.cc: Likewise.
* gimple-laddress.cc: Likewise.
* gimple-loop-interchange.cc: Likewise.
* gimple-loop-jam.cc: Likewise.
* gimple-loop-versioning.cc: Likewise.
* gimple-low.cc: Likewise.
* gimple-ssa-backprop.cc: Likewise.
* gimple-ssa-evrp.cc: Likewise.
* gimple-ssa-isolate-paths.cc: Likewise.
* gimple-ssa-nonnull-compare.cc: Likewise.
* gimple-ssa-split-paths.cc: Likewise.
* gimple-ssa-store-merging.cc: Likewise.
* gimple-ssa-strength-reduction.cc: Likewise.
* gimple-ssa-warn-access.cc: Likewise.
* gimple-ssa-warn-alloca.cc: Likewise.
* gimple-ssa-warn-restrict.cc: Likewise.
* gimple-warn-recursion.cc: Likewise.
* graphite.cc: Likewise.
* ifcvt.cc: Likewise.
* init-regs.cc: Likewise.
* ipa-comdats.cc: Likewise.
* ipa-cp.cc: Likewise.
* ipa-devirt.cc: Likewise.
* ipa-fnsummary.cc: Likewise.
* ipa-free-lang-data.cc: Likewise.
* ipa-icf.cc: Likewise.
* ipa-inline.cc: Likewise.
* ipa-modref.cc: Likewise.
* ipa-profile.cc: Likewise.
* ipa-pure-const.cc: Likewise.
* ipa-reference.cc: Likewise.
* ipa-split.cc: Likewise.
* ipa-sra.cc: Likewise.
* ipa-visibility.cc: Likewise.
* ipa.cc: Likewise.
* ira.cc: Likewise.
* jump.cc: Likewise.
* loop-init.cc: Likewise.
* lower-subreg.cc: Likewise.
* mode-switching.cc: Likewise.
* modulo-sched.cc: Likewise.
* multiple_target.cc: Likewise.
* omp-expand.cc: Likewise.
* omp-low.cc: Likewise.
* omp-oacc-kernels-decompose.cc: Likewise.
* omp-oacc-neuter-broadcast.cc: Likewise.
* omp-offload.cc: Likewise.
* omp-simd-clone.cc: Likewise.
* passes.cc: Likewise.
* postreload-gcse.cc: Likewise.
* postreload.cc: Likewise.
* predict.cc: Likewise.
* recog.cc: Likewise.
* ree.cc: Likewise.
* reg-stack.cc: Likewise.
* regcprop.cc: Likewise.
* reginfo.cc: Likewise.
* regrename.cc: Likewise.
* reorg.cc: Likewise.
* sancov.cc: Likewise.
* sanopt.cc: Likewise.
* sched-rgn.cc: Likewise.
* stack-ptr-mod.cc: Likewise.
* store-motion.cc: Likewise.
* tracer.cc: Likewise.
* trans-mem.cc: Likewise.
* tree-call-cdce.cc: Likewise.
* tree-cfg.cc: Likewise.
* tree-cfgcleanup.cc: Likewise.
* tree-complex.cc: Likewise.
* tree-eh.cc: Likewise.
* tree-emutls.cc: Likewise.
* tree-if-conv.cc: Likewise.
* tree-into-ssa.cc: Likewise.
* tree-loop-distribution.cc: Likewise.
* tree-nrv.cc: Likewise.
* tree-object-size.cc: Likewise.
* tree-parloops.cc: Likewise.
* tree-predcom.cc: Likewise.
* tree-profile.cc: Likewise.
* tree-sra.cc: Likewise.
* tree-ssa-ccp.cc: Likewise.
* tree-ssa-copy.cc: Likewise.
* tree-ssa-dce.cc: Likewise.
* tree-ssa-dom.cc: Likewise.
* tree-ssa-dse.cc: Likewise.
* tree-ssa-forwprop.cc: Likewise.
* tree-ssa-ifcombine.cc: Likewise.
* tree-ssa-loop-ch.cc: Likewise.
* tree-ssa-loop-im.cc: Likewise.
* tree-ssa-loop-ivcanon.cc: Likewise.
* tree-ssa-loop-prefetch.cc: Likewise.
* tree-ssa-loop-split.cc: Likewise.
* tree-ssa-loop-unswitch.cc: Likewise.
* tree-ssa-loop.cc: Likewise.
* tree-ssa-math-opts.cc: Likewise.
* tree-ssa-phiopt.cc: Likewise.
* tree-ssa-phiprop.cc: Likewise.
* tree-ssa-pre.cc: Likewise.
* tree-ssa-reassoc.cc: Likewise.
* tree-ssa-sccvn.cc: Likewise.
* tree-ssa-sink.cc: Likewise.
* tree-ssa-strlen.cc: Likewise.
* tree-ssa-structalias.cc: Likewise.
* tree-ssa-uncprop.cc: Likewise.
* tree-ssa-uninit.cc: Likewise.
* tree-ssanames.cc: Likewise.
* tree-stdarg.cc: Likewise.
* tree-switch-conversion.cc: Likewise.
* tree-tailcall.cc: Likewise.
* tree-vect-generic.cc: Likewise.
* tree-vectorizer.cc: Likewise.
* tree-vrp.cc: Likewise.
* tsan.cc: Likewise.
* ubsan.cc: Likewise.
* var-tracking.cc: Likewise.
* vtable-verify.cc: Likewise.
* web.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agolibbacktrace: replace fgrep with grep in configure script
Ian Lance Taylor [Mon, 27 Jun 2022 19:57:23 +0000 (12:57 -0700)]
libbacktrace: replace fgrep with grep in configure script

Patch by Xi Ruoyao.

* configure.ac: Use grep instead of fgrep.
* configure, Makefile.in: Regenerate.

2 years agoc++: Add fixed test [PR89197]
Marek Polacek [Mon, 27 Jun 2022 18:52:58 +0000 (14:52 -0400)]
c++: Add fixed test [PR89197]

Fixed since bug 97899 was fixed.

PR c++/89197

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/initlist130.C: New test.

2 years agocompiler: don't use sink as parameter in method expression thunk
Ian Lance Taylor [Mon, 27 Jun 2022 04:52:35 +0000 (21:52 -0700)]
compiler: don't use sink as parameter in method expression thunk

Also fix a couple of cases where the error led to a later compiler crash.

Test case is https://go.dev/cl/414336.

Fixes golang/go#52871

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

2 years agocompiler: always initialize mpfr in integer import
Ian Lance Taylor [Sat, 25 Jun 2022 00:18:15 +0000 (17:18 -0700)]
compiler: always initialize mpfr in integer import

Test case is https://go.dev/cl/413980.

Fixes golang/go#52862

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

2 years agoamdgcn: test global constructors
Andrew Stubbs [Wed, 22 Jun 2022 13:42:06 +0000 (14:42 +0100)]
amdgcn: test global constructors

The tests are disabled for historical reasons only.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp (check_effective_target_global_constructor):
Remove amdgcn.

2 years agotestsuite: Fix up pr106070.c test [PR106070]
Jakub Jelinek [Mon, 27 Jun 2022 13:35:25 +0000 (15:35 +0200)]
testsuite: Fix up pr106070.c test [PR106070]

The test FAILs on 32-bit targets, because when unsigned long
is 32-bit, (unsigned long) -1 isn't 0xffffffffffffffff.
The options to fix this would be either using -1UL, or switch
to unsigned long long and using -1ULL, I chose the latter because
the test then FAILs in r13-1242 even on 32-bit targets.
And while at it, some deobfuscation and formatting tweaks.

2022-06-27  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/106070
* gcc.dg/torture/pr106070.c: Use unsigned long long instead of
unsigned long and -1ULL instead of 0xffffffffffffffff, deobcuscate
and improve formatting.

2 years agolibstdc++: testsuite: use cmath long double overloads
Alexandre Oliva [Mon, 27 Jun 2022 13:34:19 +0000 (10:34 -0300)]
libstdc++: testsuite: use cmath long double overloads

In case we need to supplement the C standard library with additional
definitions for float and long double, the declarations expected to be
in the C headers may not be there.  Rely on the cmath overloads
instead.

for  libstdc++-v3/ChangeLog

* testsuite/20_util/to_chars/long_double.cc: Use cmath
long double overloads for nexttoward and ldexp.

2 years agolibstdc++: testsuite: require cmath for exp simd
Alexandre Oliva [Mon, 27 Jun 2022 13:34:19 +0000 (10:34 -0300)]
libstdc++: testsuite: require cmath for exp simd

simd_math.h assumes declarations for many C99 functions to be present,
that libstdc++ doesn't add to target systems that don't have them in
the C library.

Add the C99 math requirement to tests for simd features, so that they
don't fail because of limitations of the target C library.

for  libstdc++-v3/ChangeLog

* testsuite/experimental/simd/standard_abi_usable.cc: Require
cmath support.
* testsuite/experimental/simd/standard_abi_usable_2.cc:
Likewise.

2 years agolibstdc++: testsuite: complex proj requirements
Alexandre Oliva [Mon, 27 Jun 2022 13:34:18 +0000 (10:34 -0300)]
libstdc++: testsuite: complex proj requirements

The template version of complex::proj returns its argument without
testing for infinities, and that's all we have when neither C99
complex nor C99 math functions are available, and it seems too hard to
do better without isinf and copysign.

I suppose just calling them and expecting users will supply
specializations as needed has been ruled out, and so has refraining
from defining it when it can't be implemented correctly.

It's pointless to run the proj.cc test under these circumstances, so
arrange for it to be skipped.  In an unusual way, after trying to
introduce dg-require tests for ccomplex-or-cmath, and found their
results to be misleading due to variations across -std=* versions.

for  libstdc++-v3/ChangeLog

* testsuite/26_numerics/complex/proj.cc: Skip test in the
circumstances in which the implementation of proj is known to
be broken.

2 years agotestsuite: pthread: call sched_yield for non-preemptive targets
Alexandre Oliva [Mon, 27 Jun 2022 13:34:17 +0000 (10:34 -0300)]
testsuite: pthread: call sched_yield for non-preemptive targets

Systems without preemptive multi-threading require sched_yield calls
to be placed at points in which a context switch might be needed to
enable the test to complete.

for  gcc/testsuite/ChangeLog

* gcc.dg/atomic/c11-atomic-exec-4.c: Call sched_yield.
* gcc.dg/atomic/c11-atomic-exec-5.c: Likewise.
* gcc.dg/atomic/pr80640-2.c: Likewise.
* gcc.dg/atomic/pr80640.c: Likewise.
* gcc.dg/atomic/pr81316.c: Likewise.
* gcc.dg/di-sync-multithread.c: Likewise.

2 years agolibstdc++: check for openat with dirfd in std::filesystem
Alexandre Oliva [Mon, 27 Jun 2022 13:34:16 +0000 (10:34 -0300)]
libstdc++: check for openat with dirfd in std::filesystem

In the recent patch to check for openat, I missed an occurrence of
dirfd in std::filesystem.

for  libstdc++-v3/ChangeLog

* src/c++17/fs_dir.cc (dir_and_pathname): Use dirfd if
_GLIBCXX_HAVE_OPENAT.

2 years agolibstdc++: testsuite: conditionalize another symlink test
Alexandre Oliva [Mon, 27 Jun 2022 13:34:15 +0000 (10:34 -0300)]
libstdc++: testsuite: conditionalize another symlink test

In the recent patch that introduced NO_SYMLINKS, I missed one of the
testcases that created symlinks.

for  libstdc++-v3/ChangeLog

* testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc
(test06): Don't create symlinks when NO_SYMLINKS is defined.

2 years agolibstdc++: xfail experimental/net tests on rtems
Alexandre Oliva [Mon, 27 Jun 2022 13:34:14 +0000 (10:34 -0300)]
libstdc++: xfail experimental/net tests on rtems

Some net/timer/waitable tests fail on rtems because poll() is not
available.

The above, as well as net/internet/resolver/ops tests and
net/timer/waitable/cons.cc, will fail early at runtime unless mkfifo
is enabled in the RTEMS configuration, because the io_context ctor
throws when pipe() fails.

However, even enabling pipes and adjusting the net_ts link command to
use --gc-sections for -lbsd as recommended, both
net/internet/resolver/ops still fail at runtime.

for  libstdc++-v3/ChangeLog

* testsuite/lib/dg-options.exp (add_options_for_net_ts):
Add -Wl,--gc-sections for RTEMS targets.
* testsuite/experimental/net/timer/waitable/dest.cc: Link-time
xfail on RTEMS.
* testsuite/experimental/net/timer/waitable/ops.cc: Likewise.
* testsuite/experimental/net/internet/resolver/ops/lookup.cc:
Execution-time xfail on RTEMS.
* testsuite/experimental/net/internet/resolver/ops/reverse.cc:
Likewise.

2 years agoamdgcn: remove obsolete assembler workarounds
Andrew Stubbs [Sat, 11 Jun 2022 23:16:24 +0000 (00:16 +0100)]
amdgcn: remove obsolete assembler workarounds

This nonsense is no longer required, now that the minimum supported
assembler version is LLVM 13.0.1.

gcc/ChangeLog:

* config/gcn/gcn.md (*movbi): Remove assembler bug workarounds.
(jump): Likewise.
(movdi_symbol_save_scc): Likewise.

2 years agolibstdc++: testsuite: Add missing <string> header
Jonathan Wakely [Fri, 24 Jun 2022 14:13:12 +0000 (15:13 +0100)]
libstdc++: testsuite: Add missing <string> header

libstdc++-v3/ChangeLog:

* testsuite/ext/mt_allocator/22309_thread.cc: Include <string>.

2 years agolibstdc++: testsuite: avoid predicable mkstemp
Joel Brobecker [Thu, 23 Jun 2022 12:12:12 +0000 (13:12 +0100)]
libstdc++: testsuite: avoid predicable mkstemp

We have noticed that, on RTEMS, a small number of testscases are
failing because two calls to this method return the same filename.
This happens for instance in 27_io/filesystem/operations/copy_file.cc
where it does:

  auto from = __gnu_test::nonexistent_path();
  auto to = __gnu_test::nonexistent_path();

We tracked this issue down to the fact that the implementation of
mkstemp on that system appears to use a very predictable algorithm
for chosing the name of the temporary file, where the same filename
appears to be tried in the same order, regardless of past calls.
So, as long as the file gets deleted after a call to mkstemp (something
we do here in our nonexistent_path method), the next call to mkstemps
ends up returning the same filename, causing the collision we se above.

This commit enhances the __gnu_test::nonexistent_path method to
introduce in the filename being returned a counter which gets
incremented at every call of this method.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* testsuite/util/testsuite_fs.h (__gnu_test::nonexistent_path):
Always include a counter in the filename returned.

2 years agolibstdc++: Make std::move_only_function never valueless in std::variant
Jonathan Wakely [Thu, 23 Jun 2022 17:42:55 +0000 (18:42 +0100)]
libstdc++: Make std::move_only_function never valueless in std::variant

This is not suitable to backport, as it affects the ABI of std::variant
and so isn't appropriate for a release branch.

libstdc++-v3/ChangeLog:

* include/bits/move_only_function.h (_Never_valueless_alt):
Define partial specialization for std::move_only_function.

2 years agolibstdc++: Simplify std::variant construction using variable templates
Jonathan Wakely [Thu, 23 Jun 2022 17:41:17 +0000 (18:41 +0100)]
libstdc++: Simplify std::variant construction using variable templates

libstdc++-v3/ChangeLog:

* include/std/variant (_Build_FUN::_S_fun): Define fallback case
as deleted.
(__accepted_index, _Extra_visit_slot_needed): Replace class
templates with variable templates.

2 years agolibstdc++: Simplify fs::path construction using variable template
Jonathan Wakely [Thu, 23 Jun 2022 17:39:50 +0000 (18:39 +0100)]
libstdc++: Simplify fs::path construction using variable template

libstdc++-v3/ChangeLog:

* include/bits/fs_path.h (__is_path_iter_src): Replace class
template with variable template.

2 years agolibstdc++: Invert relationship between std::is_clock and std::is_clock_v
Jonathan Wakely [Thu, 23 Jun 2022 17:17:30 +0000 (18:17 +0100)]
libstdc++: Invert relationship between std::is_clock and std::is_clock_v

This redefines std::is_clock in terms of std::is_clock_v, instead of the
other way around. This avoids instantiatng the class template for code
that only uses the variable template.

libstdc++-v3/ChangeLog:

* include/bits/chrono.h (is_clock_v): Define to false.
(is_clock_v<T>): Define partial specialization for true cases.
(is_clock): Define in terms of is_clock_v.

2 years ago[gdb/build] Fix gdbserver build with -fsanitize=thread
Tom de Vries [Mon, 27 Jun 2022 08:46:58 +0000 (10:46 +0200)]
[gdb/build] Fix gdbserver build with -fsanitize=thread

When building gdbserver with -fsanitize=thread (added to CFLAGS/CXXFLAGS) we
run into:
...
ld: ../libiberty/libiberty.a(safe-ctype.o): warning: relocation against \
  `__tsan_init' in read-only section `.text'
ld: ../libiberty/libiberty.a(safe-ctype.o): relocation R_X86_64_PC32 \
  against symbol `__tsan_init' can not be used when making a shared object; \
  recompile with -fPIC
ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[1]: *** [libinproctrace.so] Error 1
...
which looks similar to what is described in commit 78e49486944 ("[gdb/build]
Fix gdbserver build with -fsanitize=address").

The gdbserver component builds a shared library libinproctrace.so, which uses
libiberty and therefore requires the pic variant.  The gdbserver Makefile is
setup to use this variant, if available, but it's not there.

Fix this by listing gdbserver in the toplevel configure alongside libcc1, as a
component that needs the libiberty pic variant, setting:
...
extra_host_libiberty_configure_flags=--enable-shared
...

Tested on x86_64-linux.

ChangeLog:

2022-06-27  Tom de Vries  <tdevries@suse.de>

* configure.ac: Build libiberty pic variant for gdbserver.
* configure: Regenerate.

2 years agolto-plugin: make claim_file_handler thread-safe
Martin Liska [Mon, 16 May 2022 12:18:41 +0000 (14:18 +0200)]
lto-plugin: make claim_file_handler thread-safe

lto-plugin/ChangeLog:

* lto-plugin.c (plugin_lock): New lock.
(claim_file_handler): Use mutex for critical section.
(onload): Initialize mutex.
* configure.ac: Check for pthread.h.
* configure: Regenerate.
* config.h.in: Regenerate.

2 years agoImplement __imag__ of float _Complex using shufps on x86_64.
Roger Sayle [Mon, 27 Jun 2022 06:47:40 +0000 (07:47 +0100)]
Implement __imag__ of float _Complex using shufps on x86_64.

This patch is a follow-up improvement to my recent patch for
PR rtl-optimization/7061.  That patch added the test case
gcc.target/i386/pr7061-2.c:

float im(float _Complex a) { return __imag__ a; }

For which GCC on x86_64 currently generates:

        movq    %xmm0, %rax
        shrq    $32, %rax
        movd    %eax, %xmm0
        ret

but with this patch we now generate (the same as LLVM):

        shufps  $85, %xmm0, %xmm0
        ret

This is achieved by providing a define_insn_and_split that allows
truncated lshiftrt:DI by 32 to be performed on either SSE or general
regs, where if the register allocator prefers to use SSE, we split
to a shufps_v4si, or if not, we use a regular shrq.

2022-06-27  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR rtl-optimization/7061
* config/i386/i386.md (*highpartdisi2): New define_insn_and_split.

gcc/testsuite/ChangeLog
PR rtl-optimization/7061
* gcc.target/i386/pr7061-2.c: Update to look for shufps.

2 years ago[PATCH] PR tree-optimization/94026: Simplify (X>>8)&6 != 0 as X&1536 != 0.
Roger Sayle [Mon, 27 Jun 2022 06:44:49 +0000 (07:44 +0100)]
[PATCH] PR tree-optimization/94026: Simplify (X>>8)&6 != 0 as X&1536 != 0.

This patch implements the missed optimization described in PR 94026,
where a the shift can be eliminated from the sequence of a shift,
followed by a bit-wise AND followed by an equality/inequality test.
Specifically, ((X << C1) & C2) cmp C3 into (X & (C2 >> C1)) cmp (C3 >> C1)
and likewise ((X >> C1) & C2) cmp C3 into (X & (C2 << C1)) cmp (C3 << C1)
where cmp is == or !=, and C1, C2 and C3 are integer constants.
The example in the subject line is taken from the hot function
self_atari from the Go program Leela (in SPEC CPU 2017).

2022-06-27  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR tree-optimization/94026
* match.pd (((X << C1) & C2) eq/ne C3): New simplification.
(((X >> C1) & C2) eq/ne C3): Likewise.

gcc/testsuite/ChangeLog
PR tree-optimization/94026
* gcc.dg/pr94026.c: New test case.

2 years agoEmit asmname if set for decl with -fdump-statistics-asmname.
Prathamesh Kulkarni [Mon, 27 Jun 2022 06:25:45 +0000 (11:55 +0530)]
Emit asmname if set for decl with -fdump-statistics-asmname.

gcc/ChangeLog:

* statistics.cc: Include tree.h.
(get_function_name): New function.
(statistics_fini_pass_2): Call get_function_name instead of
current_function_name.
(statistics_counter_event): Call get_function_name instead of
function_name.
(statistics_histogram_event): Likewise.

2 years agoxtensa: Optimize integer constant addition that is between -32896 and 32639
Takayuki 'January June' Suwa [Sun, 26 Jun 2022 13:28:30 +0000 (22:28 +0900)]
xtensa: Optimize integer constant addition that is between -32896 and 32639

Such constants are often subject to the constant synthesis:

    int test(int a) {
      return a - 31999;
    }

    test:
movi a3, 1
addmi a3, a3, -0x7d00
add a2, a2, a3
ret

This patch optimizes such case as follows:

    test:
addi a2, a2, 1
addmi a2, a2, -0x7d00
ret

gcc/ChangeLog:

* config/xtensa/xtensa.md:
Suppress unnecessary emitting nop insn in the split patterns for
integer/FP constant synthesis, and add new peephole2 pattern that
folds such synthesized additions.

2 years agoDaily bump.
GCC Administrator [Mon, 27 Jun 2022 00:16:20 +0000 (00:16 +0000)]
Daily bump.

2 years agoFortran: fix simplification of INDEX(str1,str2) [PR105691]
Harald Anlauf [Tue, 21 Jun 2022 21:20:18 +0000 (23:20 +0200)]
Fortran: fix simplification of INDEX(str1,str2) [PR105691]

gcc/fortran/ChangeLog:

PR fortran/105691
* simplify.cc (gfc_simplify_index): Replace old simplification
code by the equivalent of the runtime library implementation.  Use
HOST_WIDE_INT instead of int for string index, length variables.

gcc/testsuite/ChangeLog:

PR fortran/105691
* gfortran.dg/index_6.f90: New test.

2 years agoFortran: handle explicit-shape specs with constant bounds [PR105954]
Harald Anlauf [Mon, 20 Jun 2022 18:59:55 +0000 (20:59 +0200)]
Fortran: handle explicit-shape specs with constant bounds [PR105954]

gcc/fortran/ChangeLog:

PR fortran/105954
* decl.cc (variable_decl): Adjust upper bounds for explicit-shape
specs with constant bound expressions to ensure non-negative
extents.

gcc/testsuite/ChangeLog:

PR fortran/105954
* gfortran.dg/pr105954.f90: New test.

2 years ago[PATCH] testsuite: constraint some of fp tests to hard_float
Vineet Gupta [Sun, 26 Jun 2022 19:03:52 +0000 (15:03 -0400)]
[PATCH] testsuite: constraint some of fp tests to hard_float

These tests validate fp conversions with various rounding modes which
would not work on soft-float ABIs.

On -march=rv64imac/-mabi=lp64 this reduces 5 unique failures (overall 35
due to multi flag combination builds)

gcc/testsuite/Changelog:
* gcc.dg/torture/fp-double-convert-float-1.c: Add
dg-require-effective-target hard_float.
* gcc.dg/torture/fp-int-convert-timode-3.c: Ditto.
* gcc.dg/torture/fp-int-convert-timode-4.c: Ditto.
* gcc.dg/torture/fp-uint64-convert-double-1.c: Ditto.
* gcc.dg/torture/fp-uint64-convert-double-2.c: Ditto.

2 years agoMake it easier to rebuild configure files.
Simon Marchi [Sun, 26 Jun 2022 18:43:33 +0000 (14:43 -0400)]
Make it easier to rebuild configure files.

Add

  AC_CONFIG_MACRO_DIRS([../config])

So that just running:

  $ autoreconf -vf

... does the right thing (no need to specify -I ../config).

Note: I don't have access to the gcc repo, so if this patch is approved,
can somebody push it there on my behalf?  I can push it to binutils-gdb.

libiberty/ChangeLog:

* configure.ac: Add AC_CONFIG_MACRO_DIRS call.
* configure: Re-generate.

2 years agolibcpp: Update cpp_wcwidth() to Unicode 14.0.0
Lewis Hyatt [Sun, 26 Jun 2022 18:13:26 +0000 (14:13 -0400)]
libcpp: Update cpp_wcwidth() to Unicode 14.0.0

The procedure detailed in contrib/unicode/README was followed with nothing
notable coming up. The glibc scripts did not require any update, so the
only change was retrieving new versions of the Unicode data files and
rerunning gen_wcwidth.py.

contrib/ChangeLog:

* unicode/EastAsianWidth.txt: Update to Unicode 14.0.0.
* unicode/PropList.txt: Likewise.
* unicode/README: Likewise.
* unicode/UnicodeData.txt: Likewise.

libcpp/ChangeLog:

* generated_cpp_wcwidth.h: Generated from updated Unicode data files.

2 years agotestsuite: Adjust btf-bitfields-1.c for default_packed
Dimitar Dimitrov [Fri, 22 Apr 2022 17:27:22 +0000 (20:27 +0300)]
testsuite: Adjust btf-bitfields-1.c for default_packed

If target packs structures by default, the bitfield offset which the
test validates must be adjusted to not include padding.

gcc/testsuite/ChangeLog:

* gcc.dg/debug/btf/btf-bitfields-1.c: Adjust the checked offsets
for targets which pack structures by default.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2 years agoXFAIL a test in g++.dg/warn/Wstringop-overflow-4.C
Aldy Hernandez [Sun, 26 Jun 2022 15:30:18 +0000 (17:30 +0200)]
XFAIL a test in g++.dg/warn/Wstringop-overflow-4.C

As per the explanation in the test, and in the DOM conversion to
ranger patch, this is a known regression.  I had mentioned I would
XFAIL this test, but forgot to do so.  There is an analysis in the
test itself as to what is going on.

Tested on x86-64 Linux.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wstringop-overflow-4.C: XFAIL a test.

2 years agoconfigure, Darwin: Correct a pasto in host-shared processing.
Iain Sandoe [Sun, 26 Jun 2022 08:24:28 +0000 (09:24 +0100)]
configure, Darwin: Correct a pasto in host-shared processing.

We do, of course, mean $host not $target in this case.  Corrected thus.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
ChangeLog:

* configure: Regenerate.
* configure.ac: Correct use of $host.

2 years agoDaily bump.
GCC Administrator [Sun, 26 Jun 2022 00:16:33 +0000 (00:16 +0000)]
Daily bump.

2 years agoConvert DOM to use Ranger rather than EVRP
Aldy Hernandez [Sat, 25 Jun 2022 22:58:02 +0000 (18:58 -0400)]
Convert DOM to use Ranger rather than EVRP

[Jeff, this is the same patch I sent you last week with minor tweaks
to the commit message.]

[Despite the verbosity of the message, this is actually a pretty
straightforward patch.  It should've gone in last cycle, but there
was a nagging regression I couldn't get to until after stage1
had closed.]

There are 3 uses of EVRP in DOM that must be converted.
Unfortunately, they need to be converted in one go, so further
splitting of this patch would be problematic.

There's nothing here earth shattering.  It's all pretty obvious in
retrospect, but I've added a short description of each use to aid in
reviewing:

* Convert evrp use in cprop to ranger.

  This is easy, as cprop in DOM was converted to the ranger API last
  cycle, so this is just a matter of using a ranger instead of an
  evrp_range_analyzer.

* Convert evrp use in threader to ranger.

  The idea here is to use the hybrid approach we used for the initial
  VRP threader conversion last cycle.  The DOM threader will continue
  using the forward threader infrastructure while continuing to query
  DOM data structures, and only if the conditional does not relsolve,
  using the ranger.  This gives us the best of both worlds, and is a
  proven approach.

  Furthermore, as frange and prange come live in the next cycle, we
  can move away from the forward threader altogether, and just add
  another backward threader.  This will not only remove the last use
  of the forward threader, but will allow us to remove at least 1 or 2
  threader instances.

* Convert conditional folding to use the method used by the ranger and
  evrp.  Previously DOM was calling into the guts of
  simplify_using_ranges::vrp_visit_cond_stmt.  The blessed way now is
  using fold_cond() which rewrites the conditional and edges
  automatically.

  When legacy is removed, simplify_using_ranges will be further
  cleaned up, and there will only be one entry point into simplifying
  a statement.

* DOM was setting global ranges determined from unreachable edges as a
  side-effect of using the evrp engine.  We must handle these cases
  before nuking evrp, and DOM seems like a good fit.  I've just moved
  the snippet to DOM, but it could live anywhere else we do a DOM
  walk.

  For the record, this is the case *vrp handled:

<bb C>:
...
if (c_5(D) != 5)
goto <bb N>;
else
goto <bb M>;
<bb N>:
__builtin_unreachable ();
<bb M>:

  If M dominates all uses of c_5, we can set the global range of c_5
  to [5,5].

I have tested on x86-64, pcc64le, and aarch64 Linux.

I also ran threading benchmarks as well as performance benchmarks.

DOM threads 1.56% more paths which ultimately yields a miniscule total
increase of 0.03%.

The conversion to ranger brings a 7.87% performance drop in DOM, which
is a wash in overall compilation.  This is in line with other
replacements of legacy evrp with ranger.  We handle a lot more cases.
It's not free .

There is a a regression on Wstringop-overflow-4.C which I'm planning
on XFAILing.  It's another variant of the usual middle-end false
positives: having no ranges produces no warnings, but slightly refined
ranges, or worse-- isolating specific problematic cases in the
threader causes flare-ups.

As an aside, as Richi has suggested, I think we should discuss
restricting the threader's ability to thread highly unlikely paths.
These cause no end of pain for middle-end warnings.  However,
I don't know if this would conflict with path isolation for
things like null dereferencing.  ISTR you were interested in this.

BTW, I think the Wstringop-overflow-4.C test is problematic and I've
attached my analysis.  Basically the regression is caused by a bad
interaction with the rounding/alignment that placement new has inlined
into the IL.  This happens for int16_r[] which the test is testing.
Ranger can glean some range info, which causes DOM threading to
isolate a path which causes a warning.

OK for trunk?

gcc/ChangeLog:

* tree-ssa-dom.cc (dom_jt_state): Pass ranger to constructor
instead of evrp.
(dom_jt_state::push): Remove m_evrp.
(dom_jt_state::pop): Same.
(dom_jt_state::record_ranges_from_stmt): Remove.
(dom_jt_state::register_equiv): Remove updating of evrp ranges.
(class dom_jt_simplifier): Pass ranger to constructor.
Inherit from hybrid_jt_simplifier.
(dom_jt_simplifier::simplify): Convert to ranger.
(pass_dominator::execute): Same.
(all_uses_feed_or_dominated_by_stmt): New.
(dom_opt_dom_walker::set_global_ranges_from_unreachable_edges): New.
(dom_opt_dom_walker::before_dom_children): Call
set_global_ranges_from_unreachable_edges.
Do not call record_ranges_from_stmt.
(dom_opt_dom_walker::after_dom_children): Remove evrp use.
(cprop_operand): Use int_range<> instead of value_range.
(dom_opt_dom_walker::fold_cond): New.
(dom_opt_dom_walker::optimize_stmt): Pass ranger to
cprop_into_stmt.
Use fold_cond() instead of vrp_visit_cond_stmt().
* tree-ssa-threadedge.cc (jt_state::register_equivs_stmt): Do not
pass state to simplifier.
* vr-values.h (class vr_values): Make fold_cond public.

gcc/testsuite/ChangeLog:

* gcc.dg/sancov/cmp0.c: Adjust for conversion to ranger.
* gcc.dg/tree-ssa/ssa-dom-branch-1.c: Same.
* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Same.
* gcc.dg/vect/bb-slp-pr81635-2.c: Same.
* gcc.dg/vect/bb-slp-pr81635-4.c: Same.
* g++.dg/warn/Wstringop-overflow-4.C: Likewise.
* gcc.target/mips/data-sym-multi-pool.c: Likewise.
* gcc.target/mips/mips.exp: Likewise.

2 years agoRemove long deprecated tilegx and tilepro ports
Jeff Law [Sat, 25 Jun 2022 16:36:55 +0000 (12:36 -0400)]
Remove long deprecated tilegx and tilepro ports

/
* MAINTAINERS: Remove tilegx and tilepro entries.
* configure.ac: Remove tilegx and tilepro stanzas.
* configure: Rebuilt.

contrib/
* config-list.mk: Remove tilegx and tilepro entries.
* gcc_update: Remove tilegx and tilepro entries.

gcc/
* common/config/tilegx/tilegx-common.cc: Removed.
* common/config/tilepro/tilepro-common.cc: Removed.
* config.gcc: Remove tilegx and tilepro entries.
* config/tilegx/constraints.md: Removed.
* config/tilegx/feedback.h: Removed.
* config/tilegx/linux.h: Removed.
* config/tilegx/mul-tables.cc: Removed.
* config/tilegx/predicates.md: Removed.
* config/tilegx/sync.md: Removed.
* config/tilegx/t-tilegx: Removed.
* config/tilegx/tilegx-builtins.h: Removed.
* config/tilegx/tilegx-c.cc: Removed.
* config/tilegx/tilegx-generic.md: Removed.
* config/tilegx/tilegx-modes.def: Removed.
* config/tilegx/tilegx-multiply.h: Removed.
* config/tilegx/tilegx-opts.h: Removed.
* config/tilegx/tilegx-protos.h: Removed.
* config/tilegx/tilegx.cc: Removed.
* config/tilegx/tilegx.h: Removed.
* config/tilegx/tilegx.md: Removed.
* config/tilegx/tilegx.opt: Removed.
* config/tilepro/constraints.md: Removed.
* config/tilepro/feedback.h: Removed.
* config/tilepro/gen-mul-tables.cc: Removed.
* config/tilepro/linux.h: Removed.
* config/tilepro/mul-tables.cc: Removed.
* config/tilepro/predicates.md: Removed.
* config/tilepro/t-tilepro: Removed.
* config/tilepro/tilepro-builtins.h: Removed.
* config/tilepro/tilepro-c.cc: Removed.
* config/tilepro/tilepro-generic.md: Removed.
* config/tilepro/tilepro-modes.def: Removed.
* config/tilepro/tilepro-multiply.h: Removed.
* config/tilepro/tilepro-protos.h: Removed.
* config/tilepro/tilepro.cc: Removed.
* config/tilepro/tilepro.h: Removed.
* config/tilepro/tilepro.md: Removed.
* config/tilepro/tilepro.opt: Removed.
* configure.ac: Remove tilegx and tilepro entries.
* configure: Rebuilt.
* doc/extend.texi: Remove tilegx and tilepro entries.
* doc/install.texi: Remove tilegx and tilepro entries.
* doc/invoke.texi: Remove tilegx and tilepro entries.
* doc/md.texi: Remove tilegx and tilepro entries.

gcc/testsuite/
* gcc.dg/lower-subreg-1.c: Remove tilegx and tilepro entries.
* gcc.misc-tests/linkage.exp: Remove tilegx and
tilepro entries.

libgcc/
* config.host: Removed tilegx and tilepro entries.
* config/tilegx/sfp-machine.h: Removed.
* config/tilegx/sfp-machine32.h: Removed.
* config/tilegx/sfp-machine64.h: Removed.
* config/tilegx/t-crtstuff: Removed.
* config/tilegx/t-softfp: Removed.
* config/tilegx/t-tilegx: Removed.
* config/tilepro/atomic.c: Removed.
* config/tilepro/atomic.h: Removed.
* config/tilepro/linux-unwind.h: Removed.
* config/tilepro/sfp-machine.h: Removed.
* config/tilepro/softdivide.c: Removed.
* config/tilepro/softmpy.S: Removed.
* config/tilepro/t-crtstuff: Removed.
* config/tilepro/t-tilepro: Removed.

2 years agotestsuite, Darwin: Fix darwin-comm-1.c error messages for Darwin <= 10.
Iain Sandoe [Sat, 25 Jun 2022 08:58:35 +0000 (09:58 +0100)]
testsuite, Darwin: Fix darwin-comm-1.c error messages for Darwin <= 10.

When amending the allowed alignment size to accommodate the larger values
permitted by newer tools, we retained the object file limit of 2^15 for
Darwin versions <= 10, since that is what the native tools expect there.

This triggers a different diagnostic path with a distinct error message,
which is checked in the revised test here.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/testsuite/ChangeLog:

* gcc.dg/darwin-comm-1.c: Check for the correct error message for
Darwin <= 10.

2 years agoIterating cprop_hardreg... Third time's a charm.
Roger Sayle [Sat, 25 Jun 2022 08:35:45 +0000 (09:35 +0100)]
Iterating cprop_hardreg... Third time's a charm.

This middle-end patch proposes the "hard register constant propagation"
pass be performed up to three times on each basic block (up from the
current two times) if the second pass successfully made changes.

The motivation for three passes is to handle the "swap idiom" (i.e.
t = x; x = y; y = t;" sequences) that get generated by register allocation
(reload).

Consider the x86_64 test case for __int128 addition recently discussed
on gcc-patches.  With that proposed patch, the input to the cprop_hardreg
pass looks like:

movq %rdi, %r8
movq %rsi, %rdi
movq %r8, %rsi
        movq    %rdx, %rax
        movq    %rcx, %rdx
        addq    %rsi %rax
        adcq    %rdi, %rdx
        ret

where the first three instructions effectively swap %rsi and %rdi.

On the first pass of cprop_hardreg, we notice that the third insn,
%rsi := %r8, is redundant and can eliminated/propagated to produce:

        movq    %rdi, %r8
        movq    %rsi, %rdi
        movq    %rdx, %rax
        movq    %rcx, %rdx
        addq    %r8 %rax
        adcq    %rdi, %rdx
        ret

Because a successful propagation was found, cprop_hardreg then runs
a second pass/sweep on affected basic blocks (using worklist), and
on this second pass notices that the second instruction, %rdi := %rsi,
may now be propagated (%rsi was killed in the before the first transform),
and after a second pass, we now end up with:

        movq    %rdi, %r8
        movq    %rdx, %rax
        movq    %rcx, %rdx
        addq    %r8, %rax
        adcq    %rsi, %rdx
        ret

which is the current behaviour on mainline.  However, a third and final
pass would now notice that the first insn, "%r8 := %rdi" is also now
eliminable, and a third iteration would produce optimal code:

        movq    %rdx, %rax
        movq    %rcx, %rdx
        addq    %rdi, %rax
        adcq    %rsi, %rdx
        ret

The patch below creates two worklists, and alternates between them on
sucessive passes, populating NEXT with the basic block id's of blocks
that were updated during the current pass over the CURR worklist.
It should be noted that this a regression fix; GCC 4.8 generated
optimal code with two moves (whereas GCC 12 required 5 moves, up
from GCC 11's 4 moves).

2022-06-25  Roger Sayle  <roger@nextmovesoftware.com>
    Richard Biener  <rguenther@suse.de>

gcc/ChangeLog
* regcprop.cc (pass_cprop_hardreg::execute): Perform a third
iteration over each basic block that was updated by the second
iteration.

2 years agointl: stop using fgrep for exgettext
Xi Ruoyao [Fri, 24 Jun 2022 06:27:18 +0000 (14:27 +0800)]
intl: stop using fgrep for exgettext

fgrep has been deprecated in favor of grep -F for a long time, and the
next grep release (3.8 or 4.0) will print a warning of fgrep is used.
And, the fgrep command in exgettext is no longer useful after we
migrated from SVN to Git.  Remove the fgrep command so we won't see the
warning.

gcc/po/ChangeLog:

* exgettext: Remove unneeded fgrep command.

2 years agoDaily bump.
GCC Administrator [Sat, 25 Jun 2022 00:16:23 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: Include -Woverloaded-virtual in -Wall [PR87729]
Jason Merrill [Fri, 24 Jun 2022 18:40:12 +0000 (14:40 -0400)]
c++: Include -Woverloaded-virtual in -Wall [PR87729]

This seems like a good warning to have in -Wall, as requested.  But as
pointed out in PR20423, some users want a warning only when a derived
function doesn't override any base function.  So let's put that lesser
version in -Wall (and -Woverloaded-virtual=1) while leaving the semantics
for the existing option the same.

PR c++/87729
PR c++/20423

gcc/c-family/ChangeLog:

* c.opt (Woverloaded-virtual): Add levels, include in -Wall.

gcc/ChangeLog:

* doc/invoke.texi: Document changes.

gcc/cp/ChangeLog:

* class.cc (warn_hidden): Handle -Woverloaded-virtual=1.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Woverloaded-virt1.C: New test.
* g++.dg/warn/Woverloaded-virt2.C: New test.

2 years agotestsuite: Skip btf-bitfields-1.c if int is less than 32-bits
Dimitar Dimitrov [Thu, 9 Jun 2022 17:27:32 +0000 (20:27 +0300)]
testsuite: Skip btf-bitfields-1.c if int is less than 32-bits

This test spuriously fails on AVR with:
   error: width of 'bitfield_c' exceeds its type

8-bit and 16-bit microcontrollers do not seem to be the target audience
for BTF file format.  So the least intrusive fix is to simply skip the
test for them.

gcc/testsuite/ChangeLog:

* gcc.dg/debug/btf/btf-bitfields-1.c: Skip if int is less than
32-bits.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2 years agoFortran: fix checking of arguments to UNPACK when MASK is a variable [PR105813]
Harald Anlauf [Fri, 24 Jun 2022 20:21:39 +0000 (22:21 +0200)]
Fortran: fix checking of arguments to UNPACK when MASK is a variable [PR105813]

gcc/fortran/ChangeLog:

PR fortran/105813
* check.cc (gfc_check_unpack): Try to simplify MASK argument to
UNPACK so that checking of the VECTOR argument can work when MASK
is a variable.

gcc/testsuite/ChangeLog:

PR fortran/105813
* gfortran.dg/unpack_vector_1.f90: New test.

2 years agotestsuite: Handle default_packed for gcc.dg/builtin-object-size-20.c
Dimitar Dimitrov [Fri, 13 May 2022 19:46:59 +0000 (22:46 +0300)]
testsuite: Handle default_packed for gcc.dg/builtin-object-size-20.c

The gcc.dg/builtin-object-size-20.c test case assumes that the target
inserts padding between structure members.  Obviously it fails for
targets which pack structures by default.

Split the cases into two tests, so that the ones requiring structure
padding can be skipped for default_packed targets.

gcc/testsuite/ChangeLog:

* gcc.dg/builtin-object-size-20.c: Remove cases which
work on default_packed targets.
* gcc.dg/builtin-object-size-22.c: New test with the cases
removed above.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2 years agotestsuite: Rename test-defined macros
Dimitar Dimitrov [Sun, 8 May 2022 12:35:02 +0000 (15:35 +0300)]
testsuite: Rename test-defined macros

Epiphany, PRU, ARC and NDS32 may predefine __big_endian__ and
__little_endian__ macros.  This leads to spurious warnings like:
  gcc.dg/sso/memcpy-1.c:7: warning: "__little_endian__" redefined

Fix by renaming the macros in the test.

gcc/testsuite/ChangeLog:

* gcc.dg/sso/memcpy-1.c (__big_endian__, __little_endian__):
Rename macros to avoid conflicts with predefined ones.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2 years agotestsuite: Remove reliance on argc in lto/pr101868_0.c
Dimitar Dimitrov [Sun, 15 May 2022 14:30:52 +0000 (17:30 +0300)]
testsuite: Remove reliance on argc in lto/pr101868_0.c

Some embedded targets do not pass any argv arguments.  When argc is
zero, this causes spurious failures for lto/pr101868_0.c.  Fix by
following the strategy in r0-114701-g2c49569ecea56d.  Use a volatile
variable instead of argc to inject a runtime value into the test.

I validated the following:
  - No changes in testresults for x86_64-pc-linux-gnu.
  - The spurious failures are fixed for PRU target.
  - lto/pr101868_0.c still fails on x86_64-pc-linux-gnu, if
    the PR/101868 fix (r12-2254-gfedcf3c476aff7) is reverted.

PR tree-optimization/101868

gcc/testsuite/ChangeLog:

* gcc.dg/lto/pr101868_0.c (zero): New volatile variable.
(main): Use it instead of argc.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2 years agod: Give consistent error message when attribute argument not a string constant
Iain Buclaw [Fri, 24 Jun 2022 13:30:13 +0000 (15:30 +0200)]
d: Give consistent error message when attribute argument not a string constant

gcc/d/ChangeLog:

* d-attribs.cc (d_handle_section_attribute): Update error message.
(d_handle_symver_attribute): Likewise.
(d_handle_no_sanitize_attribute): Likewise.
(d_handle_visibility_attribute): Likewise.

gcc/testsuite/ChangeLog:

* gdc.dg/attr_section1.d: Update dg-error.
* gdc.dg/attr_visibility1.d: Likewise.

2 years agod: Add `@register' attribute to compiler and library.
Iain Buclaw [Thu, 23 Jun 2022 16:24:07 +0000 (18:24 +0200)]
d: Add `@register' attribute to compiler and library.

The `@register` attribute specifies that a local or `__gshared` variable
is to be given a register storage-class in the C sense of the term, and
will be placed into a register named `registerName`.

The variable needs to boiled down to a data type that fits the target
register.  It also cannot have either thread-local or `extern` storage.
It is an error to take the address of a register variable.

PR d/105413

gcc/d/ChangeLog:

* d-attribs.cc (d_handle_register_attribute): New function.
(d_langhook_attribute_table): Add register attribute.
* d-codegen.cc (d_mark_addressable): Error if taken address of
register variable.
(build_frame_type): Error if register variable has non-local
references.
* d-tree.h (d_mark_addressable): Add complain parameter.
* decl.cc (get_symbol_decl): Mark register varibles DECL_REGISTER.
Error when register variable declared thread-local or extern.
* expr.cc (ExprVisitor::visit (IndexExp *)): Don't complain about
marking register vectors as addressable in an ARRAY_REF.

libphobos/ChangeLog:

* libdruntime/gcc/attributes.d (register): Define.

gcc/testsuite/ChangeLog:

* gdc.dg/attr_register1.d: New test.
* gdc.dg/attr_register2.d: New test.
* gdc.dg/attr_register3.d: New test.

2 years agod: Construct indexes of ARRAY_TYPE using ARRAY_REF.
Iain Buclaw [Fri, 24 Jun 2022 17:48:55 +0000 (19:48 +0200)]
d: Construct indexes of ARRAY_TYPE using ARRAY_REF.

This is a small simplification over `((T *)&array)[index]', which also
allows eliding an unneccesary marking of TREE_ADDRESSABLE when the array
expression is a parameter or variable declaration.

gcc/d/ChangeLog:

* d-codegen.cc (build_array_index): Rename to...
(build_pointer_index): ...this.
* d-tree.h (build_array_index): Rename declaration to...
(build_pointer_index): ...this.
* expr.cc (ExprVisitor::visit (IndexExp *)): Construct indexes of
ARRAY_TYPE using ARRAY_REF.
(ExprVisitor::visit (SliceExp *)): Update.
* intrinsics.cc (expand_intrinsic_bt): Update.

2 years agod: Merge upstream dmd 529110f66, druntime 148608b7.
Iain Buclaw [Fri, 24 Jun 2022 17:41:41 +0000 (19:41 +0200)]
d: Merge upstream dmd 529110f66, druntime 148608b7.

D front-end changes:

    - Import latest bug fixes to mainline.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 529110f66.
* decl.cc (DeclVisitor::visit (TupleDeclaration *)): Update for new
front-end interface.
* types.cc (layout_aggregate_members): Likewise.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 148608b7.

2 years agotilegx: Fix infinite loop in gen-mul-tables generator
Iain Buclaw [Wed, 22 Jun 2022 17:11:20 +0000 (19:11 +0200)]
tilegx: Fix infinite loop in gen-mul-tables generator

Since around GCC 10, the condition `j < (INTMAX_MAX / 10)' will get
optimized into `j != 922337203685477580', which will result in an
infinite loop for certain inputs of `j'.

Copy the condition already used by the -DTILEPRO generator code, which
doesn't fall into this trap.

gcc/ChangeLog:

* config/tilepro/gen-mul-tables.cc (tilegx_emit): Adjust loop
condition to avoid overflow.

2 years agocompiler: use bool for comma-ok if not already boolean
Ian Lance Taylor [Fri, 24 Jun 2022 00:11:05 +0000 (17:11 -0700)]
compiler: use bool for comma-ok if not already boolean

If a comma-ok variable already has a type, and that type is not a
boolean type, then set the type of the temporary variable to bool.
Otherwise we may try to convert an unnamed bool type to an interface
type, which will fail. But we don't want to always use bool, because
the type of the comma-ok variable may be a named bool type, in
which case the assignment would fail (or need an explicit conversion).

The test case is https://go.dev/cl/404496.

Fixes golang/go#52535

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

2 years agoanalyzer: consolidate call_string instances
David Malcolm [Fri, 24 Jun 2022 17:44:48 +0000 (13:44 -0400)]
analyzer: consolidate call_string instances

ana::call_string is a wrapper around an auto_vec of callsites, leading
to non-trivial copying when copying around call_string instances, e.g.
in ana::program_point.

This patch consolidates call_string instances within the
region_model_manager: it now owns the root/empty call_string, and
each call_string instance tracks its children, lazily creating them on
demand, so that the call_string instances form a tree-like hierarchy in
memory.  Doing this requires passing the region_model_manager to the
various program_point factory methods, so that they can get at the root
call_string.

Instances of call_string become immutable (apart from their internal
cache for looking up their children); operations that previously
modified them now return the call_string for the result of the
operation.

I wasn't able to observe any performance impact of this, but it
simplifies call_string and program_point management, and thus I hope
will make it easier to improve call summarization.  In particular,
region_model_manager::log_stats will now print a hierarchical dump of
all the call_string instances used in the analysis (in -fdump-analyzer
and -fdump-analyzer-stderr).

gcc/analyzer/ChangeLog:
* call-string.cc: Add includes of "analyzer/analyzer.h"
and "analyzer/analyzer-logging.h".
(call_string::call_string): Delete copy ctor.
(call_string::operator=): Delete.
(call_string::operator==): Delete.
(call_string::hash): Delete.
(call_string::push_call): Make const, returning the resulting
call_string.
(call_string::pop): Delete.
(call_string::cmp_ptr_ptr): New.
(call_string::validate): Assert that m_parent is non-NULL, or
m_elements is empty.
(call_string::call_string): Move default ctor here from
call-string.h and reimplement.  Add ctor taking a parent
and an element.
(call_string::~call_string): New.
(call_string::recursive_log): New.
* call-string.h (call_string::call_string): Move default ctor's
defn to call-string.cc.  Delete copy ctor.  Add ctor taking a
parent and an element.
(call_string::operator=): Delete.
(call_string::operator==): Delete.
(call_string::hash): Delete.
(call_string::push_call): Make const, returning the resulting
call_string.
(call_string::pop): Delete decl.
(call_string::get_parent): New.
(call_string::cmp_ptr_ptr): New decl.
(call_string::get_top_of_stack): New.
(struct call_string::hashmap_traits_t): New.
(class call_string): Add friend class region_model_manager.  Add
DISABLE_COPY_AND_ASSIGN.
(call_string::~call_string): New decl.
(call_string::recursive_log): New decl.
(call_string::m_parent): New field.
(call_string::m_children): New field.
* constraint-manager.cc (selftest::test_many_constants): Pass
model manager to program_point::origin.
* engine.cc (exploded_graph::exploded_graph): Likewise.
(exploded_graph::add_function_entry): Likewise for
program_point::from_function_entry.
(add_tainted_args_callback): Likewise.
(exploded_graph::maybe_process_run_of_before_supernode_enodes):
Update for change to program_point.get_call_string.
(exploded_graph::process_node): Likewise.
(class function_call_string_cluster): Convert m_cs from a
call_string to a const call_string &.
(struct function_call_string): Likewise.
(pod_hash_traits<function_call_string>::hash): Use pointer_hash
for m_cs.
(pod_hash_traits<function_call_string>::equal): Update for change
to m_cs.
(root_cluster::add_node): Update for change to
function_call_string.
(viz_callgraph_node::dump_dot): Update for change to call_string.
* exploded-graph.h (per_call_string_data::m_key): Convert to a
reference.
(struct eg_call_string_hash_map_traits): Delete.
(exploded_graph::call_string_data_map_t): Remove traits class.
* program-point.cc: Move include of "analyzer/call-string.h" to
after "analyzer/analyzer-logging.h".
(program_point::print): Update for conversion of m_call_string to
a pointer.
(program_point::to_json): Likewise.
(program_point::push_to_call_stack): Update for immutability of
call strings.
(program_point::pop_from_call_stack): Likewise.
(program_point::hash): Use pointer hashing for m_call_string.
(program_point::get_function_at_depth): Update for change to
m_call_string.
(program_point::validate): Update for changes to call_string.
(program_point::on_edge): Likewise.
(program_point::origin): Move here from call-string.h.  Add
region_model_manager param and use it to get empty call string.
(program_point::from_function_entry): Likewise.
(selftest::test_function_point_ordering): Likewise.
(selftest::test_function_point_ordering): Likewise.
* program-point.h (program_point::program_point): Update for
change to m_call_string.
(program_point::get_call_string): Likewise.
(program_point::get_stack_depth): Likewise.
(program_point::origin): Add region_model_manager param, and move
defn to call-string.cc.
(program_point::from_function_entry): Likewise.
(program_point::empty): Drop call_string.
(program_point::deleted): Likewise.
(program_point::program_point): New private ctor.
(program_point::m_call_string): Convert from call_string to const
call_string *.
* program-state.cc (selftest::test_program_state_merging): Update
for call_string changes.
(selftest::test_program_state_merging_2): Likewise.
* region-model-manager.cc
(region_model_manager::region_model_manager): Construct
m_empty_call_string.
(region_model_manager::log_stats): Log the call strings.
* region-model.cc (assert_region_models_merge): Pass the
region_model_manager when creating program_point instances.
(selftest::test_state_merging): Likewise.
(selftest::test_constraint_merging): Likewise.
(selftest::test_widening_constraints): Likewise.
(selftest::test_iteration_1): Likewise.
* region-model.h (region_model_manager::get_empty_call_string):
New.
(region_model_manager::m_empty_call_string): New.
* sm-signal.cc (register_signal_handler::impl_transition): Update
for changes to call_string.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agoanalyzer: whitespace cleanups
David Malcolm [Fri, 24 Jun 2022 17:43:01 +0000 (13:43 -0400)]
analyzer: whitespace cleanups

Clean up whitespace in preparation for a follow-up patch.

No functional change intended.

gcc/analyzer/ChangeLog:
* call-string.cc (call_string::calc_recursion_depth): Whitespace
cleanups.
(call_string::cmp): Likewise.
(call_string::get_caller_node): Likewise.
(call_string::validate): Likewise.
* engine.cc (dynamic_call_info_t::add_events_to_path): Likewise.
(exploded_graph::get_per_function_data): Likewise.
(exploded_graph::maybe_create_dynamic_call): Likewise.
(exploded_graph::maybe_create_dynamic_call): Likewise.
(exploded_graph::process_node): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years ago[PATCH,RS6000 5/5] Replace MASK_<xxxx> usage with OPTION_MASK_<xxxx>
Will Schmidt [Thu, 23 Jun 2022 20:54:19 +0000 (15:54 -0500)]
[PATCH,RS6000 5/5] Replace MASK_<xxxx> usage with OPTION_MASK_<xxxx>

This continues the changes of replacing the MASK_<xxxx> defines
with their OPTION_MASK_<xxxx> equivalents.

This patch removes the defines for
MASK_P8_VECTOR, MASK_P9_VECTOR, MASK_P9_MISC, MASK_POPCNTB,
MASK_POPCNTD, MASK_PPC_GFXOPT, MASK_PPC_GPOPT, MASK_RECIP_PRECISION,
MASK_SOFT_FLOAT, MASK_VSX, MASK_POWER10, MASK_P10_FUSION.

gcc/
* config/rs6000/aix71.h (MASK_PPC_GPOPT, MASK_PPC_GFXOPT): Replace with
OPTION_MASK_PPC_GPOPT, OPTION_MASK_PPC_GFXOPT.
* config/rs6000/darwin.h (MASK_PPC_GFXOPT): Replace with
OPTION_MASK_PPC_GFXOPT.
* config/rs6000/darwin64-biarch.h (MASK_PPC_GFXOPT): Same.
* config/rs6000/default64.h (MASK_PPC_GPOPT, MASK_PPC_GFXOPT): Replace with
OPTION_MASK_PPC_GPOPT, OPTION_MASK_PPC_GFXOPT.
* config/rs6000/rs6000-c.cc: Update comment.
* config/rs6000/rs6000-cpus.def: Update RS6000_CPU macro calls.
* config/rs6000/rs6000.cc (rs6000_darwin_file_start): Replace
MASK_PPC_GPOPT with OPTION_MASK_PPC_GPOPT.
(rs6000_builtin_mask_names): Replace MASK_PPC_GFXOPT, MASK_POPCNTB
with OPTION_MASK_PPC_GFXOPT, OPTION_MASK_POPCNTB.
* config/rs6000/rs6000.h: (MASK_P8_VECTOR, MASK_P9_VECTOR,
MASK_P9_MISC, MASK_POPCNTB, MASK_POPCNTD, MASK_PPC_GFXOPT,
MASK_PPC_GPOPT, MASK_RECIP_PRECISION, MASK_SOFT_FLOAT,
MASK_VSX, MASK_POWER10, MASK_P10_FUSION): Delete.

2 years ago[PATCH,RS6000 4/5] Replace MASK_<xxxx> with OPTION_MASK_<xxxx>
Will Schmidt [Thu, 23 Jun 2022 20:52:33 +0000 (15:52 -0500)]
[PATCH,RS6000 4/5] Replace MASK_<xxxx> with OPTION_MASK_<xxxx>

This replaces the MASK_<xxxx> references with OPTION_MASK_<xxxx>
and removes the now unused defines.

This patch removes the defines for
MASK_ALTIVEC, MASK_CMPB, MASK_CRYPTO, MASK_DFP,
MASK_DIRECT_MOVE, MASK_DLMZB, MASK_EABI, MASK_FLOAT128_KEYWORD,
MASK_FLOAT128_HW, MASK_FPRND, MASK_P8_FUSION, MASK_HARD_FLOAT,
MASK_HTM, MASK_MFCRF, MASK_MMA, MASK_MULHW, MASK_MULTIPLE,
MASK_NO_UPDATE.

gcc/
* config/rs6000/aix71.h (TARGET_DEFAULT): Replace MASK_MFCRF with
OPTION_MASK_MFCRF.
* config/rs6000/darwin.h (TARGET_DEFAULT): Replace MASK_MULTIPLE with
OPTION_MASK_MULTIPLE.
* config/rs6000/darwin64-biarch.h (TARGET_DEFAULT): Same.
* config/rs6000/default64.h (TARGET_DEFAULT): Replace MASK_MFCRF with
OPTION_MASK_MFCRF.
* config/rs6000/eabi.h (TARGET_DEFAULT): Replace MASK_EABI with
OPTION_MASK_EABI.
* config/rs6000/eabialtivec.h (TARGET_DEFAULT): Same.
* config/rs6000/linuxaltivec.h (TARGET_DEFAULT): Replace
MASK_ALTIVEC with OPTION_MASK_ALTIVEC.
* config/rs6000/rs6000-cpus.def (MASK_ALTIVEC, MASK_CMPB,
MASK_CRYPTO, MASK_DFP, MASK_DIRECT_MOVE, MASK_DLMZB, MASK_EABI,
MASK_FLOAT128_KEYWORD, MASK_FLOAT128_HW, MASK_FPRND,
MASK_P8_FUSION, MASK_HARD_FLOAT, MASK_HTM, MASK_ISEL, MASK_MFCRF,
MASK_MMA, MASK_MULHW, MASK_MULTIPLE, MASK_NO_UPDATE):
Replace with
OPTION_MASK_ALTIVEC, OPTION_MASK_CMPB, OPTION_MASK_CRYPTO,
OPTION_MASK_DFP, OPTION_MASK_DIRECT_MOVE, OPTION_MASK_DLMZB,
OPTION_MASK_EABI, OPTION_MASK_FLOAT128_KEYWORD,
OPTION_MASK_FLOAT128_HW, OPTION_MASK_FPRND, OPTION_MASK_P8_FUSION,
OPTION_MASK_HARD_FLOAT, OPTION_MASK_HTM, OPTION_MASK_ISEL,
OPTION_MASK_MFCRF, OPTION_MASK_MMA, OPTION_MASK_MULHW,
OPTION_MASK_MULTIPLE, OPTION_MASK_NO_UPDATE.
* config/rs6000/rs6000.cc (rs6000_darwin_file_start): Replace
MASK_MFCRF, MASK_ALTIVEC with OPTION_MASK_MFCRF, OPTION_MASK_ALTIVEC.
* config/rs6000/rs6000.h (TARGET_DEFAULT): Replace MASK_MULTIPLE
with OPTION_MASK_MULTIPLE.
(MASK_ALTIVEC, MASK_CMPB, MASK_CRYPTO, MASK_DFP,
MASK_DIRECT_MOVE, MASK_DLMZB, MASK_EABI, MASK_FLOAT128_KEYWORD,
MASK_FLOAT128_HW, MASK_FPRND, MASK_P8_FUSION, MASK_HARD_FLOAT,
MASK_HTM, MASK_ISEL, MASK_MFCRF, MASK_MMA, MASK_MULHW,
MASK_MULTIPLE, MASK_NO_UPDATE): Delete.
* config/rs6000/vxworks.h (TARGET_DEFAULT): Replace MASK_EABI
with OPTION_MASK_EABI.

2 years ago[PATCH,RS6000 3/5] Rework the RS6000_BTM defines, continued.
Will Schmidt [Thu, 23 Jun 2022 20:50:57 +0000 (15:50 -0500)]
[PATCH,RS6000 3/5] Rework the RS6000_BTM defines, continued.

The RS6000_BTM_<xxxx> definitions are mostly unused after
the rs6000 builtin code was reworked.   This cleans
up the remaining RS6000_BTM_<xxxx> references by replacing
them with their OPTION_MASK_<xxxx> equivalents.

This patch removes the defines
RS6000_BTM_MODULO, RS6000_BTM_ALTIVEC, RS6000_BTM_CMPB,
RS6000_BTM_VSX, RS6000_BTM_P8_VECTOR, RS6000_BTM_P9_VECTOR,
RS6000_BTM_P9_MISC, RS6000_BTM_CRYPTO, RS6000_BTM_HTM,
RS6000_BTM_FRE.

gcc/
* config/rs6000/rs6000.cc (RS6000_BTM_ALTIVEC, RS6000_BTM_CMPB,
RS6000_BTM_VSX, RS6000_BTM_FRE, RS6000_BTM_P8_VECTOR,
RS6000_BTM_P9_VECTOR, RS6000_BTM_P9_MISC, RS6000_BTM_MODULO,
RS6000_BTM_CRYPTO, RS6000_BTM_HTM): Replace with OPTION_MASK_ALTIVEC,
OPTION_MASK_CMPB, OPTION_MASK_VSX, OPTION_MASK_POPCNTB,
OPTION_MASK_P8_VECTOR, OPTION_MASK_P9_VECTOR, OPTION_MASK_P9_MISC,
OPTION_MASK_MODULO, OPTION_MASK_CRYPTO, OPTION_MASK_HTM.
* config/rs6000/rs6000.h (RS6000_BTM_MODULO, RS6000_BTM_ALTIVEC,
RS6000_BTM_CMPB, RS6000_BTM_VSX, RS6000_BTM_P8_VECTOR,
RS6000_BTM_P9_VECTOR, RS6000_BTM_P9_MISC, RS6000_BTM_CRYPTO,
RS6000_BTM_HTM, RS6000_BTM_FRE): Remove.

2 years ago[PATCH,RS6000 2/5] Rework the RS6000_BTM defines.
Will Schmidt [Thu, 23 Jun 2022 20:48:21 +0000 (15:48 -0500)]
[PATCH,RS6000 2/5] Rework the RS6000_BTM defines.

The RS6000_BTM_<xxxx> definitions are mostly unused after the rs6000
builtin code was reworked.  The remaining references can be replaced
with the OPTION_MASK_<xxxx> and MASK_<xxxx> equivalents.

This patch remvoes the defines:
RS6000_BTM_FRES, RS6000_BTM_FRSQRTE, RS6000_BTM_FRSQRTES,
RS6000_BTM_POPCNTD, RS6000_BTM_CELL, RS6000_BTM_DFP,
RS6000_BTM_HARD_FLOAT, RS6000_BTM_LDBL128, RS6000_BTM_64BIT,
RS6000_BTM_POWERPC64, RS6000_BTM_FLOAT128, RS6000_BTM_FLOAT128_HW
RS6000_BTM_MMA, RS6000_BTM_P10.

I note that the BTM -> OPTION_MASK mappings are not always 1-to-1.
in particular the BTM_FRES and BTM_FRSQRTE values were both mapped to
OPTION_MASK_PPC_GFXOPT, while the BTM_FRE and BTM_FRSQRTES both mapped
to OPTION_MASK_POPCNTB.  In total I spent quite a bit of time
double-checking these since it looked like copy/paste errors.  I split
some of these changes out into a subsequent patch to limit the amount
of potential confusion in any particular patch.

gcc/
* config/rs6000/rs6000-c.cc: Update comments.
* config/rs6000/rs6000.cc (RS6000_BTM_FRES, RS6000_BTM_FRSQRTE,
RS6000_BTM_FRSQRTES, RS6000_BTM_POPCNTD, RS6000_BTM_CELL,
RS6000_BTM_64BIT, RS6000_BTM_POWERPC64, RS6000_BTM_DFP,
RS6000_BTM_HARD_FLOAT,RS6000_BTM_LDBL128, RS6000_BTM_FLOAT128,
RS6000_BTM_FLOAT128_HW, RS6000_BTM_MMA, RS6000_BTM_P10): Replace
with OPTION_MASK_PPC_GFXOPT, OPTION_MASK_PPC_GFXOPT,
OPTION_MASK_POPCNTB, OPTION_MASK_POPCNTD,
OPTION_MASK_FPRND, MASK_64BIT, MASK_POWERPC64,
OPTION_MASK_DFP, OPTION_MASK_SOFT_FLOAT, OPTION_MASK_MULTIPLE,
OPTION_MASK_FLOAT128_KEYWORD, OPTION_MASK_FLOAT128_HW,
OPTION_MASK_MMA, OPTION_MASK_POWER10.
* config/rs6000/rs6000.h (RS6000_BTM_FRES, RS6000_BTM_FRSQRTE,
RS6000_BTM_FRSQRTES, RS6000_BTM_POPCNTD, RS6000_BTM_CELL,
RS6000_BTM_DFP, RS6000_BTM_HARD_FLOAT, RS6000_BTM_LDBL128,
RS6000_BTM_64BIT, RS6000_BTM_POWERPC64, RS6000_BTM_FLOAT128,
RS6000_BTM_FLOAT128_HW, RS6000_BTM_MMA, RS6000_BTM_P10): Delete.

2 years ago[PATCH,RS6000 1/5] Clean-up MASK_<xxxx> and RS6000_BTM_<xxxx> definitions.
Will Schmidt [Thu, 23 Jun 2022 20:45:15 +0000 (15:45 -0500)]
[PATCH,RS6000 1/5] Clean-up MASK_<xxxx> and RS6000_BTM_<xxxx> definitions.

This patch removes the defines that are no longer used, and
updates the comment for the set of MASK_<xxxx> defines.

This patch removes the defines for
MASK_REGNAMES, MASK_PROTOTYPE, RS6000_BTM_ALWAYS, RS6000_BTM_COMMON.

gcc/
* config/rs6000/rs6000.h (RS6000_BTM_COMMON, RS6000_BTM_ALWAYS,
MASK_REGNAMES, OPTION_MASK_REGNAMES, MASK_PROTOTYPE,
OPTION_MASK_PROTOTYPE, MASK_UPDATE, OPTION_MASK_UPDATE): Remove.

2 years agomiddle-end/106070 - bogus cond-expr folding
Richard Biener [Fri, 24 Jun 2022 11:37:22 +0000 (13:37 +0200)]
middle-end/106070 - bogus cond-expr folding

The following fixes up r13-469-g9a53101caadae1b5 by properly
implementing what operand_equal_for_comparison_p did.

2022-06-24  Richard Biener  <rguenther@suse.de>

PR middle-end/106070
* match.pd (a != b ? a : b): Fix translation of
operand_equal_for_comparison_p.

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

2 years agolibstdc++: use grep -E instead of egrep in scripts
Xi Ruoyao [Fri, 24 Jun 2022 07:02:23 +0000 (15:02 +0800)]
libstdc++: use grep -E instead of egrep in scripts

egrep has been deprecated in favor of grep -E for a long time, and the
next grep release (3.8 or 4.0) will print a warning of egrep is used.
Stop using egrep so we won't see the warning.

grep's from GNU, BSD (including Mac OS X), AIX, BusyBox all support -E
and -F.  Solaris grep doesn't support -E, but extract_symvers.in already
contains a special case for Solaris and doxygen documentation generation
is already broken on non-GNU.

libstdc++-v3/ChangeLog:

* scripts/extract_symvers.in: Use grep -E instead of egrep.
* scripts/run_doxygen: Likewise.

2 years agoFix stmt_kills_ref_p WRT external throws
Jan Hubicka [Fri, 24 Jun 2022 11:52:44 +0000 (13:52 +0200)]
Fix stmt_kills_ref_p WRT external throws

Add missing check to stmt_kills_ref_p for case that function
is terminated by EH before call return value kills the ref. In the PR
I tried to construct testcase but I don't know how to do that until I
annotate EH code with fnspec attributes which I will do in separate patch
and add a testcase.

PR ipa/106057
* tree-ssa-alias.cc (stmt_kills_ref_p): Check for external throw.

2 years agoprofile-count: fix /= and *= operators
Martin Liska [Thu, 23 Jun 2022 20:59:11 +0000 (22:59 +0200)]
profile-count: fix /= and *= operators

PR middle-end/106059

gcc/ChangeLog:

* profile-count.h: *= and /= operators need to modify this
object.

2 years agoPR target/105930: Split *xordi3_doubleword after reload on x86.
Roger Sayle [Fri, 24 Jun 2022 06:15:08 +0000 (07:15 +0100)]
PR target/105930: Split *xordi3_doubleword after reload on x86.

This patch addresses PR target/105930 which is an ia32 stack frame size
regression in high-register pressure XOR-rich cryptography functions
reported by Linus Torvalds.  The underlying problem is once the limited
number of registers on the x86 are exhausted, the register allocator
has to decide which to spill, where some eviction choices lead to much
poorer code, but these consequences are difficult to predict in advance.

The patch below, which splits xordi3_doubleword and iordi3_doubleword
after reload (instead of before), significantly reduces the amount of
spill code and stack frame size, in what might appear to be an arbitrary
choice.

My explanation of this behaviour is that the mixing of pre-reload split
SImode instructions and post-reload split DImode instructions is
confusing some of the heuristics used by reload.  One might think
that splitting early gives the register allocator more freedom to
use available registers, but in practice the constraint that double
word values occupy consecutive registers (when ultimately used as a
DImode value) is the greater constraint.  Instead, I believe in this
case, the pseudo registers used in memory addressing, appear to be
double counted for split SImode instructions compared to unsplit
DImode instructions.  For the reduced test case in comment #13, this
leads to %eax being used to hold the long-lived argument pointer "v",
blocking the use of the ax:dx pair for processing double word values.
The important lines are at the very top of the assembly output:

GCC 11 [use %ecx to address memory, require a 24-byte stack frame]
        sub     esp, 24
        mov     ecx, DWORD PTR [esp+40]

GCC 12 [use %eax to address memory, require a 44-byte stack frame]
        sub     esp, 44
        mov     eax, DWORD PTR [esp+64]

2022-06-24  Roger Sayle  <roger@nextmovesoftware.com>
    Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog
PR target/105930
* config/i386/i386.md (*<any_or>di3_doubleword): Split after
reload.  Use rtx_equal_p to avoid creating memory-to-memory moves,
and emit NOTE_INSN_DELETED if operand[2] is zero (i.e. with -O0).

2 years agolibstdc++: check for openat
Alexandre Oliva [Fri, 24 Jun 2022 02:20:53 +0000 (23:20 -0300)]
libstdc++: check for openat

rtems6.0 has fdopendir, and fcntl.h defines AT_FDCWD and declares
openat, but there's no openat in libc.  Adjust dir-common.h to not
assume ::openat just because of AT_FDCWD.

for  libstdc++-v3/ChangeLog

* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Check for
openat.
* configure, config.h.in: Rebuilt.
* src/filesystem/dir-common.h (openat): Use ::openat if
_GLIBCXX_HAVE_OPENAT.
* src/filesystem/dir.cc (dir_and_pathname): Use dirfd if
_GLIBCXX_HAVE_OPENAT.

2 years agolibstdc++: xfail rename tests on rtems
Alexandre Oliva [Fri, 24 Jun 2022 02:20:52 +0000 (23:20 -0300)]
libstdc++: xfail rename tests on rtems

::rename on RTEMS does not meet several POSIX requirements, despite
compliance with C and C++ standards.  ::std::filesystem::rename, in
turn, has requirements borrowed from POSIX, so it would have to be a
lot more than a simple wrapper around ::rename on RTEMS, and even then
fall short.

Until RTEMS reimplements ::rename for POSIX compliance, expect
filesystem rename tests to fail on it.

for  libstdc++-v3/ChangeLog

* testsuite/27_io/filesystem/operations/rename.cc: xfail on
rtems.
* testsuite/experimental/filesystem/operations/rename.cc:
Likewise.

2 years agolibstdc++: testsuite: skip fs last_write_time tests if dummy
Alexandre Oliva [Fri, 24 Jun 2022 02:20:51 +0000 (23:20 -0300)]
libstdc++: testsuite: skip fs last_write_time tests if dummy

The last_write_time functions are defined in ways that are useful, or
that fail immediately, depending on various macros.  When they fail
immediately, the filesystem last_write_time.cc tests fail noisily, but
the fail is entirely expected.

Define NO_LAST_WRITE_TIME in the last_write_time.cc tests, according
to the macros that select implementations of last_write_time, and use
it through the new dg-require-target-fs-lwt to skip tests that are
expected to fail.

for  libstdc++-v3/ChangeLog

* testsuite/util/testsuite_fs.h (NO_LAST_WRITE_TIME): Define
when appropriate.
* testsuite/lib/libstdc++.exp
(check_v3_target_fs_last_write_time): New.
* testsuite/lib/dg-options.exp (dg-require-target-fs-lwt):
New.
* testsuite/27_io/filesystem/operations/last_write_time.cc:
Skip the test if the features are unavailable.
* testsuite/experimental/filesystem/operations/last_write_time.cc:
Likewise.

2 years agolibstdc++: testsuite: skip fs space tests on dummy implementations
Alexandre Oliva [Fri, 24 Jun 2022 02:20:51 +0000 (23:20 -0300)]
libstdc++: testsuite: skip fs space tests on dummy implementations

The do_space function is defined in ways that are useful, or that fail
immediately, depending on various macros.  When it fails immediately,
the filesystem space.cc tests fail noisily, but the fail is entirely
expected.

Define NO_SPACE in testsuite_fs.h, according to the macros that select
implementations of do_space, and use it to skip tests that are
expected to fail, through a new dg-require.

for  libstdc++-v3/ChangeLog

* testsuite/util/testsuite_fs.h (NO_SPACE): Define if
appropriate.
* testsuite/lib/libstdc++.exp (check_v3_target_fs_space): New.
* testsuite/lib/dg-options.exp (dg-require-target-fs-space):
New.
* testsuite/27_io/filesystem/operations/space.cc: Require
target-fs-space.
* testsuite/experimental/filesystem/operations/space.cc:
Likewise.

2 years agolibstdc++: testsuite: conditionalize symlink tests
Alexandre Oliva [Fri, 24 Jun 2022 02:20:50 +0000 (23:20 -0300)]
libstdc++: testsuite: conditionalize symlink tests

Several filesystem tests expect to be able to create symlinks even
when !defined (_GLIBCXX_HAVE_SYMLINK), and fail predictably, reducing
the amount of testing of other filesystem features.

They are already skipped for mingw targets.  I've extended the
skipping to other targets in which _GLIBCXX_HAVE_SYMLINK is undefined,
through a new NO_SYMLINKS macro in testsuite_fs.h that guards
skippable portions of tests, and dg-require-target-fs-symlinks for
tests that would be reduced to nothing.

for  libstdc++-v3/ChangeLog

* testsuite/util/testsuite_fs.h (NO_SYMLINKS): Define on
mingw and when create_symlink is a dummy.
* testsuite/27_io/filesystem/operations/symlink_status.cc:
Drop mingw xfail.
(test01, test02): Don't create symlinks when NO_SYMLINKS is
defined.
* testsuite/27_io/filesystem/operations/canonical.cc (test03):
Likewise.
* testsuite/27_io/filesystem/operations/copy.cc (test02):
Likewise.
* testsuite/27_io/filesystem/operations/create_directories.cc
(test04): Likewise.
* testsuite/27_io/filesystem/operations/create_directory.cc
(test01): Likewise.
* testsuite/27_io/filesystem/operations/permissions.cc
(test03, test04): Likewise.
* testsuite/27_io/filesystem/operations/remove.cc (test01):
Likewise.
* testsuite/27_io/filesystem/operations/remove_all.cc (test01):
Likewise.
* testsuite/27_io/filesystem/operations/rename.cc
(test_symlinks): Likewise.
* testsuite/27_io/filesystem/operations/weakly_canonical.cc
(test01): Likewise.
* testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc
(test06): Likewise.
* testsuite/experimental/filesystem/operations/copy.cc
(test01): Likewise.
* testsuite/experimental/filesystem/operations/create_directories.cc
(test04): Likewise.
* testsuite/experimental/filesystem/operations/create_directory.cc
(test01): Likewise.
* testsuite/experimental/filesystem/operations/permissions.cc
(test03, test04): Likewise.
* testsuite/experimental/filesystem/operations/remove.cc
(test01): Likewise.
* testsuite/experimental/filesystem/operations/remove_all.cc
(test01): Likewise.
* testsuite/experimental/filesystem/operations/rename.cc
(test01): Likewise.
* testsuite/lib/libstdc++.exp
(v3_check_preprocessor_condition): Add optional inc parameter.
Add it to the test program after include bits/c++config.h.
(check_v3_target_fs_symlinks): New.
* testsuite/lib/dg-options.exp
(dg-require-target-fs-symlinks): New.
* testsuite/27_io/filesystem/operations/read_symlink.cc:
Replace mingw xfail with require target-fs-symlinks.
* testsuite/experimental/filesystem/operations/read_symlink.cc:
Likewise.

2 years agoIntroduce -nostdlib++ option
Alexandre Oliva [Fri, 24 Jun 2022 02:20:48 +0000 (23:20 -0300)]
Introduce -nostdlib++ option

Using g++ to link without libstdc++, as in g++.dg/abi/pure-virtual1.C,
is error prone, because there's no way to tell g++ to drop libstdc++
without also dropping libc and any other libraries that the target
implicitly links in.

This has often led to the need for manual adjustments to this
testcase.

I figured adding support for -nostdlib++, even though redundant, makes
some sense.  One could presumably use gcc rather than g++ for linking,
for the same effect, but sometimes changing the link command is harder
than adding an option, as in our testsuite.

Since clang already had an option with this effect, we've adopted the
same spelling.

for  gcc/ChangeLog

* common.opt (nostdlib++): New.
* doc/invoke.texi (-nostdlib++): Document it.

for  gcc/cp/ChangeLog

* g++spec.cc (lang_specific_driver): Implement -nostdlib++.

for  gcc/testsuite/ChangeLog

* g++.dg/abi/pure-virtual1.C: Use -nostdlib++.

2 years agolibstdc++: testsuite: avoid predictable mkstemp
Alexandre Oliva [Fri, 24 Jun 2022 02:20:47 +0000 (23:20 -0300)]
libstdc++: testsuite: avoid predictable mkstemp

This patch was originally meant to reduce the likelihood that
nonexistent_path() returns the same pathname for from and to.

It was prompted by a target system with a non-random implementation of
mkstemp, that returns a predictable sequence of filenames and selects
the first one that isn't already taken.

That turned out not to be enough: nonexistent_path adds a suffix to
the filename chosen by mkstemp and removes the file it created, so
mkstemp may very well insist on the same basename, and the case that
doesn't use mkstemp doesn't even check whether the file already
exists.

Anyway, by the time I realized this wasn't enough, I'd already
implemented some of the changes, and I figured I might as well
contribute them, even though they don't really solve any problem, and
even if they did, they'd be just a partial solution.

for  libstdc++-v3/ChangeLog

* testsuite/27_io/filesystem/operations/copy.cc (test02):
Select TO after creating FROM.
(test03, test04): Likewise.
* testsuite/experimental/filesystem/operations/copy.cc
(test02, test03, test04): Likewise.

2 years agolibstdc++: testsuite: tolerate non-cancelling sleep
Alexandre Oliva [Fri, 24 Jun 2022 02:20:46 +0000 (23:20 -0300)]
libstdc++: testsuite: tolerate non-cancelling sleep

Though sleep, nanosleep and clock_nanosleep are all POSIX cancellation
points, not all target systems follow this POSIX requirement.
30_threads/thread/native_handle/cancel.cc will run until it times out
on such systems.

Rather than failing a C++ library test because of a limitation of the
target system, this patch gives the test a chance to successfully
exercise the features it intends to exercise, by introducing a
cancellation point in a loop that would otherwise run indefinitely on
systems exhibiting this limitation.

for  libstdc++-v3/ChangeLog

* testsuite/30_threads/thread/native_handle/cancel.cc: Add an
explicit cancellation point in case sleep_for lacks one.

2 years agolibstdc++: testsuite: use -lbsd for net_ts on RTEMS
Alexandre Oliva [Fri, 24 Jun 2022 02:20:46 +0000 (23:20 -0300)]
libstdc++: testsuite: use -lbsd for net_ts on RTEMS

Networking functions that net_ts tests rely on are defined in libbsd
on RTEMS, so link with it.

for  libstdc++-v3/ChangeLog

* testsuite/lib/dg-options.exp (add_options_for_net_ts): Add
-lbsd for RTEMS targets.

2 years agoaarch64: testsuite: symbol-range fallback to compile
Alexandre Oliva [Fri, 24 Jun 2022 02:20:45 +0000 (23:20 -0300)]
aarch64: testsuite: symbol-range fallback to compile

On some of our embedded aarch64 targets, RAM size is too small for
this test to fit.  It doesn't look like this test requires linking,
and if it does, the -tiny version may presumably get most of the
coverage without going overboard in target system requirements.

Still, linking may be useful, so introduce a two_plus_gigs effective
target, that checks for the ability to link a program with 2GiB of
sbss, and use that to select whether to link or just compile
symbol-range.c.

for  gcc/ChangeLog

* doc/sourcebuild.texi (Environment attributes): Document
two_plus_gigs.

for  gcc/testsuite/ChangeLog

* lib/target-supports.exp
(check_effective_target_two_plus_gigs): New.
* gcc.target/aarch64/symbol-range.c: Link only on
two_plus_gigs targets, compile otherwise.

2 years agoDaily bump.
GCC Administrator [Fri, 24 Jun 2022 00:16:41 +0000 (00:16 +0000)]
Daily bump.

2 years agoc++: designated init cleanup [PR105925]
Jason Merrill [Thu, 23 Jun 2022 18:41:19 +0000 (14:41 -0400)]
c++: designated init cleanup [PR105925]

build_aggr_conv expects to run after reshape_init, which will usually have
filled out all the CONSTRUCTOR indexes; there's no reason to limit using
those to the case where the user gave an explicit designator.

PR c++/105925

gcc/cp/ChangeLog:

* call.cc (build_aggr_conv): Don't depend on
CONSTRUCTOR_IS_DESIGNATED_INIT.

2 years agoc++: anon union designated init [PR105925]
Jason Merrill [Thu, 23 Jun 2022 20:04:02 +0000 (16:04 -0400)]
c++: anon union designated init [PR105925]

This testcase was failing because CONSTRUCTOR_IS_DESIGNATED_INIT wasn't
getting set on the introduced CONSTRUCTOR for the anonymous union, and
build_aggr_conv uses that flag to decide whether to pay attention to the
indexes of the CONSTRUCTOR.  So set the flag when we see a designator rather
than relying on copying it from another CONSTRUCTOR.

This avoids some redundant errors on desig4.C because we stop setting
CONSTRUCTOR_IS_DESIGNATED_INIT on _Complex CONSTRUCTORs where it's
nonsense.

PR c++/105925

gcc/cp/ChangeLog:

* decl.cc (reshape_init_array_1): Set
CONSTRUCTOR_IS_DESIGNATED_INIT here.
(reshape_init_class): And here.
(reshape_init): Not here.

gcc/testsuite/ChangeLog:

* g++.dg/ext/desig4.C: Remove extra errors.
* g++.dg/cpp2a/desig26.C: New test.

2 years agoc++: constexpr folding in unevaluated context [PR105931]
Patrick Palka [Thu, 23 Jun 2022 20:36:43 +0000 (16:36 -0400)]
c++: constexpr folding in unevaluated context [PR105931]

Changing the type of N from int to unsigned in decltype82.C (from
r13-986-g0ecb6b906f215e) reveals another spot where we perform constexpr
evaluation in an unevaluated context for sake of warnings, this time
from the call to shorten_compare in cp_build_binary_op, which calls
fold_for_warn.

We could (and probably should) suppress the shorten_compare warnings
when in an unevaluated context, but there's probably other callers of
fold_for_warn that are similarly affected.  So this patch takes the
approach of directly suppressing fold_for_warn when in an unevaluated
context.

PR c++/105931

gcc/cp/ChangeLog:

* expr.cc (fold_for_warn): Don't fold when in an unevaluated
context.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/decltype82a.C: New test.

2 years agoc++: context completion in lookup_template_class [PR105982]
Patrick Palka [Thu, 23 Jun 2022 20:18:55 +0000 (16:18 -0400)]
c++: context completion in lookup_template_class [PR105982]

The below testcase demonstrates that completion of the substituted
context during lookup_template_class can end up registering the desired
specialization for us in more cases than r13-1045-gcb7fd1ea85feea
anticipated.  In particular this can happen for a non-dependent
specialization of a nested class as well.

For this testcase, during overload resolution with A's guides, we
substitute the deduced argument T=int into the TYPENAME_TYPE B::C,
during which we call lookup_template_class for A<T>::B with T=int,
which completes A<int> for the first time, which recursively registers
the desired specialization of B already.  The parent call to
lookup_template_class then tries to register the same specialization,
triggering an ICE.

This patch fixes this by making lookup_template_class determine more
directly whether we need to recheck the specializations table after
completion of the context -- when and only when the call to complete_type
had an effect.

PR c++/105982

gcc/cp/ChangeLog:

* pt.cc (lookup_template_class): After calling complete_type for
the substituted context, check the table again iff the type was
previously incomplete and complete_type made it complete.

gcc/testsuite/ChangeLog:

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

2 years agocompiler: in Sort_bindings return false if comparing value to itself
zhangjian [Tue, 21 Jun 2022 16:08:47 +0000 (16:08 +0000)]
compiler: in Sort_bindings return false if comparing value to itself

Some versions of std::sort may pass elements at the same iterator location.

Fixes golang/go#53483

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

2 years agocompiler: unalias types for hash/equality functions
Ian Lance Taylor [Wed, 22 Jun 2022 23:40:24 +0000 (16:40 -0700)]
compiler: unalias types for hash/equality functions

Test case is https://go.dev/cl/413694.

Fixes golang/go#52846

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

2 years agodiagnostics: add ability to associate diagnostics with rules from coding standards
David Malcolm [Thu, 23 Jun 2022 18:59:24 +0000 (14:59 -0400)]
diagnostics: add ability to associate diagnostics with rules from coding standards

gcc/ChangeLog:
* common.opt (fdiagnostics-show-rules): New option.
* diagnostic-format-json.cc (diagnostic_output_format_init_json):
Fix up context->show_rules.
* diagnostic-format-sarif.cc
(diagnostic_output_format_init_sarif): Likewise.
* diagnostic-metadata.h (diagnostic_metadata::rule): New class.
(diagnostic_metadata::precanned_rule): New class.
(diagnostic_metadata::add_rule): New.
(diagnostic_metadata::get_num_rules): New.
(diagnostic_metadata::get_rule): New.
(diagnostic_metadata::m_rules): New field.
* diagnostic.cc (diagnostic_initialize): Initialize show_rules.
(print_any_rules): New.
(diagnostic_report_diagnostic): Call it.
* diagnostic.h (diagnostic_context::show_rules): New field.
* doc/invoke.texi (-fno-diagnostics-show-rules): New option.
* opts.cc (common_handle_option): Handle
OPT_fdiagnostics_show_rules.
* toplev.cc (general_init): Set up global_dc->show_rules.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic-test-metadata.c: Expect " [STR34-C]" to
be emitted at the "gets" call.
* gcc.dg/plugin/diagnostic_plugin_test_metadata.c
(pass_test_metadata::execute): Associate the "gets" diagnostic
with a rule named "STR34-C".

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 years agolibstdc++: Properly remove temporary directories in filesystem tests
Jonathan Wakely [Thu, 23 Jun 2022 13:25:49 +0000 (14:25 +0100)]
libstdc++: Properly remove temporary directories in filesystem tests

Although these tests use filesystem::remove_all to clean up, that fails
because it uses recursive_directory_iterator which is intentionally
bodged by the custom readdir defined in the test.

Just use POSIX rmdir to clean up. We don't need to use _rmdir or _wrmdir
for Windows, because we'll never reach test02() on targets where the
custom readdir doesn't interpose the one from libc.

libstdc++-v3/ChangeLog:

* testsuite/27_io/filesystem/iterators/error_reporting.cc: Use
rmdir to remove directories.
* testsuite/experimental/filesystem/iterators/error_reporting.cc:
Likewise.