platform/upstream/gcc.git
3 years agoDaily bump.
GCC Administrator [Fri, 8 Oct 2021 00:16:28 +0000 (00:16 +0000)]
Daily bump.

3 years agoc++: NTTP with array/function type after substitution [PR61355]
Patrick Palka [Thu, 7 Oct 2021 20:39:16 +0000 (16:39 -0400)]
c++: NTTP with array/function type after substitution [PR61355]

We're performing the [temp.param]/10 adjustment at parse time but not
also at substitution time.

PR c++/61355

gcc/cp/ChangeLog:

* pt.c (convert_template_argument): Perform array/function to
pointer conversion on the substituted type of an NTTP.

gcc/testsuite/ChangeLog:

* g++.old-deja/g++.pt/nontype5.C: Adjust.
* g++.dg/template/param6.C: New test.

3 years agolibstdc++: Move C++14 <chrono> components to new <bits/chrono.h> header
Jonathan Wakely [Thu, 7 Oct 2021 13:51:18 +0000 (14:51 +0100)]
libstdc++: Move C++14 <chrono> components to new <bits/chrono.h> header

This moves the "classic" contents of <chrono> to a new header, so that
<future>, <thread> etc. can get use durations and clocks without
calendar types, time zones, and chrono I/O.

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/std/chrono (duration, time_point, system_clock)
(steady_clock, high_resolution_clock, chrono_literals, sys_time)
(file_clock, file_time): Move to ...
* include/bits/chrono.h: New file.
* include/bits/atomic_futex.h: Include new header instead of
<chrono>.
* include/bits/atomic_timed_wait.h: Likewise.
* include/bits/fs_fwd.h: Likewise.
* include/bits/semaphore_base.h: Likewise.
* include/bits/this_thread_sleep.h: Likewise.
* include/bits/unique_lock.h: Likewise.
* include/experimental/bits/fs_fwd.h: Likewise.
* include/experimental/chrono: Likewise.
* include/experimental/io_context: Likewise.
* include/experimental/netfwd: Likewise.
* include/experimental/timer: Likewise.
* include/std/condition_variable: Likewise.
* include/std/mutex: Likewise.
* include/std/shared_mutex: Likewise.

3 years agoctfc: Free CTF container elements in ctfc_delete_container ()
Indu Bhagat [Thu, 7 Oct 2021 19:24:33 +0000 (12:24 -0700)]
ctfc: Free CTF container elements in ctfc_delete_container ()

Free up the memory held by hash tables containing CTF types and CTF variables
at the earliest.  This can be done in ctfc_delete_container () as CTF debug
informtion has already been emitted.

gcc/ChangeLog:

* ctfc.c (ctfc_delete_container): Free hash table contents.

3 years agoctf: Do not warn for CTF not supported for GNU GIMPLE
Indu Bhagat [Thu, 7 Oct 2021 19:09:14 +0000 (12:09 -0700)]
ctf: Do not warn for CTF not supported for GNU GIMPLE

CTF is supported for C only.  Currently, a warning is emitted if the -gctf
command line option is specified for a non-C frontend.  This warning is also
used by the GCC testsuite framework - it skips adding -gctf to the list of
debug flags for automated testing, if CTF is not supported for the frontend.

The following warning, however, is not useful in case of LTO:

"lto1: note: CTF debug info requested, but not supported for ‘GNU GIMPLE’
frontend"

This patch disables the generation of the above warning for GNU GIMPLE.

gcc/ChangeLog:

* toplev.c (process_options): Do not warn for GNU GIMPLE.

3 years agolibstdc++: Avoid use of hardware interference non-constant [PR102377]
Jonathan Wakely [Thu, 7 Oct 2021 17:28:04 +0000 (18:28 +0100)]
libstdc++: Avoid use of hardware interference non-constant [PR102377]

libstdc++-v3/ChangeLog:

PR libstdc++/102377
* include/bits/atomic_wait.h (__waiter_pool_base:_S_align):
Hardcode to 64 instead of using non-constant constant.

3 years agolibstdc++: Avoid debug checks in uniform container erasure functions
Jonathan Wakely [Thu, 7 Oct 2021 13:40:26 +0000 (14:40 +0100)]
libstdc++: Avoid debug checks in uniform container erasure functions

In commit r12-4083 I tried to make the std::erase and std::erase_if
function avoid the unnecessary overhead of safe iterators. It didn't
work, for two reasons. Firstly, for the RB tree containers the
__niter_base function is a no-op (because the iterators aren't
random access) so the safe iterators were still used. Secondly, for the
cases where __niter_base did remove the safe iterator layer, there was
still unnecessary overhead to create a new safe iterator and link it to
the container.

This solves the problem by simply binding a reference to the non-debug
version of the conainer. For normal mode this is a no-op, and for debug
mode it binds a reference to the debug container's base class. That
means the rest of the function operates directly on the non-debug
container, and avoids all checking.

For std::basic_string there's no need to unwrap anything, because we use
std::basic_string directly in debug mode anyway.

libstdc++-v3/ChangeLog:

* include/bits/erase_if.h (__erase_nodes_if): Remove redundant
__niter_base calls.
* include/std/string (erase, erase_if): Likewise.
* include/std/deque (erase, erase_if): Access non-debug
container directly.
* include/std/map (erase, erase_if): Likewise.
* include/std/set (erase, erase_if): Likewise.
* include/std/unordered_map (erase, erase_if): Likewise.
* include/std/unordered_set (erase, erase_if): Likewise.
* include/std/vector (erase, erase_if): Likewise.
* include/experimental/deque (erase, erase_if): Likewise.
* include/experimental/map (erase, erase_if): Likewise.
* include/experimental/set (erase, erase_if): Likewise.
* include/experimental/unordered_map (erase, erase_if):
Likewise.
* include/experimental/unordered_set (erase, erase_if):
Likewise.
* include/experimental/vector (erase, erase_if): Likewise.

3 years agotree-object-size: Drop unused pdecl and poff arguments
Siddhesh Poyarekar [Thu, 7 Oct 2021 14:14:00 +0000 (19:44 +0530)]
tree-object-size: Drop unused pdecl and poff arguments

The pdecl and poff arguments were added to allow their use in
compute_objsize in builtins.c.  That use has been gone for a while now
since compute_objsize does its own size estimation, so drop these
arguments to simplify code.

gcc/ChangeLog:

* tree-object-size.c (addr_object_size,
compute_builtin_object_size): Drop PDECL and POFF arguments.
(addr_object_size): Adjust calls.
* tree-object-size.h (compute_builtin_object_size): Drop PDECL
and POFF arguments.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
3 years agoIntroduce smul_highpart and umul_highpart RTX for high-part multiplications
Roger Sayle [Thu, 7 Oct 2021 14:42:09 +0000 (15:42 +0100)]
Introduce smul_highpart and umul_highpart RTX for high-part multiplications

This patch introduces new RTX codes to allow the RTL passes and
backends to consistently represent high-part multiplications.
Currently, the RTL used by different backends for expanding
smul<mode>3_highpart and umul<mode>3_highpart varies greatly,
with many but not all choosing to express this something like:

(define_insn "smuldi3_highpart"
  [(set (match_operand:DI 0 "nvptx_register_operand" "=R")
       (truncate:DI
        (lshiftrt:TI
         (mult:TI (sign_extend:TI
                   (match_operand:DI 1 "nvptx_register_operand" "R"))
                  (sign_extend:TI
                   (match_operand:DI 2 "nvptx_register_operand" "R")))
         (const_int 64))))]
  ""
  "%.\\tmul.hi.s64\\t%0, %1, %2;")

One complication with using this "widening multiplication" representation
is that it requires an intermediate in a wider mode, making it difficult
or impossible to encode a high-part multiplication of the widest supported
integer mode.  A second is that it can interfere with optimization; for
example simplify-rtx.c contains the comment:

   case TRUNCATE:
      /* Don't optimize (lshiftrt (mult ...)) as it would interfere
         with the umulXi3_highpart patterns.  */

Hopefully these problems are solved (or reduced) by introducing a
new canonical form for high-part multiplications in RTL passes.
This also simplifies insn patterns when one operand is constant.

Whilst implementing some constant folding simplifications and
compile-time evaluation of these new RTX codes, I noticed that
this functionality could also be added for the existing saturating
arithmetic RTX codes.  Then likewise when documenting these new RTX
codes, I also took the opportunity to silence the @xref warnings in
invoke.texi.

2021-10-07  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* rtl.def (SMUL_HIGHPART, UMUL_HIGHPART): New RTX codes for
representing signed and unsigned high-part multiplication resp.
* simplify-rtx.c (simplify_binary_operation_1) [SMUL_HIGHPART,
UMUL_HIGHPART]: Simplify high-part multiplications by zero.
[SS_PLUS, US_PLUS, SS_MINUS, US_MINUS, SS_MULT, US_MULT,
SS_DIV, US_DIV]: Similar simplifications for saturating
arithmetic.
(simplify_const_binary_operation) [SS_PLUS, US_PLUS, SS_MINUS,
US_MINUS, SS_MULT, US_MULT, SMUL_HIGHPART, UMUL_HIGHPART]:
Implement compile-time evaluation for constant operands.

* dwarf2out.c (mem_loc_descriptor): Skip SMUL_HIGHPART and
UMUL_HIGHPART.
* doc/rtl.texi (smul_highpart, umul_highpart): Document RTX codes.
* doc/md.texi (smul@var{m}3_highpart, umul@var{m3}_highpart):
Mention the new smul_highpart and umul_highpart RTX codes.
* doc/invoke.texi: Silence @xref "compilation" warnings.

gcc/testsuite/ChangeLog
* gcc.target/i386/sse2-mmx-paddsb-2.c: New test case.
* gcc.target/i386/sse2-mmx-paddusb-2.c: New test case.
* gcc.target/i386/sse2-mmx-psubsb-2.c: New test case.
* gcc.target/i386/sse2-mmx-psubusb-2.c: New test case.

3 years agoipa: Fix ICE when speculating calls from inlined functions (PR 102388)
Martin Jambor [Thu, 7 Oct 2021 14:21:19 +0000 (16:21 +0200)]
ipa: Fix ICE when speculating calls from inlined functions (PR 102388)

The code handling various cases which lead to call graph edge
duplication (in order to update reference descriptions used to track
and remove no-longer needed references) has missed one important case.

When edge duplication is an effect of creating a speculative edge for
an indirect edge which carries a constant jump function which had been
created from a pass-through function when the edge caller has was
inlined into one of its callers, the reference description attached to
the function describes an edge higher up in the "inlined" clone tree
and so even the new speculative edge will.  Therefore we should not
try to duplicate the reference description itself but rather just bump
the refcount of the existing one.

gcc/ChangeLog:

2021-09-22  Martin Jambor  <mjambor@suse.cz>

PR ipa/102388
* ipa-prop.c (ipa_edge_args_sum_t::duplicate): Also handle the
case when the source reference description corresponds to a
referance taken in a function src->caller is inlined to.

3 years agoc++: variadic ttp constraint subsumption [PR99904]
Patrick Palka [Thu, 7 Oct 2021 14:02:54 +0000 (10:02 -0400)]
c++: variadic ttp constraint subsumption [PR99904]

Here we're crashing when level-lowering the variadic constraint C<Ts...>
on the template template parameter TT because tsubst_pack_expansion expects
processing_template_decl to be set during a partial substitution.

PR c++/99904

gcc/cp/ChangeLog:

* pt.c (is_compatible_template_arg): Set processing_template_decl
around tsubst_constraint_info.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-ttp4.C: New test.

3 years agoc++: Do not warn about lifetime of std::initializer_list<T>& [PR102482]
Jonathan Wakely [Wed, 29 Sep 2021 20:19:49 +0000 (21:19 +0100)]
c++: Do not warn about lifetime of std::initializer_list<T>& [PR102482]

An initializer-list constructor taking a non-const lvalue cannot be
called with a temporary, so the array's lifetime probably doesn't end
with the full expression. -Winit-list-lifetime should not warn for that
case.

PR c++/102482

gcc/cp/ChangeLog:

* init.c (maybe_warn_list_ctor): Do not warn for a reference to
a non-const std::initializer_list.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Winit-list5.C: New test.

3 years agoFix access node merging
Jan Hubicka [Thu, 7 Oct 2021 13:26:01 +0000 (15:26 +0200)]
Fix access node merging

gcc/ChangeLog:

2021-10-07  Jan Hubicka  <hubicka@ucw.cz>

PR ipa/102581
* ipa-modref-tree.h (modref_access_node::contains_p): Handle offsets
better.
(modref_access_node::try_merge_with): Add sanity check that there
are no redundant entries in the list.

gcc/testsuite/ChangeLog:

2021-10-07  Jan Hubicka  <hubicka@ucw.cz>

* g++.dg/torture/pr102581.C: New test.

3 years agoc++: Add testcase for C++23 P2316R2 - consistent character literal encoding [PR102615]
Jakub Jelinek [Thu, 7 Oct 2021 13:16:13 +0000 (15:16 +0200)]
c++: Add testcase for C++23 P2316R2 - consistent character literal encoding [PR102615]

I believe we need no changes to the compiler for P2316R2, seems we treat
character literals the same between preprocessor and C++ expressions,
here is a testcase that should verify it.

Note, seems the internal charset for GCC can be either UTF-8 or UTF-EBCDIC,
but I bet it is very hard (at least for me) to actually test the latter.
I'd guess one needs all system headers to be in EBCDIC and the gcc sources too.
But looking around the source, I'm a little bit worried about the UTF-EBCDIC
case.
One is:
 #if  '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
    && 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21
 #  define HOST_CHARSET HOST_CHARSET_ASCII
 #else
 # if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \
    && 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A
 #  define HOST_CHARSET HOST_CHARSET_EBCDIC
 # else
 #  define HOST_CHARSET HOST_CHARSET_UNKNOWN
 # endif
 #endif
in include/safe-ctype.h, does that mean we only support EBCDIC if -funsigned-char
and otherwise fail to build gcc?  Because with -fsigned-char, '0' is -0x10
rather than 0xF0, 'A' is -0x3F rather than 0xC1 and 'a' is -0x7F rather than
0x81.
And another thing, if HOST_CHARSET == HOST_CHARSET_EBCDIC, how does the libcpp/lex.c
static const cppchar_t utf8_signifier = 0xC0;
...
      if (*buffer->cur >= utf8_signifier)
        {
          if (_cpp_valid_utf8 (pfile, &buffer->cur, buffer->rlimit, 1 + !first,
                               state, &s))
            return true;
        }
work?  Because in UTF-EBCDIC, >= 0xC0 isn't the right test for start of
multi-byte character, it is more complicated and seems _cpp_valid_utf8
assumes UTF-8 as the host charset.

2021-10-07  Jakub Jelinek  <jakub@redhat.com>

PR c++/102615
* g++.dg/cpp23/charlit-encoding1.C: New testcase for C++23 P2316R2.

3 years agotree-optimization/102608 - avoid CSEing .DEFERRED_INIT
Richard Biener [Thu, 7 Oct 2021 12:24:03 +0000 (14:24 +0200)]
tree-optimization/102608 - avoid CSEing .DEFERRED_INIT

This makes VN not CSE .DEFERRED_INIT which confuses uninit
analysis which reports the wrong decl when facing copies
of not initialized data.

2021-10-07  Richard Biener  <rguenther@suse.de>

PR tree-optimization/102608
* tree-ssa-sccvn.c (visit_stmt): Drop .DEFERRED_INIT to
varying.

3 years agoMAINTAINERS: Add myself to DCO section
Siddhesh Poyarekar [Thu, 7 Oct 2021 12:19:00 +0000 (17:49 +0530)]
MAINTAINERS: Add myself to DCO section

Also updated my email address to the one I actually use for gcc, which
unfortunately is not the same as the one I use for glibc.  Oh well...

ChangeLog:

* MAINTAINERS: Add myself to DCO section and update email
address.

3 years agobuild: Fix --enable-gather-detailed-mem-stats
Martin Liska [Thu, 7 Oct 2021 10:29:15 +0000 (12:29 +0200)]
build: Fix --enable-gather-detailed-mem-stats

gcc/c-family/ChangeLog:

* c-common.c (parse_optimize_options): Make
save_opt_decoded_options a pointer type.

gcc/ChangeLog:

* toplev.c (toplev::main): Make
save_opt_decoded_options a pointer type
* toplev.h: Likewise.

3 years agoamdgcn: Fix assembler version incompatibility
Andrew Stubbs [Thu, 30 Sep 2021 16:50:33 +0000 (17:50 +0100)]
amdgcn: Fix assembler version incompatibility

This is another case of the global_load instruction format changing in LLVM
(because they fixed a bug).  The configure test is already in place to detect
what is needed.

gcc/ChangeLog:

* config/gcn/gcn-valu.md (gather<mode>_insn_2offsets<exec>): Apply
HAVE_GCN_ASM_GLOBAL_LOAD_FIXED.
(scatter<mode>_insn_2offsets<exec_scatter>): Likewise.

3 years agoamdgcn: Implement -msram-ecc=any
Andrew Stubbs [Tue, 28 Sep 2021 15:26:09 +0000 (16:26 +0100)]
amdgcn: Implement -msram-ecc=any

The option was already there, but just an alias for -msram-ecc=on.  Now that
LLVM13 supports HSACOv4 and the new ELF flags I can implement the option
properly.

The "any" option is the default in order to ensure that library files work
whichever way the user wants, which means we won't need multilibs to support
the different SRAM ECC hardware configurations.

gcc/ChangeLog:

* config/gcn/gcn-hsa.h (SRAMOPT): Include the whole option string.
Adjust for new -msram-ecc=any behaviour.
(ASM_SPEC): Adjust -mxnack and -msram-ecc usage.
* config/gcn/gcn.c (output_file_start): Implement -msram-ecc=any.
* config/gcn/mkoffload.c (EF_AMDGPU_XNACK): Rename to ...
(EF_AMDGPU_XNACK_V3): ... this.
(EF_AMDGPU_SRAM_ECC): Rename to ...
(EF_AMDGPU_SRAM_ECC_V3): ... this.
(EF_AMDGPU_FEATURE_XNACK_V4): New.
(EF_AMDGPU_FEATURE_XNACK_UNSUPPORTED_V4): New.
(EF_AMDGPU_FEATURE_XNACK_ANY_V4): New.
(EF_AMDGPU_FEATURE_XNACK_OFF_V4): New.
(EF_AMDGPU_FEATURE_XNACK_ON_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_UNSUPPORTED_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_ANY_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_OFF_V4): New.
(EF_AMDGPU_FEATURE_SRAMECC_ON_V4): New.
(SET_XNACK_ON): New.
(SET_XNACK_OFF): New.
(TEST_XNACK): New.
(SET_SRAM_ECC_ON): New.
(SET_SRAM_ECC_ANY): New.
(SET_SRAM_ECC_OFF): New.
(TEST_SRAM_ECC_ANY): New.
(TEST_SRAM_ECC_ON): New.
(main): Implement HSACOv4 and -msram-ecc=any.

3 years agoamdgcn: Support LLVM 13 assembler syntax
Andrew Stubbs [Fri, 24 Sep 2021 10:37:37 +0000 (11:37 +0100)]
amdgcn: Support LLVM 13 assembler syntax

The LLVM devs have changed the assembler architecture attribute names on both
CLI and in the ".amdgcn_target" directive, and changed the attribute syntax
inside the directive, without keeping any backwards compatibility. :-(

This patch improves our configure tests to detect what dialect to use, what
attributes are valid, and adjusts the specs to match.

gcc/ChangeLog:

* config.in: Regenerate.
* config/gcn/gcn-hsa.h (X_FIJI): New macro.
(X_900): New macro.
(X_906): New macro.
(X_908): New macro.
(A_FIJI): Rename to ...
(S_FIJI): ... this.
(A_900): Rename to ...
(S_900): ... this.
(A_906): Rename to ...
(S_906): ... this.
(A_908): Rename to ...
(S_908): ... this.
(SRAMOPT): New macro.
(ASM_SPEC): Adjust xnack option usage.
* config/gcn/gcn.c (output_file_start): Adjust amdgcn_target usage.
* configure: Regenerate.
* configure.ac: Detect LLVM assembler dialect.

3 years agoProperly parse invariant &MEM addresses in the GIMPLE FE
Richard Biener [Wed, 6 Oct 2021 09:02:38 +0000 (11:02 +0200)]
Properly parse invariant &MEM addresses in the GIMPLE FE

Currently the frontend rejects those addresses as not lvalues
because the C frontend doens't expect MEM_REF or TARGET_MEM_REF
to appear (but they would be valid lvalues there).  The following
fixes that by amending lvalue_p.

The change also makes the dumping of the source of the testcase
valid for the GIMPLE FE by not eliding the '&' when dumping
string literals.

2021-10-06  Richard Biener  <rguenther@suse.de>

gcc/c/
* c-typeck.c (lvalue_p): Also allow MEM_REF and TARGET_MEM_REF.

gcc/
* tree-pretty-print.c (dump_generic_node): Do not elide
printing '&' when dumping with -gimple.

gcc/testsuite/
* gcc.dg/gimplefe-47.c: New testcase.

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

3 years agoc++: One more spaceship test.
Jason Merrill [Wed, 6 Oct 2021 21:12:02 +0000 (17:12 -0400)]
c++: One more spaceship test.

Jakub suggested adding a variant where we actually try to call the
implicitly deleted operator.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/spaceship-synth8a.C: New test.

3 years agolibsanitizer: Update LOCAL_PATCHES
H.J. Lu [Wed, 6 Oct 2021 20:11:34 +0000 (13:11 -0700)]
libsanitizer: Update LOCAL_PATCHES

* LOCAL_PATCHES: Update to the corresponding revision.

3 years agolibsanitizer: Apply local patches
H.J. Lu [Tue, 20 Jul 2021 17:46:51 +0000 (10:46 -0700)]
libsanitizer: Apply local patches

3 years agolibsanitizer: Merge with upstream
H.J. Lu [Wed, 6 Oct 2021 17:24:24 +0000 (10:24 -0700)]
libsanitizer: Merge with upstream

Merged revision: fdf4c035225de52f596899931b1f6100e5e3e928

3 years agolibstdc++: Implement std::move_only_function for C++23 (P0288R9)
Jonathan Wakely [Wed, 6 Oct 2021 12:28:57 +0000 (13:28 +0100)]
libstdc++: Implement std::move_only_function for C++23 (P0288R9)

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add new headers.
* include/Makefile.in: Regenerate.
* include/std/functional: Include <bits/move_only_function.h>.
* include/std/version (__cpp_lib_move_only_function): Define.
* include/bits/mofunc_impl.h: New file.
* include/bits/move_only_function.h: New file.
* testsuite/20_util/move_only_function/call.cc: New test.
* testsuite/20_util/move_only_function/cons.cc: New test.
* testsuite/20_util/move_only_function/move.cc: New test.
* testsuite/20_util/move_only_function/version.cc: New test.

3 years agoAdd range intersect with 2 wide-ints.
Andrew MacLeod [Mon, 4 Oct 2021 19:30:44 +0000 (15:30 -0400)]
Add range intersect with 2 wide-ints.

Add a more efficent intersect using a lower/upper bound single pair of
wide_ints.

* gimple-range-cache.cc (non_null_ref::adjust_range): Call new
intersect routine.
* gimple-range-fold.cc (adjust_pointer_diff_expr): Ditto.
(adjust_imagpart_expr): Ditto.
* value-range.cc (irange::irange_intersect): Call new routine if
RHS is a single pair.
(irange::intersect): New wide_int version.
* value-range.h (class irange): New prototype.

3 years agoIntroduce a param-switch-limit for EVRP.
Andrew MacLeod [Wed, 29 Sep 2021 21:25:50 +0000 (17:25 -0400)]
Introduce a param-switch-limit for EVRP.

Very large switches cause a lot of range calculations with multiple subranges
to happen.  This can cause quadratic or even exponetial time increases in
large testcases.  This patch introduces a param variable to limit
the size of switches EVRP will process.

* gimple-range-edge.cc (gimple_outgoing_range::gimple_outgoing_range):
Add parameter to limit size when recognizing switches.
(gimple_outgoing_range::edge_range_p): Check size limit.
* gimple-range-edge.h (gimple_outgoing_range): Add size field.
* gimple-range-gori.cc (gori_map::calculate_gori): Ignore switches
that exceed the size limit.
(gori_compute::gori_compute): Add initializer.
* params.opt (evrp-switch-limit): New.
* doc/invoke.texi: Update docs.

3 years agoUse TYPE_MIN/MAX_VALUE in set_varying when possible.
Andrew MacLeod [Tue, 28 Sep 2021 17:11:22 +0000 (13:11 -0400)]
Use TYPE_MIN/MAX_VALUE in set_varying when possible.

We currently create new trees every time... which is very wasteful and time
consuming. Instead, just use the TYPE_MIN/MAX_VALUE.

* value-range.h (irange::set_varying): Use TYPE_MIN_VALUE and
TYPE_MAX_VALUE instead of creating new trees when possible.

3 years agoRanger: More efficient zero/nonzero check.
Andrew MacLeod [Mon, 27 Sep 2021 22:53:54 +0000 (18:53 -0400)]
Ranger: More efficient zero/nonzero check.

A recent change introduced a frequent check for zero and non-zero which has
caused a lot of extra temporary trees to be created.  Make the check more
efficent as it is always a pointer and thus unsigned.

* gimple-range-cache.cc (non_null_ref::adjust_range): Check for
zero and non-zero more efficently.

3 years agoMore consistently dump GIMPLE FE consumable stmts
Richard Biener [Tue, 5 Oct 2021 12:49:42 +0000 (14:49 +0200)]
More consistently dump GIMPLE FE consumable stmts

The following makes more stmts consumable with the GIMPLE FE
when dumping with -gimple.  In particular addresses in GIMPLE
operand position require wrapping with _Literal.

The TDF_ flag space is now exhausted and I've removed overlaps
and re-ordered things as to how it is supposed to work and
made it uint32_t and prepared the operator overloads for an
easy migration to uint64_t once required.

2021-10-05  Richard Biener  <rguenther@suse.de>

PR c/102605
* dumpfile.h (TDF_GIMPLE_VAL): New.
(dump_flag): Re-order and adjust TDF_* flags.  Make
the enum uint32_t.  Use std::underlying_type in the
operator overloads.
(optgroup_flag): Likewise for the operator overloads.
* tree-pretty-print.c (dump_generic_node): Wrap ADDR_EXPR
in _Literal if TDF_GIMPLE_VAL.
* gimple-pretty-print.c (dump_gimple_assign): Add
TDF_GIMPLE_VAL to flags when dumping operands where only
is_gimple_val are allowed.
(dump_gimple_cond): Likewise.

3 years agoopenmp: Optimize for OpenMP atomics 2x__builtin_clear_padding+__builtin_memcmp if...
Jakub Jelinek [Wed, 6 Oct 2021 08:40:12 +0000 (10:40 +0200)]
openmp: Optimize for OpenMP atomics 2x__builtin_clear_padding+__builtin_memcmp if possible

For the few long double types that do have padding bits, e.g. on x86
the clear_type_padding_in_mask computed mask is
ff ff ff ff ff ff ff ff ff ff 00 00 for 32-bit and
ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 for 64-bit.
Instead of doing __builtin_clear_padding on both operands that will clear the
last 2 or 6 bytes and then memcmp on the whole 12/16 bytes, we can just
memcmp 10 bytes.  The code also handles if the padding would be at the start
or both at the start and end, but everything on byte boundaries only and
non-padding bits being contiguous.
This works around a tree-ssa-dse.c bug (but we need to fix it anyway,
as libstdc++ won't do this and as it can deal with arbitrary types, it even
can't do that generally).

2021-10-06  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/102571
* c-omp.c (c_finish_omp_atomic): Optimize the case where type has
padding, but the non-padding bits are contiguous set of bytes
by adjusting the memcmp call arguments instead of emitting
__builtin_clear_padding and then comparing all the type's bytes.

3 years agoc++: Implement C++23 P2242R3 - Non-literal variables (and labels and gotos) in conste...
Jakub Jelinek [Wed, 6 Oct 2021 08:28:31 +0000 (10:28 +0200)]
c++: Implement C++23 P2242R3 - Non-literal variables (and labels and gotos) in constexpr functions [PR102612]

The following patch implements C++23 P2242R3 - Non-literal variables
(and labels and gotos) in constexpr functions.
I think it is mostly straightforward, don't diagnose certain
statements/declarations just because of their presence in
constexpr/consteval functions, but (except for the non-literal type
var declarations which ought to be caught by e.g. constructor or
destructor call during evaluation not being constexpr and for
labels which are now always allowed) diagnose it during constexpr
evaluation.

2021-10-06  Jakub Jelinek  <jakub@redhat.com>

PR c++/102612
gcc/c-family/
* c-cppbuiltin.c (c_cpp_builtins): For -std=c++23 predefine
__cpp_constexpr to 202110L rather than 201907L.
gcc/cp/
* parser.c (cp_parser_jump_statement): Implement C++23 P2242R3.
Allow goto expressions in constexpr function bodies for C++23.
Adjust error message for older standards to mention it.
* decl.c (start_decl): Allow static and thread_local declarations
in constexpr function bodies for C++23.  Adjust error message for
older standards to mention it.
* constexpr.c (ensure_literal_type_for_constexpr_object): Allow
declarations of variables with non-literal type in constexpr function
bodies for C++23.  Adjust error message for older standards to mention
it.
(cxx_eval_constant_expression) <case DECL_EXPR>: Diagnose declarations
of initialization of static or thread_local vars.
(cxx_eval_constant_expression) <case GOTO_EXPR>: Diagnose goto
statements for C++23.
(potential_constant_expression_1) <case DECL_EXPR>: Swap the
CP_DECL_THREAD_LOCAL_P and TREE_STATIC checks.
(potential_constant_expression_1) <case LABEL_EXPR>: Allow labels for
C++23.  Adjust error message for older standards to mention it.
gcc/testsuite/
* g++.dg/cpp23/feat-cxx2b.C: Expect __cpp_constexpr 202110L rather
than 201907L.
* g++.dg/cpp23/constexpr-nonlit1.C: New test.
* g++.dg/cpp23/constexpr-nonlit2.C: New test.
* g++.dg/cpp23/constexpr-nonlit3.C: New test.
* g++.dg/cpp23/constexpr-nonlit4.C: New test.
* g++.dg/cpp23/constexpr-nonlit5.C: New test.
* g++.dg/cpp23/constexpr-nonlit6.C: New test.
* g++.dg/diagnostic/constexpr1.C: Only expect some diagnostics for
c++20_down.
* g++.dg/cpp1y/constexpr-label.C: Likewise.
* g++.dg/cpp1y/constexpr-neg1.C: Likewise.
* g++.dg/cpp2a/constexpr-try5.C: Likewise.  Adjust some expected
wording.
* g++.dg/cpp2a/constexpr-dtor3.C: Likewise.
* g++.dg/cpp2a/consteval3.C: Likewise.  Add effective target c++20
and remove dg-options.

3 years agolibcpp: Implement C++23 P2334R1 - #elifdef/#elifndef
Jakub Jelinek [Wed, 6 Oct 2021 08:13:51 +0000 (10:13 +0200)]
libcpp: Implement C++23 P2334R1 - #elifdef/#elifndef

This patch implements C++23 P2334R1, which is easy because Joseph has done
all the hard work for C2X already.
Unlike the C N2645 paper, the C++ P2334R1 contains one important addition
(but not in the normative text):
"While this is a new preprocessor feature and cannot be treated as a defect
report, implementations that support older versions of the standard are
encouraged to implement this feature in the older language modes as well
as C++23."
so there are different variants how to implement it.
One is ignoring that sentence and only implementing it
for -std=c++23/-std=gnu++23 like it is only implemented for -std=c2x.
Another option would be to implement it also in the older GNU modes but
not in the C/CXX modes (but it would be strange if we did that just for
C++ and not for C).
Yet another option is to enable it unconditionally.
And yet another option would be to enable it unconditionally but emit
a warning (or pedwarn) when it is seen.
Note, when it is enabled for the older language modes, as Joseph wrote
in the c11-elifdef-1.c testcase, it can result e.g. in rejecting previously
valid code:
 #define A
 #undef B
 #if 0
 #elifdef A
 #error "#elifdef A applied"
 #endif
 #if 0
 #elifndef B
 #error "#elifndef B applied"
 #endif
Note, seems clang went the enable it unconditionally in all standard
versions of both C and C++, no warnings or anything whatsoever, so
essentially treated it as a DR that changed behavior of e.g. the above code.
After feedback, this option enables #elifdef/#elifndef for -std=c2x
and -std=c++2{b,3} and enables it also for -std=gnu*, but for GNU modes
older than C2X or C++23 if -pedantic it emits a pedwarn on the directives
that either would be rejected in the corresponding -std=c* modes, e.g.
  #if 1
  #elifdef A // pedwarn if -pedantic
  #endif
or when the directives would be silently accepted, but when they are
recognized it changes behavior, so e.g.
  #define A
  #if 0
  #elifdef A // pedwarn if -pedantic
  #define M 1
  #endif
It won't pedwarn if the directives would be silently ignored and wouldn't
change anything, like:
  #define A
  #if 0
  #elifndef A
  #define M 1
  #endif
or
  #undef B
  #if 0
  #elifdef B
  #define M 1
  #endif

2021-10-06  Jakub Jelinek  <jakub@redhat.com>

libcpp/
* init.c (lang_defaults): Implement P2334R1, enable elifdef for
-std=c++23 and -std=gnu++23.
* directives.c (_cpp_handle_directive): Support elifdef/elifndef if
either CPP_OPTION (pfile, elifdef) or !CPP_OPTION (pfile, std).
(do_elif): For older non-std modes if pedantic pedwarn about
#elifdef/#elifndef directives that change behavior.
gcc/testsuite/
* gcc.dg/cpp/gnu11-elifdef-1.c: New test.
* gcc.dg/cpp/gnu11-elifdef-2.c: New test.
* gcc.dg/cpp/gnu11-elifdef-3.c: New test.
* gcc.dg/cpp/gnu11-elifdef-4.c: New test.
* g++.dg/cpp/elifdef-1.C: New test.
* g++.dg/cpp/elifdef-2.C: New test.
* g++.dg/cpp/elifdef-3.C: New test.
* g++.dg/cpp/elifdef-4.C: New test.
* g++.dg/cpp/elifdef-5.C: New test.
* g++.dg/cpp/elifdef-6.C: New test.
* g++.dg/cpp/elifdef-7.C: New test.

3 years agoFortran: Fix deprecate warning with parameter
Tobias Burnus [Wed, 6 Oct 2021 06:47:40 +0000 (08:47 +0200)]
Fortran: Fix deprecate warning with parameter

Only warn with !GCC$ ATTRIBUTES DEPRECATED if
deprecated PARMETERS are actually used.

gcc/fortran/ChangeLog:

* resolve.c (resolve_values): Only show
deprecated warning if attr.referenced.

gcc/testsuite/ChangeLog:

* gfortran.dg/attr_deprecated-2.f90: New test.

3 years ago[gimple-isel] Remove redundant if condition.
prathamesh.kulkarni [Wed, 6 Oct 2021 05:51:13 +0000 (11:21 +0530)]
[gimple-isel] Remove redundant if condition.

gcc/ChangeLog:
* gimple-isel.cc (gimple_expand_vec_cond_expr): Remove redundant if
condition.

3 years agoc++: defaulted <=> with bitfields [PR102490]
Jakub Jelinek [Fri, 1 Oct 2021 15:07:17 +0000 (17:07 +0200)]
c++: defaulted <=> with bitfields [PR102490]

The testcases in the patch are either miscompiled or ICE with checking,
because the defaulted operator== is synthesized too early (but only if
constexpr), when the corresponding class type is still incomplete type.  The
problem is that at that point the bitfield FIELD_DECLs still have as
TREE_TYPE their underlying type rather than integral type with their
precision and when layout_class_type is called for the class soon after
that, it changes those types but the COMPONENT_REFs type stay the way that
they were during the operator== synthesize_method type and the middle-end is
then upset by the mismatch of types.  As what exact type will be given isn't
just a one liner but quite long code especially for over-sized bitfields, I
think it is best to just not synthesize the comparison operators so early
and call defaulted_late_check for them once again as soon as the class is
complete.

This is also a problem for virtual operator<=>, where we need to compare the
noexcept-specifier to validate the override before the class is complete.
Rather than try to defer that comparison, maybe_instantiate_noexcept now
calls maybe_synthesize_method, which calls build_comparison_op in
non-defining mode if the class isn't complete yet.  In that situation we
also might not have base fields yet, so we look in the binfo for the bases.

Co-authored-by: Jason Merrill <jason@redhat.com>
2021-10-01  Jakub Jelinek  <jakub@redhat.com>

PR c++/98712
PR c++/102490
* cp-tree.h (maybe_synthesize_method): Declare.
* method.c (genericize_spaceship): Use
LOOKUP_NORMAL | LOOKUP_NONVIRTUAL | LOOKUP_DEFAULTED instead of
LOOKUP_NORMAL for flags.
(comp_info): Remove defining member.  Add complain, code, retcat.
(comp_info::comp_info): Adjust.
(do_one_comp): Split out from build_comparison_op.   Use
LOOKUP_NORMAL | LOOKUP_NONVIRTUAL | LOOKUP_DEFAULTED instead of
LOOKUP_NORMAL for flags.
(build_comparison_op): Add defining argument. Adjust comp_info
construction.  Use defining instead of info.defining.  Assert that
if defining, ctype is a complete type.  Walk base binfos.
(synthesize_method, maybe_explain_implicit_delete,
explain_implicit_non_constexpr): Adjust build_comparison_op callers.
(maybe_synthesize_method): New function.
* class.c (check_bases_and_members): Don't call defaulted_late_check
for sfk_comparison.
(finish_struct_1): Call it here instead after class has been
completed.
* pt.c (maybe_instantiate_noexcept): Call maybe_synthesize_method
instead of synthesize_method.

* g++.dg/cpp2a/spaceship-synth8.C (std::strong_ordering): Provide
more complete definition.
(std::strong_ordering::less, std::strong_ordering::equal,
std::strong_ordering::greater): Define.
* g++.dg/cpp2a/spaceship-synth12.C: New test.
* g++.dg/cpp2a/spaceship-synth13.C: New test.
* g++.dg/cpp2a/spaceship-synth14.C: New test.
* g++.dg/cpp2a/spaceship-eq11.C: New test.
* g++.dg/cpp2a/spaceship-eq12.C: New test.
* g++.dg/cpp2a/spaceship-eq13.C: New test.

3 years agoDaily bump.
GCC Administrator [Wed, 6 Oct 2021 00:16:30 +0000 (00:16 +0000)]
Daily bump.

3 years agoNot add initialization for variables been initialized by FEs [PR102359]
qing zhao [Tue, 5 Oct 2021 23:14:00 +0000 (16:14 -0700)]
Not add initialization for variables been initialized by FEs [PR102359]

C++ FE creates proxy variables, which have associated DECL_VALUE_EXPR
and have been initialized by FE. For such auto variable, we should not
add initialization when -ftrivial-auto-var-init presents.

PR middle-end/102359

gcc/ChangeLog:

2021-10-05  qing zhao  <qing.zhao@oracle.com>

* gimplify.c (gimplify_decl_expr): Not add initialization for an
auto variable when it has been initialized by frontend.

gcc/testsuite/ChangeLog:

2021-10-05  qing zhao  <qing.zhao@oracle.com>

* g++.dg/pr102359_1.C: New test.
* g++.dg/pr102359_2.C: New test.

3 years agocompiler: workaround for C++ build template matching quirk
Than McIntosh [Tue, 5 Oct 2021 20:25:45 +0000 (16:25 -0400)]
compiler: workaround for C++ build template matching quirk

Tweak a couple of places in the types code to use nullptr instead of
NULL to work around a template matching quirk when using certain build
compilers.

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

3 years agoc++: Fix apply_identity_attributes [PR102548]
Jakub Jelinek [Tue, 5 Oct 2021 20:28:38 +0000 (22:28 +0200)]
c++: Fix apply_identity_attributes [PR102548]

The following testcase ICEs on x86_64-linux with -m32 due to a bug in
apply_identity_attributes.  The function is being smart and attempts not
to duplicate the chain unnecessarily, if either there are no attributes
that affect type identity or there is possibly empty set of attributes
that do not affect type identity in the chain followed by attributes
that do affect type identity, it reuses that attribute chain.

The function mishandles the cases where in the chain an attribute affects
type identity and is followed by one or more attributes that don't
affect type identity (and then perhaps some further ones that do).

There are two bugs.  One is that when we notice first attribute that
doesn't affect type identity after first attribute that does affect type
identity (with perhaps some further such attributes in the chain after it),
we want to put into the new chain just attributes starting from
(inclusive) first_ident and up to (exclusive) the current attribute a,
but the code puts into the chain all attributes starting with first_ident,
including the ones that do not affect type identity and if e.g. we have
doesn't0 affects1 doesn't2 affects3 affects4 sequence of attributes, the
resulting sequence would have
affects1 doesn't2 affects3 affects4 affects3 affects4
attributes, i.e. one attribute that shouldn't be there and two attributes
duplicated.  That is fixed by the a2 -> a2 != a change.

The second one is that we ICE once we see second attribute that doesn't
affect type identity after an attribute that affects it.  That is because
first_ident is set to error_mark_node after handling the first attribute
that doesn't affect type identity (i.e. after we've copied the
[first_ident, a) set of attributes to the new chain) to denote that from
that time on, each attribute that affects type identity should be copied
whenever it is seen (the if (as && as->affects_type_identity) code does
that correctly).  But that condition is false and first_ident is
error_mark_node, we enter else if (first_ident) and use TREE_PURPOSE
/TREE_VALUE/TREE_CHAIN on error_mark_node, which ICEs.  When
first_ident is error_mark_node and a doesn't affect type identity,
we want to do nothing.  So that is the && first_ident != error_mark_node
chunk.

2021-10-05  Jakub Jelinek  <jakub@redhat.com>

PR c++/102548
* tree.c (apply_identity_attributes): Fix handling of the
case where an attribute in the list doesn't affect type
identity but some attribute before it does.

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

3 years agoDarwin, D: Fix bootstrap when target does not support -Bstatic/dynamic.
Iain Sandoe [Tue, 5 Oct 2021 18:54:30 +0000 (19:54 +0100)]
Darwin, D: Fix bootstrap when target does not support -Bstatic/dynamic.

This fixes a bootstrap fail because saw_static_libcxx was unused for
targets without support for -Bstatic/dynamic.

The fix applied pushes the -static-libstdc++ back onto the command
line, which allows a target to substitute a static version of the
c++ standard library using specs.

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

* d-spec.cc (lang_specific_driver): Push the -static-libstdc++
option back onto the command line for targets without support
for -Bstatic/dynamic.

3 years agoc++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547]
Patrick Palka [Tue, 5 Oct 2021 19:35:21 +0000 (15:35 -0400)]
c++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547]

Here during partial ordering of the two partial specializations we end
up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash shortly
thereafter because uses_template_parms(parms) calls potential_const_expr
which doesn't handle NONTYPE_ARGUMENT_PACK.

This patch fixes this by extending potential_constant_expression to handle
NONTYPE_ARGUMENT_PACK appropriately.

PR c++/102547

gcc/cp/ChangeLog:

* constexpr.c (potential_constant_expression_1): Handle
NONTYPE_ARGUMENT_PACK.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/variadic-partial2.C: New test.
* g++.dg/cpp0x/variadic-partial2a.C: New test.

3 years agoLoosen loop crossing restriction in threader.
Aldy Hernandez [Tue, 5 Oct 2021 13:03:34 +0000 (15:03 +0200)]
Loosen loop crossing restriction in threader.

Crossing loops is generally discouraged from the threader, but we can
make an exception when we don't cross the latch or enter another loop,
since this is just an early exit out of the loop.

In fact, the whole threaded path is logically outside the loop.  This
has nice secondary effects.  For example, objects on the threaded path
will no longer necessarily be live throughout the loop, so we can get
register allocation improvements.  The threaded path can physically
move outside the loop resulting in better icache efficiency, etc.

Tested on x86-64 Linux, and on a visium-elf cross making sure that the
following tests do not have an abort in the final assembly:

gcc.c-torture/execute/960218-1.c
gcc.c-torture/execute/visium-pending-4.c
gcc.c-torture/execute/pr58209.c

gcc/ChangeLog:

* tree-ssa-threadupdate.c (jt_path_registry::cancel_invalid_paths):
Loosen restrictions

gcc/testsuite/ChangeLog:

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

3 years agolibstdc++: Ensure std::span and std::string_view are trivially copyable (P2251R1)
Jonathan Wakely [Tue, 5 Oct 2021 15:38:42 +0000 (16:38 +0100)]
libstdc++: Ensure std::span and std::string_view are trivially copyable (P2251R1)

The recently approved P2251R1 paper requires these types to be trivially
copyable. They always have been in libstdc++, but add tests to check it.

libstdc++-v3/ChangeLog:

* testsuite/21_strings/basic_string_view/requirements/trivially_copyable.cc:
New test.
* testsuite/23_containers/span/trivially_copyable.cc: New test.

3 years agoMark argument as unused
Jan-Benedict Glaw [Tue, 5 Oct 2021 15:16:49 +0000 (17:16 +0200)]
Mark argument as unused

The `loc` argument may or may not be used, depending on some #ifdefs.
Mark it as ATTRIBUTE_UNUSED, though it might be worth polishing the
whole target hook to not depend on the #ifdef'ed code at all.

gcc/ChangeLog:

* common/config/avr/avr-common.c (avr_handle_option): Mark
argument as ATTRIBUTE_UNUSED.

3 years agoFix s390 test to have pointer type for computed goto
Jeff Law [Tue, 5 Oct 2021 15:15:02 +0000 (11:15 -0400)]
Fix s390 test to have pointer type for computed goto

gcc/testsuite
* gcc.target/s390/pr80725.c: Ensure computed goto is used on
a pointer type.

3 years agoFix redefinition warning
Jan-Benedict Glaw [Tue, 5 Oct 2021 15:08:23 +0000 (17:08 +0200)]
Fix redefinition warning

gcc/ChangeLog:

* config/lm32/uclinux-elf.h (LINK_GCC_C_SEQUENCE_SPEC):
Undefine before redefinition.

3 years agolibstdc++: Simplify constraints for std::any construction
Jonathan Wakely [Mon, 4 Oct 2021 22:14:30 +0000 (23:14 +0100)]
libstdc++: Simplify constraints for std::any construction

libstdc++-v3/ChangeLog:

* include/bits/utility.h (__is_in_place_type_v): Define
variable template to detect in_place_type_t specializations.
(__is_in_place_type): Replace class template with alias
template using __is_in_place_type_v.
* include/std/any (any(T&&)): Check __is_in_place_type first and
avoid instantiating is_copy_constructible unnecessarily.

3 years agolibstdc++: Add test for std::cmp_greater
Jonathan Wakely [Tue, 5 Oct 2021 09:38:03 +0000 (10:38 +0100)]
libstdc++: Add test for std::cmp_greater

This was omitted from the commit that added these comparisons.

libstdc++-v3/ChangeLog:

* testsuite/20_util/integer_comparisons/greater.cc: New test.

3 years agolibstdc++: Improve test for printing volatile pointers
Jonathan Wakely [Tue, 5 Oct 2021 13:45:11 +0000 (14:45 +0100)]
libstdc++: Improve test for printing volatile pointers

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_ostream/inserters_other/char/volatile_ptr.cc:
Check result matches non-volatile pointer.

3 years agoAllow more kinds of invariant addresses in GIMPLE FE
Richard Biener [Tue, 5 Oct 2021 12:18:09 +0000 (14:18 +0200)]
Allow more kinds of invariant addresses in GIMPLE FE

The gimple FE is too restrictive in what it accepts as
literals, the following makes it also accept &a[10] for example.

2021-10-05  Richard Biener  <rguenther@suse.de>

PR c/102605
gcc/c/
* gimple-parser.c (c_parser_gimple_postfix_expression):
Accept more address _Literals.

gcc/testsuite/
* gcc.dg/gimplefe-46.c: New testcase.

3 years agoc++: templated static local var has value-dep addr [PR98930]
Patrick Palka [Tue, 5 Oct 2021 13:50:02 +0000 (09:50 -0400)]
c++: templated static local var has value-dep addr [PR98930]

Here uses_template_parms returns false for the dependent type A<&impl::i>,
which causes tsubst_aggr_type to think it's non-dependent and not bother
substituting into it, leading to breakage.

This patch fixes this by making has_value_dependent_address also return
true for templated static local variables.

PR c++/98930

gcc/cp/ChangeLog:

* pt.c (has_value_dependent_address): Return true for a static
local variable from a function template.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/nontype4.C: New test.
* g++.dg/cpp1z/nontype4a.C: New test.

3 years agogfortran.dg/gomp/pr43711.f90: Change dg-* for XFAIL->PASS
Tobias Burnus [Tue, 5 Oct 2021 12:28:10 +0000 (14:28 +0200)]
gfortran.dg/gomp/pr43711.f90: Change dg-* for XFAIL->PASS

gcc/testsuite/
* gfortran.dg/gomp/pr43711.f90: Add dg-error + dg-prune-output,
remove dg-excess-errors to change XFAIL to PASS.

3 years agoMake flow of option processing more readily visible
Richard Biener [Tue, 5 Oct 2021 10:35:57 +0000 (12:35 +0200)]
Make flow of option processing more readily visible

This moves calls to various option processing stages to one place,
toplev::main.

2021-10-05  Richard Biener  <rguenther@suse.de>

* toplev.c (no_backend): Remove global var.
(process_options): Pass in no_backend, move post_options
langhook call to toplev::main.
(do_compile): Pass in no_backend, move process_options call
to toplev::main.
(toplev::run_self_tests): Check no_backend at the caller.
(toplev::main): Call post_options and process_options
split out from do_compile, do self-tests only if
no_backend is initialized.

3 years agoAmend function names with UID when dumping with TDF_UID
Richard Biener [Tue, 5 Oct 2021 09:41:42 +0000 (11:41 +0200)]
Amend function names with UID when dumping with TDF_UID

The following makes sure to amend more function names with the
associated DECL_UID when dumping with TDF_UID, in particular
function names printed as part of calls and in the function header.
That allows one to more easily follow the call flow of PR102528
where coroutines cause three clones of the name 'test2' that are
not distinguishable otherwise.

2021-10-05  Richard Biener  <rguenther@suse.de>

* tree-cfg.c (dump_function_to_file): Dump the UID of the
function as part of the name when requested.
* tree-pretty-print.c (dump_function_name): Dump the UID when
requested and the langhook produced the actual name.

3 years agoMore .DEFERRED_INIT expansion rework
Richard Biener [Tue, 5 Oct 2021 07:28:20 +0000 (09:28 +0200)]
More .DEFERRED_INIT expansion rework

This avoids looking at the type size and instead uses the size
as passed to .DEFERRED_INIT to determine the size of the non-MEM
to be initialized.  It also arranges for possibly poly-int
inits to always use zero-initialization rather than not initializing
and when we need to pun puns the LHS instead of the constant value.

That correctly initializes the variable-size typed array in the
testcase for PR102285 and the SVE vector in PR102587 where for
the testcase I needed to add a SVE capable -march as to not
ICE later.

2021-10-05  Richard Biener  <rguenther@suse.de>

PR middle-end/102587
PR middle-end/102285
* internal-fn.c (expand_DEFERRED_INIT): Fall back to
zero-initialization as last resort, use the constant
size as given by the DEFERRED_INIT argument to build
the initializer.

* gcc.target/aarch64/sve/pr102587-1.c: Add -march=armv8.3-a+sve.
* gcc.target/aarch64/sve/pr102587-2.c: Likewise.

3 years agolibstdc++: Fix testcase for newly-implemented C++20 semantics [PR102535]
Jonathan Wakely [Tue, 5 Oct 2021 08:32:11 +0000 (09:32 +0100)]
libstdc++: Fix testcase for newly-implemented C++20 semantics [PR102535]

libstdc++-v3/ChangeLog:

PR c++/102535
* testsuite/20_util/is_trivially_constructible/value.cc: Adjust
expected value for C++20.

3 years agolibstdc++: Add noexcept to some std::function internals
Jonathan Wakely [Mon, 4 Oct 2021 14:22:58 +0000 (15:22 +0100)]
libstdc++: Add noexcept to some std::function internals

libstdc++-v3/ChangeLog:

* include/bits/std_function.h (_Any_data::_M_access): Add
noexcept.
(_Function_base::_Base_manager::_M_get_pointer): Likewise.
(_Function_base::_Base_manager::_M_not_empty_function):
Likewise.

3 years agolibstdc++: Support printing volatile pointers (P1147R1)
Jonathan Wakely [Mon, 4 Oct 2021 14:22:00 +0000 (15:22 +0100)]
libstdc++: Support printing volatile pointers (P1147R1)

To avoid needing to export a new symbol from the library (for now) the
new member function uses __attribute__((always_inline)).

libstdc++-v3/ChangeLog:

* include/std/ostream (operator<<(const volatile void*)):
Add new overload, as per P1147R1.
* testsuite/27_io/basic_ostream/inserters_other/char/volatile_ptr.cc:
New test.

3 years agolibstdc++: Update __cpp_lib_adaptor_iterator_pair_constructor value
Jonathan Wakely [Mon, 4 Oct 2021 19:16:47 +0000 (20:16 +0100)]
libstdc++: Update __cpp_lib_adaptor_iterator_pair_constructor value

I started implementing this feature before it was voted into the C++ WP,
and forgot to update the feature test macro after it was approved.

This defines it to the correct value, as specified in the C++23 draft.

libstdc++-v3/ChangeLog:

* include/bits/stl_queue.h
(__cpp_lib_adaptor_iterator_pair_constructor): Set to correct
value.
* include/bits/stl_stack.h
(__cpp_lib_adaptor_iterator_pair_constructor): Likewise.
* include/std/version
(__cpp_lib_adaptor_iterator_pair_constructor): Likewise.
* testsuite/23_containers/queue/cons_from_iters.cc: Update
expected value.
* testsuite/23_containers/stack/cons_from_iters.cc: Likewise.

3 years ago[Ada] Plug small loophole with boolean values
Eric Botcazou [Fri, 24 Sep 2021 13:20:22 +0000 (15:20 +0200)]
[Ada] Plug small loophole with boolean values

gcc/ada/

* gcc-interface/trans.c (gnat_to_gnu): Do not wrap boolean values
referenced in pragmas.

3 years ago[Ada] Do not unconditionally inline expression functions with -gnatd.8
Eric Botcazou [Thu, 12 Aug 2021 20:53:53 +0000 (22:53 +0200)]
[Ada] Do not unconditionally inline expression functions with -gnatd.8

gcc/ada/

* gcc-interface/trans.c (Subprogram_Body_to_gnu): Do not set the
DECL_DISREGARD_INLINE_LIMITS flag if -gnatd.8 is specified.

3 years ago[Ada] Fix latent bug in set_end_locus_from_node
Bob Duff [Wed, 11 Aug 2021 11:44:31 +0000 (07:44 -0400)]
[Ada] Fix latent bug in set_end_locus_from_node

gcc/ada/

* gcc-interface/trans.c (set_end_locus_from_node): Check that
Handled_Statement_Sequence is not Empty before calling
End_Label, because the Empty node has no End_Label, and
depending on the exact node layout chosen by gen_il, calling
End_Label might crash, or might work OK by accident.

3 years ago[Ada] Minor include directives placement adjustment
Eric Botcazou [Mon, 2 Aug 2021 18:53:30 +0000 (20:53 +0200)]
[Ada] Minor include directives placement adjustment

gcc/ada/

* gcc-interface/cuintp.c: Adjust placement of include directive.
* gcc-interface/targtyps.c: Likewise.

3 years ago[Ada] introduce stack scrub (strub) feature
Alexandre Oliva [Thu, 23 Sep 2021 12:46:54 +0000 (09:46 -0300)]
[Ada] introduce stack scrub (strub) feature

gcc/ada/

* doc/gnat_rm.rst: Add...
* doc/gnat_rm/security_hardening_features.rst: New.
* doc/gnat_rm/about_this_guide.rst: Link to new chapter.
* gnat_rm.texi: Regenerate.
* gcc-interface/utils.c (handle_strub_attribute): New.
(gnat_internal_attribute_table): Add strub.
* libgnat/a-except.adb: Make Rcheck_CE_* strub-callable.
* libgnat/a-except.ads (Raise_Exception): Likewise.
(Raise_Exception_Always): Likewise.
* libgnat/s-arit128.ads (Multiply_With_Ovflo_Check128):
Likewise.
* libgnat/s-arit64.ads (Multiply_With_Ovflo_Check64):
Likewise.
* libgnat/s-secsta.ads (SS_Allocate, SS_Mark, SS_Release):
Likewise.

3 years ago[Ada] Mark private component renaming as coming from source
Eric Botcazou [Thu, 23 Sep 2021 10:06:42 +0000 (12:06 +0200)]
[Ada] Mark private component renaming as coming from source

gcc/ada/

* exp_ch9.adb (Install_Private_Data_Declarations): Copy the Sloc of
components for the local renamings as well as the Comes_From_Source
flag, and also set Warnings_Off on them.  Use Nam local variable.

3 years ago[Ada] Add comments in Ada.Task_Initialization
Arnaud Charlet [Thu, 23 Sep 2021 10:04:41 +0000 (06:04 -0400)]
[Ada] Add comments in Ada.Task_Initialization

gcc/ada/

* libgnarl/a-tasini.ads (Set_Initialization_Handler): Update
comments.

3 years ago[Ada] Include errno.h in QNX specific part of the signal handling
Corentin Gay [Mon, 20 Sep 2021 15:27:37 +0000 (17:27 +0200)]
[Ada] Include errno.h in QNX specific part of the signal handling

gcc/ada/

* init.c (QNX): Add #include errno.h.

3 years ago[Ada] Remove left-overs of Unaligned_Valid attribute
Eric Botcazou [Thu, 23 Sep 2021 09:18:02 +0000 (11:18 +0200)]
[Ada] Remove left-overs of Unaligned_Valid attribute

gcc/ada/

* exp_attr.adb (Expand_Fpt_Attribute): Likewise.
* snames.ads-tmpl (Name_Unaligned_Valid): Delete.

3 years ago[Ada] Forbids use of Compile_Time_(Error|Warning) as configuration pragma
Etienne Servais [Mon, 20 Sep 2021 09:15:36 +0000 (11:15 +0200)]
[Ada] Forbids use of Compile_Time_(Error|Warning) as configuration pragma

gcc/ada/

* sem_prag.adb (Analyze_Pragma): Forbid use of
Compile_Time_(Error|Warning) as configuration pragma.
* doc/gnat_ugn/the_gnat_compilation_model.rst:
Compile_Time_(Error|Warning) and Compiler_Unit(_Warning) are not
configuration pragmas and shall not be listed as such.  The
following pragmas are either obsolete or undocumented:
No_Run_Time, Propagate_Exceptions, Rational, Ravenscar,
Restricted_Run_Time, Short_Descriptors, Universal_Data.  Fix
some typos (notably on Restriction_Warnings).
* doc/gnat_rm/implementation_defined_pragmas.rst: Move
Rename_Pragma documentation to alphabetical order.
* gnat_rm.texi, gnat_ugn.texi: Regenerate.

3 years ago[Ada] Add sys/time.h #include for QNX
Corentin Gay [Tue, 7 Sep 2021 12:18:06 +0000 (14:18 +0200)]
[Ada] Add sys/time.h #include for QNX

gcc/ada/

* adaint.c (QNX): Add #include for sys/time.h.

3 years ago[Ada] Issue a proper error message when no format specifier found
Pascal Obry [Thu, 16 Sep 2021 17:10:39 +0000 (19:10 +0200)]
[Ada] Issue a proper error message when no format specifier found

gcc/ada/

* libgnat/g-forstr.adb (Next_Format): When there is no more
format specifier found issue a proper error message instead of
raising a contraint error.

3 years ago[Ada] Fix negative numbers formatted with leading zero
Pascal Obry [Thu, 16 Sep 2021 14:23:55 +0000 (16:23 +0200)]
[Ada] Fix negative numbers formatted with leading zero

gcc/ada/

* libgnat/g-forstr.adb (Get_Formatted): Fix computation of the
number of zero to use in the formatted string. This was a wrong
copy/paste.

3 years ago[Ada] Minor code clean-up
Pascal Obry [Thu, 16 Sep 2021 14:23:07 +0000 (16:23 +0200)]
[Ada] Minor code clean-up

gcc/ada/

* libgnat/g-forstr.adb (Get_Formatted): Minor code clean-up.

3 years ago[Ada] Add missing functions to Wide_Wide_Characters Handling
Etienne Servais [Fri, 17 Sep 2021 10:29:46 +0000 (12:29 +0200)]
[Ada] Add missing functions to Wide_Wide_Characters Handling

gcc/ada/

* libgnat/a-zchhan.ads, libgnat/a-zchhan.adb
(Character_Set_Version, Is_Basic, To_Basic): New.
* libgnat/a-zchuni.ads, libgnat/a-zchuni.adb (Is_Basic,
To_Basic): New.

3 years ago[Ada] Improve error message on array aggregates
Yannick Moy [Thu, 16 Sep 2021 14:51:15 +0000 (16:51 +0200)]
[Ada] Improve error message on array aggregates

gcc/ada/

* sem_aggr.adb (Resolve_Array_Aggregate): Improve error message.

3 years ago[Ada] Front-end support for Storage_Model feature
Gary Dismukes [Mon, 13 Sep 2021 21:40:34 +0000 (17:40 -0400)]
[Ada] Front-end support for Storage_Model feature

gcc/ada/

* aspects.ads (type Aspect_Id): Add
Aspect_Designated_Storage_Model and Aspect_Storage_Model_Type.
(Aspect_Argument): Add associations for the above new aspects.
(Is_Representation_Aspect): Likewise.
(Aspect_Names, Aspect_Delay): Likewise.
* exp_ch4.adb (Expand_N_Allocator): Call Find_Storage_Op rather
than Find_Prim_Op.
* exp_intr.adb (Expand_Unc_Deallocation): Likewise.
* exp_util.ads (Find_Storage_Op): New function that locates
either a primitive operation of a storage pool or an operation
of a storage-model type specified in its Storage_Model_Type
aspect.
* exp_util.adb (Find_Storage_Op): New function that calls either
Find_Prim_Op or Get_Storage_Model_Type_Entity to locate a
storage-related operation that is associated with a type.
* sem_ch13.adb (Analyze_Aspects_At_Freeze_Point): Analyzes,
resolves, and validates the arguments of aspect
Designated_Storage_Model_Type.
(Analyze_Aspect_Specifications): Sets delay-related flags on
storage-model aspects when Delay_Required. Checks that aspect
Designated_Storage_Model is only specified for an access type
and that aspect Storage_Model_Type is only specified on an
immutably limited type. Also records such aspects for their
associated types.
(Check_Aspect_At_Freeze_Point): Resolve each of the argument
associations given for a Storage_Model_Type aspect.
(Resolve_Storage_Model_Type_Argument): New procedure that
resolves an argument given in the association for a given entity
name associated with a type with aspect Storage_Model_Type,
ensuring that it has the proper kind or profile.
(Validate_Storage_Model_Type_Aspect): New procedure that checks
the legality and completeness of the entity associations given
in a Storage_Model_Type aspect.
* sem_util.ads (package Storage_Model_Support): New nested
package that encapsulates a set of convenient utility functions
for retrieving entities, etc. associated with
storage-model-related types and objects.
(Get_Storage_Model_Type_Entity): New function to return a
specified entity associated with a type that has aspect
Storage_Model_Type.
(Has_Designated_Storage_Model_Aspect): New function that returns
whether a type has aspect Designated_Storage_Model.
(Has_Storage_Model_Type_Aspect): New function that returns
whether a type has aspect Storage_Model_Type.
(Storage_Model_Object): New function that returns the object
Entity_Id associated with a type's Designated_Storage_Model
aspect.
(Storage_Model_Type): New function that returns the type
associated with a storage-model object (when the object's type
specifies Storage_Model_Type).
(Storage_Model_Address_Type): New function that returns the
Address_Type associated with a type that has aspect
Storage_Model_Type.
(Storage_Model_Null_Address): New function that returns the
Null_Address constant associated with a type that has aspect
Storage_Model_Type.
(Storage_Model_Allocate): New function that returns the Allocate
procedure associated with a type that has aspect
Storage_Model_Type.
(Storage_Model_Deallocate): New function that returns the
Deallocate procedure associated with a type that has aspect
Storage_Model_Type.
(Storage_Model_Copy_From): New function that returns the
Copy_From procedure associated with a type that has aspect
Storage_Model_Type.
(Storage_Model_Copy_To): New function that returns the Copy_To
procedure associated with a type that has aspect
Storage_Model_Type.
(Storage_Model_Storage_Size): New function that returns the
Storage_Size function associated with a type that has aspect
Storage_Model_Type.
* sem_util.adb (package Storage_Model_Support): Body of new
nested package that contains the implementations the utility
functions declared in the spec of this package.
* snames.ads-tmpl: Add new names Name_Designated_Storage_Pool,
Name_Storage_Model, Name_Storage_Model_Type, Name_Address_Type,
Name_Copy_From, Name_Copy_To, and Name_Null_Address for the new
aspects and associated aspect arguments.

3 years ago[Ada] Note that -gnatd_t is used in CCG
Richard Kenner [Tue, 14 Sep 2021 12:28:09 +0000 (08:28 -0400)]
[Ada] Note that -gnatd_t is used in CCG

gcc/ada/

* debug.adb: Add documentation for -gnatd_t.

3 years ago[Ada] Add case to consider ENODEV a "file not found error"
Corentin Gay [Thu, 9 Sep 2021 09:57:06 +0000 (11:57 +0200)]
[Ada] Add case to consider ENODEV a "file not found error"

gcc/ada/

* sysdep.c (__gnat_is_file_not_found_error): Add else if case.

3 years ago[Ada] Rewrite operator entity in derived class-wide expressions
Piotr Trojanek [Fri, 10 Sep 2021 20:29:27 +0000 (22:29 +0200)]
[Ada] Rewrite operator entity in derived class-wide expressions

gcc/ada/

* exp_util.adb (Build_Class_Wide_Expression): Replace entities
of both identifiers and operator symbols.

3 years ago[Ada] Propagate Ghost status from parent to derived subprograms
Piotr Trojanek [Fri, 10 Sep 2021 20:27:20 +0000 (22:27 +0200)]
[Ada] Propagate Ghost status from parent to derived subprograms

gcc/ada/

* sem_ch3.adb (Derive_Subprogram): Copy ghost status from parent
to derived subprogram.

3 years ago[Ada] Add Default_Initial_Condition to type Unbounded_String
Joffrey Huguet [Fri, 10 Sep 2021 13:10:33 +0000 (15:10 +0200)]
[Ada] Add Default_Initial_Condition to type Unbounded_String

gcc/ada/

* libgnat/a-strunb.ads, libgnat/a-strunb__shared.ads: Add
Default_Initial_Condition to Unbounded_String.

3 years ago[Ada] Disable contract cases on formal containers
Claire Dross [Fri, 10 Sep 2021 10:05:27 +0000 (12:05 +0200)]
[Ada] Disable contract cases on formal containers

gcc/ada/

* libgnat/a-cfdlli.ads: Use pragma Assertion_Policy to disable
contract cases at execution.
* libgnat/a-cfinve.ads: Idem.
* libgnat/a-cofove.ads: Idem.
* libgnat/a-cfhase.ads: Idem.
* libgnat/a-cfhama.ads: Idem.
* libgnat/a-cforse.ads: Idem.
* libgnat/a-cforma.ads: Idem.

3 years ago[Ada] Improve message on missing all/for in pre-Ada-2022 modes
Bob Duff [Thu, 9 Sep 2021 16:24:32 +0000 (12:24 -0400)]
[Ada] Improve message on missing all/for in pre-Ada-2022 modes

gcc/ada/

* par-ch4.adb (P_Iterated_Component_Association): Parse these
features the same way in all language versions.  Move the call
to Error_Msg_Ada_2022_Feature into semantic analysis.
* sem_aggr.adb (Resolve_Iterated_Component_Association,
Resolve_Iterated_Association): Move the call to
Error_Msg_Ada_2022_Feature here from par-ch4.adb.

3 years ago[Ada] Improve error message on missing all/for in quantified expression
Yannick Moy [Thu, 9 Sep 2021 04:29:43 +0000 (06:29 +0200)]
[Ada] Improve error message on missing all/for in quantified expression

gcc/ada/

* sem_res.adb (Resolve): Recognize specially that case.

3 years ago[Ada] Proof of Ada.Strings.Maps
Yannick Moy [Thu, 2 Sep 2021 21:29:38 +0000 (23:29 +0200)]
[Ada] Proof of Ada.Strings.Maps

gcc/ada/

* libgnat/a-strmap.adb: Add ghost code for proof.
(To_Range): This is the most involved proof, as it requires
creating the result of the call to To_Domain as a ghost
variable, and show the unicity of this result in order to prove
the postcondition.
* libgnat/a-strmap.ads: (SPARK_Proof_Sorted_Character_Sequence):
New ghost function.
(To_Domain): Add postcondition regarding sorting of result.
(To_Range): Fix postcondition that should compare Length instead
of Last for the results of To_Domain and To_Range, as the value
of Last for an empty result is not specified in the Ada RM.

3 years ago[Ada] Proof of Ada.Characters.Handling
Yannick Moy [Tue, 31 Aug 2021 08:21:42 +0000 (10:21 +0200)]
[Ada] Proof of Ada.Characters.Handling

gcc/ada/

* libgnat/a-chahan.adb: Add loop invariants as needed to prove
subprograms.  Also use extended return statements where
appropriate and not done already.  Mark data with
Relaxed_Initialization where needed for initialization by parts.
Convert regular functions to expression functions where needed
for proof.
* libgnat/a-chahan.ads: Add postconditions.
* libgnat/a-strmap.ads (Model): New ghost function to create a
publicly visible model of the private data Character_Mapping,
needed in order to prove subprograms in Ada.Characters.Handling.

3 years agoAdjust gfortran.dg/predict-2.f90
Richard Biener [Tue, 5 Oct 2021 06:35:17 +0000 (08:35 +0200)]
Adjust gfortran.dg/predict-2.f90

After teaching VN to handle internal functions we now optimize
the redundant inner loop preheader check of the testcase making
the dump scanning fail because there's nothing to predict left.
The following restores the inner preheader check by making it
not redundant.

2021-10-05  Richard Biener  <rguenther@suse.de>

* gfortran.dg/predict-2.f90: Adjust to avoid redundant
inner loop preheader checking code.

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

3 years agoc-family: Implement -Warray-compare [PR97573]
Marek Polacek [Wed, 29 Sep 2021 15:45:24 +0000 (11:45 -0400)]
c-family: Implement -Warray-compare [PR97573]

This patch addresses one of my leftovers from GCC 11.  C++20 introduced
[depr.array.comp]: "Equality and relational comparisons between two operands
of array type are deprecated." so this patch adds -Warray-compare.  Since the
code in question is dubious (the comparison doesn't actually compare the array
elements), I've added this warning for C too, and enabled it in all C++ modes.

PR c++/97573

gcc/c-family/ChangeLog:

* c-common.h (do_warn_array_compare): Declare.
* c-warn.c (do_warn_array_compare): New.
* c.opt (Warray-compare): New option.

gcc/c/ChangeLog:

* c-typeck.c (parser_build_binary_op): Call do_warn_array_compare.

gcc/cp/ChangeLog:

* typeck.c (cp_build_binary_op): Call do_warn_array_compare.

gcc/ChangeLog:

* doc/invoke.texi: Document -Warray-compare.

gcc/testsuite/ChangeLog:

* c-c++-common/Warray-compare-1.c: New test.
* c-c++-common/Warray-compare-2.c: New test.

3 years agoavoid hardreg autoinit
Richard Biener [Mon, 4 Oct 2021 12:24:07 +0000 (14:24 +0200)]
avoid hardreg autoinit

This avoids initializating "uninitialized" hardregs like SP.

2021-10-04  Richard Biener  <rguenther@suse.de>

* gimplify.c (is_var_need_auto_init): DECL_HARD_REGISTER
variables are not to be initialized.

* gcc.dg/auto-init-hardreg-1.c: New testcase.

3 years agod: gdc driver ignores -static-libstdc++ when automatically linking libstdc++ library
Iain Buclaw [Sun, 3 Oct 2021 14:02:24 +0000 (16:02 +0200)]
d: gdc driver ignores -static-libstdc++ when automatically linking libstdc++ library

Adds handling of `-static-libstc++' in the gdc driver, so that libstdc++
is appropriately linked if libstdc++ is either needed or seen on the
command-line.

PR d/102574

gcc/d/ChangeLog:

* d-spec.cc (lang_specific_driver): Link libstdc++ statically if
-static-libstdc++ was given on command-line.

3 years agod: Save target node before parsing optimize options in case it changes.
Iain Buclaw [Sun, 3 Oct 2021 13:21:05 +0000 (15:21 +0200)]
d: Save target node before parsing optimize options in case it changes.

Fixes an ICE seen on PowerPC targets with the attr_optimize*.d tests in
the gdc.dg testsuite.

gcc/d/ChangeLog:

* d-attribs.cc (d_handle_optimize_attribute): Save target node before
calling parse_optimize_options in case it changes.

3 years agomiddle-end/102285 - refine .DEFERRED_INIT expansion
Richard Biener [Mon, 4 Oct 2021 09:34:27 +0000 (11:34 +0200)]
middle-end/102285 - refine .DEFERRED_INIT expansion

This refines the way we figure whether we are facing a register
that cannot be initialized by emitting a memset away from inspecting
expanded RTL of the LHS to using the predicates expand_assignment
is using to detect decls or MEM_REFs with non-memory DECL_RTL.

2021-10-04  Richard Biener  <rguenther@suse.de>

* expr.h (non_mem_decl_p): Declare.
(mem_ref_refers_to_non_mem_p): Likewise.
* expr.c (non_mem_decl_p): Export.
(mem_ref_refers_to_non_mem_p): Likewise.
* internal-fn.c (expand_DEFERRED_INIT): Do not expand the LHS
but check the base with mem_ref_refers_to_non_mem_p
and non_mem_decl_p.

* c-c++-common/pr102285.c: New testcase.

3 years agotree-optimization/102570 - teach VN about internal functions
Richard Biener [Mon, 4 Oct 2021 08:57:45 +0000 (10:57 +0200)]
tree-optimization/102570 - teach VN about internal functions

We're now using internal functions for a lot of stuff but there's
still missing VN support out of laziness.  The following instantiates
support and adds testcases for FRE and PRE (hoisting).

2021-10-04  Richard Biener  <rguenther@suse.de>

PR tree-optimization/102570
* tree-ssa-sccvn.h (vn_reference_op_struct): Document
we are using clique for the internal function code.
* tree-ssa-sccvn.c (vn_reference_op_eq): Compare the
internal function code.
(print_vn_reference_ops): Print the internal function code.
(vn_reference_op_compute_hash): Hash it.
(copy_reference_ops_from_call): Record it.
(visit_stmt): Remove the restriction around internal function
calls.
(fully_constant_vn_reference_p): Use fold_const_call and handle
internal functions.
(vn_reference_eq): Compare call return types.
* tree-ssa-pre.c (create_expression_by_pieces): Handle
generating calls to internal functions.
(compute_avail): Remove the restriction around internal function
calls.

* gcc.dg/tree-ssa/ssa-fre-96.c: New testcase.
* gcc.dg/tree-ssa/ssa-pre-33.c: Likewise.

3 years agolibstdc++: Implement P1518R2 for container deduction guides
Jonathan Wakely [Mon, 4 Oct 2021 13:04:20 +0000 (14:04 +0100)]
libstdc++: Implement P1518R2 for container deduction guides

This implements the C++23 P1518R2 proposal "Stop overconstraining
allocators in container deduction guides" as a fix for C++17 and C++20
too.

The changes allow class template argument deduction to ignore the type
of a constructor argument that initializes an allocator_type parameter
if the type should be deducible only from the other arguments. So for
the constructor vector(const vector&, const allocator_type&) only the
first argument is used for deduction, allowing the second argument to be
anything that is implicitly convertible to argument_type. Previously
deduction would fail or an ill-formed type would be deduced if the
second argument wasn't of type allocator_type.

The unordered containers do not need changes, because their
allocator-extended constructors use the allocator_type alias, which
comes from the dependent base class so is already a non-deduced context.

libstdc++-v3/ChangeLog:

* include/bits/forward_list.h (forward_list): Use non-deduced
context for allocator parameter of allocator-extended copy and
move constructors.
* include/bits/stl_bvector.h (vector<bool>): Likewise.
* include/bits/stl_deque.h (deque): Likewise.
* include/bits/stl_list.h (list): Likewise.
* include/bits/stl_map.h (map): Likewise.
* include/bits/stl_multimap.h (multimap): Likewise.
* include/bits/stl_multiset.h (multiset): Likewise.
* include/bits/stl_set.h (set): Likewise.
* include/bits/stl_vector.h (vector): Likewise.
* include/bits/stl_queue.h (queue, priority_queue): Do not
constrain Allocator template parameter of deduction guides that
have a Container parameter.
* include/bits/stl_stack.h (stack): Likewise.
* include/debug/deque (__gnu_debug::deque): Use non-deduced
context for allocator parameter of allocator-extended copy and
move constructors.
* include/debug/list (__gnu_debug::list): Likewise.
* include/debug/map.h (__gnu_debug::map): Likewise.
* include/debug/multimap.h (__gnu_debug::multimap): Likewise.
* include/debug/multiset.h (__gnu_debug::multiset): Likewise.
* include/debug/set.h (__gnu_debug::set): Likewise.
* include/debug/vector (__gnu_debug::vector): Likewise.
* testsuite/23_containers/deque/cons/deduction.cc: Test class
template argument deduction with non-deduced allocator
arguments.
* testsuite/23_containers/forward_list/cons/deduction.cc:
Likewise.
* testsuite/23_containers/list/cons/deduction.cc: Likewise.
* testsuite/23_containers/map/cons/deduction.cc: Likewise.
* testsuite/23_containers/multimap/cons/deduction.cc: Likewise.
* testsuite/23_containers/multiset/cons/deduction.cc: Likewise.
* testsuite/23_containers/priority_queue/deduction.cc: Likewise.
* testsuite/23_containers/queue/deduction.cc: Likewise.
* testsuite/23_containers/set/cons/deduction.cc: Likewise.
* testsuite/23_containers/stack/deduction.cc: Likewise.
* testsuite/23_containers/unordered_map/cons/deduction.cc:
Likewise.
* testsuite/23_containers/unordered_multimap/cons/deduction.cc:
Likewise.
* testsuite/23_containers/unordered_multiset/cons/deduction.cc:
Likewise.
* testsuite/23_containers/unordered_set/cons/deduction.cc:
Likewise.
* testsuite/23_containers/vector/cons/deduction.cc: Likewise.

3 years agolibstdc++: Add missing noexcept to std::variant helper
Jonathan Wakely [Mon, 4 Oct 2021 09:21:58 +0000 (10:21 +0100)]
libstdc++: Add missing noexcept to std::variant helper

libstdc++-v3/ChangeLog:

* include/std/variant (__detail::__variant::__as): Add missing
noexcept to first overload.

3 years agolibstdc++: Disable std::string{,_view} construction from nullptr (P2166R1)
Jonathan Wakely [Fri, 1 Oct 2021 20:27:24 +0000 (21:27 +0100)]
libstdc++: Disable std::string{,_view} construction from nullptr (P2166R1)

Implement this C++23 feature. Because construction from a null pointer
is undefined, we can implement it for C++11 and up, turning undefined
behaviour into a compilation error.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (basic_string(nullptr_t)): Define
as deleted.
(operator=(nullptr_t)): Likewise.
* include/bits/cow_string.h (basic_string(nullptr_t)): Likewise.
(operator=(nullptr_t)): Likewise.
* include/std/string_view (basic_string_view(nullptr_t)):
Likewise.
* testsuite/21_strings/basic_string/cons/char/nullptr.cc: New test.
* testsuite/21_strings/basic_string_view/cons/char/nonnull.cc:
Change dg-warning to dg-error.
* testsuite/21_strings/basic_string_view/cons/wchar_t/nonnull.cc:
Likewise.