]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
4 years agomatch.pd: Avoid (intptr_t)x eq/ne CST to x eq/ne (typeof x) CST opt in GENERIC when...
Jakub Jelinek [Tue, 29 Jun 2021 09:24:38 +0000 (11:24 +0200)] 
match.pd: Avoid (intptr_t)x eq/ne CST to x eq/ne (typeof x) CST opt in GENERIC when sanitizing [PR101210]

When we have (intptr_t) x == cst where x has REFERENCE_TYPE, this
optimization creates x == cst out of it where cst has REFERENCE_TYPE.
If it is done in GENERIC folding, it can results in ubsan failures
where the INTEGER_CST with REFERENCE_TYPE is instrumented.

Fixed by deferring it to GIMPLE folding in this case.

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

PR c++/101210
* match.pd ((intptr_t)x eq/ne CST to x eq/ne (typeof x) CST): Don't
perform the optimization in GENERIC when sanitizing and x has a
reference type.

* g++.dg/ubsan/pr101210.C: New test.

(cherry picked from commit 53fd7544aff6d0a18869017cb9bb921a7f5dcd04)

4 years agoc: Fix up c_parser_has_attribute_expression [PR101176]
Jakub Jelinek [Thu, 24 Jun 2021 13:58:02 +0000 (15:58 +0200)] 
c: Fix up c_parser_has_attribute_expression [PR101176]

This function keeps src_range member of the result uninitialized, which at
least under valgrind can show up later when those uninitialized location_t's
can make it into the IL or location_t hash tables.

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

PR c/101176
* c-parser.c (c_parser_has_attribute_expression): Set source range for
the result.

(cherry picked from commit 178fb8df9315f2f8f45b7fe5faf11a9c2912cc28)

4 years agoc: Fix C cast error-recovery [PR101171]
Jakub Jelinek [Thu, 24 Jun 2021 13:55:28 +0000 (15:55 +0200)] 
c: Fix C cast error-recovery [PR101171]

The following testcase ICEs during error-recovery, as build_c_cast calls
note_integer_operands on error_mark_node and that wraps it into
C_MAYBE_CONST_EXPR which is unexpected and causes ICE later on.
Seems most other callers of note_integer_operands check early if something
is error_mark_node and return before calling note_integer_operands on it.

The following patch fixes it by not calling on error_mark_node, another
possibility would be to handle error_mark_node in note_integer_operands and
just return it.

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

PR c/101171
* c-typeck.c (build_c_cast): Don't call note_integer_operands on
error_mark_node.

* gcc.dg/pr101171.c: New test.

(cherry picked from commit fdc5522fb04b4a820b28c4d1f16f54897f5978de)

4 years agostor-layout: Avoid DECL_BIT_FIELD_REPRESENTATIVE with NULL TREE_TYPE [PR101172]
Jakub Jelinek [Thu, 24 Jun 2021 10:22:14 +0000 (12:22 +0200)] 
stor-layout: Avoid DECL_BIT_FIELD_REPRESENTATIVE with NULL TREE_TYPE [PR101172]

finish_bitfield_representative has an early out if the field after a
bitfield has error_mark_node type, but that early out leads to TREE_TYPE
of the DECL_BIT_FIELD_REPRESENTATIVE being NULL, which breaks assumptions
on code that uses the DECL_BIT_FIELD_REPRESENTATIVE during error-recovery.

The following patch instead sets TREE_TYPE of the representative to
error_mark_node, something the users can deal with better.  At this point
the representative can be set as DECL_BIT_FIELD_REPRESENTATIVE for multiple
bitfields, so making sure that we clear the DECL_BIT_FIELD_REPRESENTATIVE
instead would be harder (but doable, e.g. with the error_mark_node TREE_TYPE
set by this patch set some flag in the caller and if the flag is there, walk
all the fields once again and clear all DECL_BIT_FIELD_REPRESENTATIVE that
have error_mark_node TREE_TYPE).

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

PR middle-end/101172
* stor-layout.c (finish_bitfield_representative): If nextf has
error_mark_node type, set repr type to error_mark_node too.

* gcc.dg/pr101172.c: New test.

(cherry picked from commit 65371066d8967560e3508af4a804e0ddb90acee7)

4 years agoDaily bump.
GCC Administrator [Sun, 18 Jul 2021 00:17:54 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sat, 17 Jul 2021 00:18:12 +0000 (00:18 +0000)] 
Daily bump.

4 years agoc++: alias CTAD in unevaluated context [PR101233]
Patrick Palka [Fri, 16 Jul 2021 20:21:13 +0000 (16:21 -0400)] 
c++: alias CTAD in unevaluated context [PR101233]

This is the alias CTAD version of the CTAD bug PR93248, and the fix is
the same: clear cp_unevaluated_operand so that the entire chain of
DECL_ARGUMENTS gets substituted.

PR c++/101233

gcc/cp/ChangeLog:

* pt.c (alias_ctad_tweaks): Clear cp_unevaluated_operand for
substituting DECL_ARGUMENTS.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-alias10.C: New test.

(cherry picked from commit a8b3861496bffae8b813ea196c1c5b27f79fbe69)

4 years agoc++: fn parm pack expansion inside constraint [PR100138]
Patrick Palka [Tue, 11 May 2021 02:33:04 +0000 (22:33 -0400)] 
c++: fn parm pack expansion inside constraint [PR100138]

This PR is about CTAD but the underlying problems are more general;
CTAD is a good trigger for them because of the necessary substitution
into constraints that deduction guide generation entails.

In the testcase below, when generating the implicit deduction guide for
the constrained constructor template for A, we substitute the generic
flattening map 'tsubst_args' into the constructor's constraints.  During
this substitution, tsubst_pack_expansion returns a rebuilt pack
expansion for sizeof...(xs), but doesn't carry over the
PACK_EXPANSION_LOCAL_P (and PACK_EXPANSION_SIZEOF_P) flag from the
original tree to the rebuilt one.  The flag is otherwise unset on the
original tree but gets set for the rebuilt tree from make_pack_expansion
since at_function_scope_p() is true (we're inside main).  This leads to
a crash during satisfaction when substituting into the pack expansion
because we don't have local_specializations set up (and it'd be set up
for us if PACK_EXPANSION_LOCAL_P is unset)

Similarly, tsubst_constraint needs to set cp_unevaluated so that the
substitution performed therein doesn't rely on local_specializations.
This avoids a crash during CTAD for C below.

gcc/cp/ChangeLog:

PR c++/100138
* constraint.cc (tsubst_constraint): Set up cp_unevaluated.
(satisfy_atom): Set up iloc_sentinel before calling
cxx_constant_value.
* pt.c (tsubst_pack_expansion): When returning a rebuilt pack
expansion, carry over PACK_EXPANSION_LOCAL_P and
PACK_EXPANSION_SIZEOF_P from the original pack expansion.

gcc/testsuite/ChangeLog:

PR c++/100138
* g++.dg/cpp2a/concepts-ctad4.C: New test.

(cherry picked from commit e7a9f085ffd34b0d7bc4b803c182b41494f609aa)

4 years agolibstdc++: Use function object for __decay_copy helper
Jonathan Wakely [Tue, 15 Jun 2021 13:39:02 +0000 (14:39 +0100)] 
libstdc++: Use function object for __decay_copy helper

By changing __cust_access::__decay_copy from a function template to a
function object we avoid ADL. That means it's fine to call it
unqualified (the compiler won't waste time doing ADL in associated
namespaces, and won't try to complete associated types).

This also makes some other minor simplications to other concepts for the
[range.access] CPOs.

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

* include/bits/iterator_concepts.h (__cust_access::__decay_copy):
Replace with function object.
(__cust_access::__member_begin, ___cust_access::_adl_begin): Use
__decay_copy unqualified.
* include/bits/ranges_base.h (__member_end, __adl_end):
Likewise. Use __range_iter_t for type of ranges::begin.
(__member_rend): Use correct value category for rbegin argument.
(__member_data): Use __decay_copy unqualified.
(__begin_data): Use __range_iter_t for type of ranges::begin.

(cherry picked from commit cb326a6442f09cb36b05ce556fc91e10bfeb0cf6)

4 years agoDaily bump.
GCC Administrator [Fri, 16 Jul 2021 00:17:59 +0000 (00:17 +0000)] 
Daily bump.

4 years agolibstdc++: Fix noexcept-specifier for ranges::empty
Jonathan Wakely [Mon, 14 Jun 2021 21:42:05 +0000 (22:42 +0100)] 
libstdc++: Fix noexcept-specifier for ranges::empty

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

* include/bits/ranges_base.h (ranges::empty): Check whether
conversion to bool can throw.
* testsuite/std/ranges/access/empty.cc: Check for correct
noexcept-specifier.

(cherry picked from commit f9598d89a9f5a327ecdfa6f6978a0cfbe4447111)

4 years agolibstdc++: Make <experimental/simd> depend on C++17
Jonathan Wakely [Wed, 30 Jun 2021 20:35:51 +0000 (21:35 +0100)] 
libstdc++: Make <experimental/simd> depend on C++17

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

* include/experimental/simd: Do not define anything pre-C++17.

(cherry picked from commit 36adced3b6b7cae17d7b42e4573bd0f4194b1f70)

4 years agoFortran - ICE in gfc_conv_expr_present initializing non-dummy class variable
Harald Anlauf [Wed, 14 Jul 2021 15:25:29 +0000 (17:25 +0200)] 
Fortran - ICE in gfc_conv_expr_present initializing non-dummy class variable

gcc/fortran/ChangeLog:

PR fortran/100949
* trans-expr.c (gfc_trans_class_init_assign): Call
gfc_conv_expr_present only for dummy variables.

gcc/testsuite/ChangeLog:

PR fortran/100949
* gfortran.dg/pr100949.f90: New test.

(cherry picked from commit 269ca408e2839d7f3554a91515d73d4d95352f68)

4 years agox86: Replace ix86_red_zone_size with ix86_red_zone_used
H.J. Lu [Fri, 11 Jun 2021 14:31:29 +0000 (07:31 -0700)] 
x86: Replace ix86_red_zone_size with ix86_red_zone_used

Add red_zone_used to machine_function to track if red zone is used.
When expanding function prologue, set red_zone_used to true if red
zone is used.

gcc/

PR target/101023
* config/i386/i386.c (ix86_expand_prologue): Set red_zone_used
to true if red zone is used.
(ix86_output_indirect_jmp): Replace ix86_red_zone_size with
ix86_red_zone_used.
* config/i386/i386.h (machine_function): Add red_zone_used.
(ix86_red_zone_size): Removed.
(ix86_red_zone_used): New.
* config/i386/i386.md (peephole2 patterns): Replace
ix86_red_zone_size with ix86_red_zone_used.

gcc/testsuite/

PR target/101023
* g++.target/i386/pr101023a.C: New test.
* g++.target/i386/pr101023b.C: Likewise.

(cherry picked from commit 3f04e3782536ad2f9cfbb8cfe6630e9f9dd8af4c)

4 years agox86: Don't enable UINTR in 32-bit mode
H.J. Lu [Fri, 9 Jul 2021 16:16:01 +0000 (09:16 -0700)] 
x86: Don't enable UINTR in 32-bit mode

UINTR is available only in 64-bit mode.  Since the codegen target is
unknown when the the gcc driver is processing -march=native, to properly
handle UINTR for -march=native:

1. Pass "arch [32|64]" and "tune [32|64]" to host_detect_local_cpu to
indicate 32-bit and 64-bit codegen.
2. Change ix86_option_override_internal to enable UINTR only in 64-bit
mode for -march=CPU when PTA_CPU includes PTA_UINTR.

gcc/

PR target/101395
* config/i386/driver-i386.c (host_detect_local_cpu): Check
"arch [32|64]" and "tune [32|64]" for 32-bit and 64-bit codegen.
Enable UINTR only for 64-bit codegen.
* config/i386/i386-options.c
(ix86_option_override_internal::DEF_PTA): Skip PTA_UINTR if not
in 64-bit mode.
* config/i386/i386.h (ARCH_ARG): New.
(CC1_CPU_SPEC): Pass "[arch|tune] 32" for 32-bit codegen and
"[arch|tune] 64" for 64-bit codegen.

gcc/testsuite/

PR target/101395
* gcc.target/i386/pr101395-1.c: New test.
* gcc.target/i386/pr101395-2.c: Likewise.
* gcc.target/i386/pr101395-3.c: Likewise.

(cherry picked from commit cc11b924bfe7752edbba052ca71653f46a60887a)

4 years agodriver/101383 - handle -gtoggle in driver
Richard Biener [Fri, 9 Jul 2021 09:13:11 +0000 (11:13 +0200)] 
driver/101383 - handle -gtoggle in driver

The driver amends assembler options with for example --gdwarf-5
when debugging is enabled but the check for that does not consider
the effect of -gtoggle which is not handled in the common option
machinery.  The following alters debug_info_level according to
-gtoggle mimicing what process_options later does in the compiler.

This in particular avoids changing of the cc1-checksum with every
bootstrap (debug) cycle as we compute that from stage2 where we
use -g -gtoggle but with --gdwarf-5 and no debug info from the
compiler the assembler will fill the line table with the temporary
assembler file names.

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

PR driver/101383
* gcc.c (process_command): Process -gtoggle like process_options
would after parsing options.

(cherry picked from commit 4f3b383cf8825197e714a4a21852eca071f8e67e)

4 years agoDaily bump.
GCC Administrator [Thu, 15 Jul 2021 00:18:30 +0000 (00:18 +0000)] 
Daily bump.

4 years agoFix build_gt and build_lt for signed 1 bit values.
Andrew MacLeod [Wed, 30 Jun 2021 18:15:53 +0000 (14:15 -0400)] 
Fix build_gt and build_lt for signed 1 bit values.

Signed 1 bit values have a range of [-1, 0] but neither (0 - 1) nor (-1 + 1)
can be represented.  For signed values, add or subtract -1 as appropriate.

PR tree-optimization/101223
gcc/
* range-op.cc (build_lt): Add -1 for signed values.
(built_gt): Subtract -1 for signed values.

gcc/testsuite/
* gcc.dg/pr101223.c: New.

(cherry picked from commit 84f7bab89279ca1234fef88929c74caeda8cb55e)

4 years agoDo not continue propagating values which cannot be set properly.
Andrew MacLeod [Tue, 22 Jun 2021 21:46:05 +0000 (17:46 -0400)] 
Do not continue propagating values which cannot be set properly.

If the on-entry cache cannot properly represent a range, do not continue
trying to propagate it.

PR tree-optimization/101148
PR tree-optimization/101014
* gimple-range-cache.cc (ranger_cache::ranger_cache): Adjust.
(ranger_cache::~ranger_cache): Adjust.
(ranger_cache::block_range): Check if propagation disallowed.
(ranger_cache::propagate_cache): Disallow propagation if new value
can't be stored properly.
* gimple-range-cache.h (ranger_cache::m_propfail): New member.

4 years agoAdjust on_entry cache to indicate if the value was set properly.
Andrew MacLeod [Tue, 22 Jun 2021 21:21:32 +0000 (17:21 -0400)] 
Adjust on_entry cache to indicate if the value was set properly.

* gimple-range-cache.cc (class ssa_block_ranges): Adjust prototype.
(sbr_vector::set_bb_range): Return true.
(class sbr_sparse_bitmap): Adjust.
(sbr_sparse_bitmap::set_bb_range): Return value.
(block_range_cache::set_bb_range): Return value.
(ranger_cache::propagate_cache): Use return value to print msg.
* gimple-range-cache.h (class block_range_cache): Adjust.

4 years agoDisable poor value processing in ranger cache.
Andrew MacLeod [Wed, 23 Jun 2021 16:55:14 +0000 (12:55 -0400)] 
Disable poor value processing in ranger cache.

* gimple-range-cache.cc (ranger_cache::push_poor_value): Disable
poor value processing.

4 years agoDon't process lookups for debug statements in Ranger.
Andrew MacLeod [Tue, 8 Jun 2021 13:43:17 +0000 (09:43 -0400)] 
Don't process lookups for debug statements in Ranger.

Although PR 100781 is not an issue in GCC11, its possible that a similar
situation may arise.  The identical fix cannot be easily introduced.
With EVRP always running in hybrid mode, there is no need for ranger to
spawn a lookup for a debug statement in this release.

* gimple-range.cc (gimple_ranger::range_of_expr): Treat debug statments
as contextless queries to avoid additional lookups.

4 years agoImplement a sparse bitmap representation for Rangers on-entry cache.
Andrew MacLeod [Mon, 7 Jun 2021 17:18:55 +0000 (13:18 -0400)] 
Implement a sparse bitmap representation for Rangers on-entry cache.

Use a sparse representation for the on entry cache, and utilize it when
the number of basic blocks in the function exceeds param_evrp_sparse_threshold.

PR tree-optimization/100299
* gimple-range-cache.cc (class sbr_sparse_bitmap): New.
(sbr_sparse_bitmap::sbr_sparse_bitmap): New.
(sbr_sparse_bitmap::bitmap_set_quad): New.
(sbr_sparse_bitmap::bitmap_get_quad): New.
(sbr_sparse_bitmap::set_bb_range): New.
(sbr_sparse_bitmap::get_bb_range): New.
(sbr_sparse_bitmap::bb_range_p): New.
(block_range_cache::block_range_cache): initialize bitmap obstack.
(block_range_cache::~block_range_cache): Destruct obstack.
(block_range_cache::set_bb_range): Decide when to utilze the
sparse on entry cache.
* gimple-range-cache.h (block_range_cache): Add bitmap obstack.
* params.opt (-param=evrp-sparse-threshold): New.

(cherry picked from commit 9858cd1a6827ee7a928318acb5e86389f79b4012)

4 years agoImplement multi-bit aligned accessors for sparse bitmap.
Andrew MacLeod [Mon, 7 Jun 2021 17:12:01 +0000 (13:12 -0400)] 
Implement multi-bit aligned accessors for sparse bitmap.

Provide set/get routines to allow sparse bitmaps to be treated as an array
of multiple bit values. Only chunk sizes that are powers of 2 are supported.

* bitmap.c (bitmap_set_aligned_chunk): New.
(bitmap_get_aligned_chunk): New.
(test_aligned_chunk): New.
(bitmap_c_tests): Call test_aligned_chunk.
* bitmap.h (bitmap_set_aligned_chunk, bitmap_get_aligned_chunk): New.

(cherry picked from commit 5ad089a3c946aec655436fa3b0b50d6574b78197)

4 years agoClean up and virtualize the on-entry cache interface.
Andrew MacLeod [Fri, 7 May 2021 16:03:01 +0000 (12:03 -0400)] 
Clean up and virtualize the on-entry cache interface.

Cleanup/Virtualize the ssa_block_range class, and implement the current
vector approach as a derived class.
Allow memory allocation from the irange allocator obstack for easy freeing.

* gimple-range-cache.cc (ssa_block_ranges): Virtualize.
(sbr_vector): Renamed from ssa_block_cache.
(sbr_vector::sbr_vector): Allocate from obstack abd initialize.
(ssa_block_ranges::~ssa_block_ranges): Remove.
(sbr_vector::set_bb_range): Use varying and undefined cached values.
(ssa_block_ranges::set_bb_varying): Remove.
(sbr_vector::get_bb_range): Adjust assert.
(sbr_vector::bb_range_p): Adjust assert.
(~block_range_cache): No freeing loop required.
(block_range_cache::get_block_ranges): Remove.
(block_range_cache::set_bb_range): Inline get_block_ranges.
(block_range_cache::set_bb_varying): Remove.
* gimple-range-cache.h (set_bb_varying): Remove prototype.
* value-range.h (irange_allocator::get_memory): New.

(cherry picked from commit 14b0f37a644d7b59e1737fb275ec4fff044972a8)

4 years agoGenerate 128-bit int divide/modulus on power10.
Michael Meissner [Wed, 14 Jul 2021 17:23:51 +0000 (13:23 -0400)] 
Generate 128-bit int divide/modulus on power10.

This patch adds support for the VDIVSQ, VDIVUQ, VMODSQ, and VMODUQ
instructions to do 128-bit arithmetic.

Backported from master: 2021-07-07  Michael Meissner  <meissner@linux.ibm.com>

2021-07-14  Michael Meissner  <meissner@linux.ibm.com>

gcc/
PR target/100809
* config/rs6000/rs6000.md (udivti3): New insn.
(divti3): New insn.
(umodti3): New insn.
(modti3): New insn.

gcc/testsuite/
PR target/100809
* gcc.target/powerpc/p10-vdivq-vmodq.c: New test.

4 years agofix typo in attr_fnspec::verify
Alexandre Oliva [Wed, 14 Jul 2021 16:03:23 +0000 (13:03 -0300)] 
fix typo in attr_fnspec::verify

Odd-numbered indices describing argument access sizes in the fnspec
string can only hold 't' or a digit, as tested in the beginning of the
case.  When checking that the size-supplying argument does not have
additional information associated with it, the test that excludes the
't' possibility looks for it at the even position in the fnspec
string.  Oops.

This might yield false positives and negatives if a function has a
fnspec in which an argument uses a 't' access-size, and ('t' - '1')
happens to be the index of an argument described in an fnspec string.
Assuming ASCII encoding, it would take a function with at least 68
arguments described in fnspec.  Still, probably worth fixing.

for  gcc/ChangeLog

* tree-ssa-alias.c (attr_fnspec::verify): Fix index in
non-'t'-sized arg check.

(cherry picked from commit a7098d6ef4e4e799dab8ef925c62b199d707694b)

4 years agolibstdc++: Simplify basic_string_view::ends_with [PR 101361]
Jonathan Wakely [Tue, 13 Jul 2021 11:21:27 +0000 (12:21 +0100)] 
libstdc++: Simplify basic_string_view::ends_with [PR 101361]

The use of npos triggers a diagnostic as described in PR c++/101361.
This change replaces the use of npos with the exact length, which is
already known. We can further simplify it by inlining the effects of
compare and substr, avoiding the redundant range checks in the latter.

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

PR c++/101361
* include/std/string_view (ends_with): Use traits_type::compare
directly.

(cherry picked from commit 4d3eaeb4f505b0838c673ee28e7dba8687fc8272)

4 years agolibstdc++: Remove duplicate #include in <string_view>
Jonathan Wakely [Tue, 13 Jul 2021 11:09:37 +0000 (12:09 +0100)] 
libstdc++: Remove duplicate #include in <string_view>

When I added the new C++23 constructor I added a conditional include of
<bits/ranges_base.h>, which was already being included unconditionally.
This removes the unconditional include but changes the condition for the
other one, so it's used for C++20 as well.

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

* include/std/string_view: Only include <bits/ranges_base.h>
once, and only for C++20 and later.

(cherry picked from commit bd1eb556b910fd4853ea83291e495d40adbcdf81)

4 years agolibstdc++: Constrain std::as_writable_bytes [PR101411]
Jonathan Wakely [Mon, 12 Jul 2021 15:09:34 +0000 (16:09 +0100)] 
libstdc++: Constrain std::as_writable_bytes [PR101411]

The std::as_writable_bytes function should be constrained to only accept
writable spans. Currently it can be called but then gives an error in
the function body.

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

PR libstdc++/101411
* include/std/span (as_writable_bytes): Add requires-clause.
* testsuite/23_containers/span/101411.cc: New test.

(cherry picked from commit 9d4393af9d2b37b78eb5b1f84f5d4da3a6f7fba6)

4 years agoRevert x86_order_regs_for_local_alloc changes in r12-1669.
liuhongt [Thu, 24 Jun 2021 08:14:13 +0000 (16:14 +0800)] 
Revert x86_order_regs_for_local_alloc changes in r12-1669.

Still put general regs as first alloca order.

gcc/ChangeLog:

PR target/101185
* config/i386/i386.c (x86_order_regs_for_local_alloc):
Revert r12-1669.

gcc/testsuite/ChangeLog

PR target/101185
* gcc.target/i386/bitwise_mask_op-3.c: Add xfail to
temporarily avoid regression, eventually xfail should be
removed.

4 years agoDisparage slightly the mask register alternative for bitwise operations.
liuhongt [Tue, 15 Jun 2021 08:25:16 +0000 (16:25 +0800)] 
Disparage slightly the mask register alternative for bitwise operations.

The avx512 supports bitwise operations with mask registers, but the
throughput of those instructions is much lower than that of the
corresponding gpr version, so we would additionally disparages
slightly the mask register alternative for bitwise operations in the
LRA.

Also when allocano cost of GENERAL_REGS is same as MASK_REGS, allocate
MASK_REGS first since it has already been disparaged.

gcc/ChangeLog:

PR target/101142
* config/i386/i386.md: (*anddi_1): Disparage slightly the mask
register alternative.
(*and<mode>_1): Ditto.
(*andqi_1): Ditto.
(*andn<mode>_1): Ditto.
(*<code><mode>_1): Ditto.
(*<code>qi_1): Ditto.
(*one_cmpl<mode>2_1): Ditto.
(*one_cmplsi2_1_zext): Ditto.
(*one_cmplqi2_1): Ditto.
* config/i386/i386.c (x86_order_regs_for_local_alloc): Change
the order of mask registers to be before general registers.

gcc/testsuite/ChangeLog:

PR target/101142
* gcc.target/i386/spill_to_mask-1.c: Adjust testcase.
* gcc.target/i386/spill_to_mask-2.c: Adjust testcase.
* gcc.target/i386/spill_to_mask-3.c: Adjust testcase.
* gcc.target/i386/spill_to_mask-4.c: Adjust testcase.

4 years agotree-optimization/101445 - fix negative stride SLP vect with gaps
Richard Biener [Wed, 14 Jul 2021 09:06:58 +0000 (11:06 +0200)] 
tree-optimization/101445 - fix negative stride SLP vect with gaps

The following fixes the IV adjustment for the gap in a negative
stride SLP vectorization.  The adjustment was in the wrong direction,
now fixes as in the patch.

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

PR tree-optimization/101445
* tree-vect-stmts.c (vectorizable_load): Do the gap adjustment
of the IV in the correct direction for negative stride
accesses.

* gcc.dg/vect/pr101445.c: New testcase.

(cherry picked from commit a967a3efd39280fe3f5774e45490e991f8e99059)

4 years agoDaily bump.
GCC Administrator [Wed, 14 Jul 2021 00:18:23 +0000 (00:18 +0000)] 
Daily bump.

4 years agoc++: requires-expr with dependent extra args [PR101181]
Patrick Palka [Fri, 9 Jul 2021 14:20:25 +0000 (10:20 -0400)] 
c++: requires-expr with dependent extra args [PR101181]

Here we're crashing ultimately because the mechanism for delaying
substitution into a requires-expression (and constexpr if and pack
expansions) doesn't expect to see dependent args.  But we end up
capturing dependent args here during substitution into the default
template argument as part of coerce_template_parms for the dependent
specialization p<T>.

This patch enables the commented out code in add_extra_args for handling
this situation.  This isn't needed for pack expansions (as the
accompanying comment points out), and it doesn't seem strictly necessary
for constexpr if either, but for requires-expressions delaying even
dependent substitution is important for ensuring we don't evaluate
requirements out of order.

It turns out we also need to make a copy of the arguments when capturing
them so that coerce_template_parms doesn't later add to them and form an
unexpected cycle (REQUIRES_EXPR_EXTRA_ARGS (t) would indirectly point to t).
We also need to make tsubst_template_args handle missing template
arguments, since the arguments we capture from coerce_template_parms
and are incomplete at that point.

PR c++/101181

gcc/cp/ChangeLog:

* constraint.cc (tsubst_requires_expr): Pass complain/in_decl to
add_extra_args.
* cp-tree.h (add_extra_args): Add complain/in_decl parameters.
* pt.c (build_extra_args): Make a copy of args.
(add_extra_args): Add complain/in_decl parameters.  Enable the
code for handling the case where the extra arguments are
dependent.
(tsubst_pack_expansion): Pass complain/in_decl to
add_extra_args.
(tsubst_template_args): Handle missing template arguments.
(tsubst_expr) <case IF_STMT>: Pass complain/in_decl to
add_extra_args.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-requires26.C: New test.
* g++.dg/cpp2a/lambda-uneval16.C: New test.

(cherry picked from commit 2c699fd29829cd6115f78238dab7cab74f0a5009)

4 years agoc++: find_template_parameters and TEMPLATE_DECLs [PR101247]
Patrick Palka [Fri, 9 Jul 2021 14:20:22 +0000 (10:20 -0400)] 
c++: find_template_parameters and TEMPLATE_DECLs [PR101247]

r12-1989 fixed the testcase in the PR, but unfortunately the fix is
buggy: it breaks the case where the common template between the
TEMPLATE_DECL t and ctx_parms is the innermost template (as in
concepts-memtmpl5.C below).  This can be fixed by instead passing the
TREE_TYPE of ctmpl to common_enclosing_class when ctmpl is a class
template.

But even after that's fixed, the analogous case where the innermost
template is a partial specialization is still broken (as in
concepts-memtmpl5a.C below), because ctmpl is always a primary template.

So this patch instead takes a diferent approach that doesn't rely on
ctx_parms at all: when looking for the template parameters of a
TEMPLATE_DECL that are shared with the current template context, just
walk its DECL_CONTEXT.  As long as the template is not overly general
(e.g. we didn't pass it through most_general_template), this should give
us exactly what we want, since if a TEMPLATE_DECL can be referred to
from some template context then the template parameters it uses must all
be in-scope and contained in its DECL_CONTEXT.  This effectively makes
us treat TEMPLATE_DECLs more similarly to other _DECLs (whose DECL_CONTEXT
we also walk).

PR c++/101247

gcc/cp/ChangeLog:

* pt.c (any_template_parm_r) <case TEMPLATE_DECL>: Just walk the
DECL_CONTEXT.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-memtmpl4.C: Uncomment the commented out
example, which we now handle correctly.
* g++.dg/cpp2a/concepts-memtmpl5.C: New test.
* g++.dg/cpp2a/concepts-memtmpl5a.C: New test.

(cherry picked from commit f53e66019df819f55d424cc56f8b0ea81c074b55)

4 years agoc++: unqualified member template in constraint [PR101247]
Patrick Palka [Fri, 2 Jul 2021 17:54:57 +0000 (13:54 -0400)] 
c++: unqualified member template in constraint [PR101247]

Here any_template_parm_r is failing to mark the template parameters
implicitly used by the unqualified use of 'd' inside the constraint
because the code to do so assumes each level of a template parameter
list points to the corresponding primary template, but here the
parameter level for A in the out-of-line definition of A::B does not
(nor do the parameter levels for A and C in the definition of A::C),
which causes us to overlook the sharing.

So it seems we can't in general depend on the TREE_TYPE of a template
parameter level being non-empty here.  This patch partially fixes this
by rewriting the relevant part of any_template_parm_r to not depend on
the TREE_TYPE of outer levels.  We still depend on the innermost level
to point to the innermost primary template, so we still crash on the
commented out line in the below testcase.

PR c++/101247

gcc/cp/ChangeLog:

* pt.c (any_template_parm_r) <case TEMPLATE_DECL>: Rewrite to
use common_enclosing_class and to not depend on the TREE_TYPE
of outer levels pointing to the corresponding primary template.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit e3528ce197f8886869f95e8a8f901861a319851c)

4 years agoc++: cxx_eval_array_reference and empty elem type [PR101194]
Patrick Palka [Thu, 1 Jul 2021 00:44:52 +0000 (20:44 -0400)] 
c++: cxx_eval_array_reference and empty elem type [PR101194]

Here the initializer for x is represented as an empty CONSTRUCTOR due to
its empty element type.  So during constexpr evaluation of the ARRAY_REF
x[0], we end up trying to value initialize the omitted element at index 0,
which fails because the element type is not default constructible.

This patch makes cxx_eval_array_reference specifically handle the case
where the element type is an empty type.

PR c++/101194

gcc/cp/ChangeLog:

* constexpr.c (cxx_eval_array_reference): When the element type
is an empty type and the corresponding element is omitted, just
return an empty CONSTRUCTOR instead of attempting value
initialization.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-empty16.C: New test.

(cherry picked from commit a688c284dd3848b6c4ea553035f0f9769fb4fbc9)

4 years agoc++: alias CTAD and aggregate deduction cand [PR98832]
Patrick Palka [Thu, 24 Jun 2021 17:11:44 +0000 (13:11 -0400)] 
c++: alias CTAD and aggregate deduction cand [PR98832]

During alias CTAD, we're accidentally ignoring the aggregate deduction
candidate for the underlying template because this guide is added
separately via maybe_aggr_guide (which doesn't yet handle alias
templates) instead of via deduction_guides_for (which does).  This patch
makes maybe_aggr_guide handle alias templates in a manner similar to
deduction_guides_for.

PR c++/98832

gcc/cp/ChangeLog:

* pt.c (maybe_aggr_guide): Handle alias templates appropriately.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-alias9.C: New test.

(cherry picked from commit c761be53f6b62e22ac5de18c4aaf88648f64f5b7)

4 years agoc++: requires-expression folding [PR101182]
Patrick Palka [Thu, 24 Jun 2021 15:29:02 +0000 (11:29 -0400)] 
c++: requires-expression folding [PR101182]

Here we're crashing because cp_fold_function walks into the (templated)
requirements of a requires-expression outside a template, but the
folding routines aren't prepared to handle templated trees.  This patch
fixes this by making cp_fold use evaluate_requires_expr to fold a
requires-expression as a whole, which also means we no longer need to
explicitly do so during gimplification.  (Note that we delay folding
of such requires-expressions for sake of better diagnostics when one is
used as the condition of a failed static_assert.)

PR c++/101182

gcc/cp/ChangeLog:

* constraint.cc (evaluate_requires_expr): Adjust function comment.
* cp-gimplify.c (cp_genericize_r) <case REQUIRES_EXPR>: Move to ...
(cp_fold) <case REQUIRES_EXPR>: ... here.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit c06493dc30afbf65b14d783c7cd53f20877ef577)

4 years agolibstdc++: Reduce ranges::minmax/minmax_element comparison complexity
Patrick Palka [Fri, 18 Jun 2021 23:33:39 +0000 (19:33 -0400)] 
libstdc++: Reduce ranges::minmax/minmax_element comparison complexity

This rewrites ranges::minmax and ranges::minmax_element so that it
performs at most 3*N/2 many comparisons, as required by the standard.
In passing, this also fixes PR100387 by avoiding a premature std::move
in ranges::minmax and in std::shift_right.

PR libstdc++/100387

libstdc++-v3/ChangeLog:

* include/bits/ranges_algo.h (__minmax_fn::operator()): Rewrite
to limit comparison complexity to 3*N/2.
(__minmax_element_fn::operator()): Likewise.
(shift_right): Avoid premature std::move of __result.
* testsuite/25_algorithms/minmax/constrained.cc (test04, test05):
New tests.
* testsuite/25_algorithms/minmax_element/constrained.cc (test02):
Likewise.

(cherry picked from commit cc9c94d43dcfa98436152af9c00f011e9dab25f6)

4 years agoc++: access of dtor named by qualified template-id [PR100918]
Patrick Palka [Mon, 7 Jun 2021 16:02:08 +0000 (12:02 -0400)] 
c++: access of dtor named by qualified template-id [PR100918]

Here, when resolving the destructor named by Inner<int>::~Inner<int>
(which is valid until C++20) we end up in cp_parser_lookup_name called
indirectly from cp_parser_template_id to look up the name Inner from
the scope Inner<int>.  The lookup naturally finds the injected-class-name,
and because the flag is_template is true, we adjust this lookup result
to the TEMPLATE_DECL Inner.  We then check access of this adjusted
lookup result.  But this access check fails because the lookup scope is
Inner<int> and the context_for_name_lookup for the TEMPLATE_DECL is
Outer (whereas for the injected-class-name it's also Inner<int>).

The simplest fix seems to be to check access of the original lookup
result (the injected-class-name) instead of the adjusted result (the
TEMPLATE_DECL).  So this patch moves the access check in
cp_parser_lookup_name to before the injected-class-name adjustment.

PR c++/100918

gcc/cp/ChangeLog:

* parser.c (cp_parser_lookup_name): Check access of the lookup
result before we potentially adjust an injected-class-name to
its TEMPLATE_DECL.

gcc/testsuite/ChangeLog:

* g++.dg/template/access38.C: New test.

(cherry picked from commit 6cb35b606c39d5f21f3298c77bfbcaaef3fbc872)

4 years agoc++: Fix reference NTTP binding to noexcept fn [PR97420]
Patrick Palka [Wed, 26 May 2021 12:35:31 +0000 (08:35 -0400)] 
c++: Fix reference NTTP binding to noexcept fn [PR97420]

Here, in C++17 mode, convert_nontype_argument_function is rejecting
binding a non-noexcept function reference template parameter to a
noexcept function (encoded as the template argument '*(int (&) (int)) &f').

The first roadblock to making this work is that the argument is wrapped
an an implicit INDIRECT_REF, so we need to unwrap it before calling
strip_fnptr_conv.

The second roadblock is that the NOP_EXPR cast converts from a function
pointer type to a reference type while simultaneously removing the
noexcept qualification, and fnptr_conv_p doesn't consider this cast to
be a function pointer conversion.  This patch fixes this by making
fnptr_conv_p treat REFERENCE_TYPEs and POINTER_TYPEs interchangeably.

Finally, in passing, this patch also simplifies noexcept_conv_p by
removing a bunch of redundant checks already performed by its only
caller fnptr_conv_p.

PR c++/97420

gcc/cp/ChangeLog:

* cvt.c (noexcept_conv_p): Remove redundant checks and simplify.
(fnptr_conv_p): Don't call non_reference.  Use INDIRECT_TYPE_P
instead of TYPE_PTR_P.
* pt.c (convert_nontype_argument_function): Look through
implicit INDIRECT_REFs before calling strip_fnptr_conv.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit b4329e3dd6fb7c78948fcf9d2f5b9d873deec284)

4 years agomiddle-end/101291 - set loop copy of versioned loop
Richard Biener [Mon, 5 Jul 2021 09:53:07 +0000 (11:53 +0200)] 
middle-end/101291 - set loop copy of versioned loop

This fixes the vectorizer loop versioning code failing to clear
niter related info on the scalar loop as it assumed get_loop_copy
would work even for the outermost loop.  The patch makes that
assumption hold by adjusting the loop versioning code.

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

PR middle-end/101291
* cfgloopmanip.c (loop_version): Set the loop copy of the
versioned loop to the new loop.

(cherry picked from commit 38872c6c0db1b10b17d3913b277c499913208d0b)

4 years agotree-optimization/101394 - fix PRE full redundancy wrt abnormals
Richard Biener [Mon, 12 Jul 2021 08:49:03 +0000 (10:49 +0200)] 
tree-optimization/101394 - fix PRE full redundancy wrt abnormals

This avoids adding a copy from an abnormal picked up from PHI
translation much like we'd avoid inserting the translated
expression on pred edges.

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

PR tree-optimization/101394
* tree-ssa-pre.c (do_pre_regular_insertion): Avoid inserting
copies from abnormals for a full redundancy.

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

(cherry picked from commit 92343e0ba4d47f21ae20ffcb83d736bdbc15dae0)

4 years agomiddle-end/101423 - internal calls do not trap
Richard Biener [Mon, 12 Jul 2021 08:26:25 +0000 (10:26 +0200)] 
middle-end/101423 - internal calls do not trap

This adjusts gimple_could_trap_p to not consider internal function
calls to trap compared to indirect calls or calls to weak functions.

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

PR middle-end/101423
* gimple.c (gimple_could_trap_p_1): Internal function calls
do not trap.
* tree-eh.c (tree_could_trap_p): Likewise.

(cherry picked from commit 123d0a597beb6d9865f808bf15b0d67f2a8fd5b2)

4 years agotree-optimization/100778 - fix placement of trapping vectorized ops
Richard Biener [Thu, 1 Jul 2021 08:35:38 +0000 (10:35 +0200)] 
tree-optimization/100778 - fix placement of trapping vectorized ops

This avoids placing possibly trapping vectorized operations where
the corresponding scalar operation was possibly not executed.

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

PR tree-optimization/100778
* tree-vect-slp.c (vect_schedule_slp_node): Do not place trapping
vectorized ops ahead of their scalar BB.

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

(cherry picked from commit a3aaba68405751bae3f630669515b7ecdf77efa6)

4 years agotree-optimization/100778 - avoid cross-BB vectorization of trapping op
Richard Biener [Fri, 28 May 2021 12:26:06 +0000 (14:26 +0200)] 
tree-optimization/100778 - avoid cross-BB vectorization of trapping op

This avoids vectorizing a possibly trapping operation when lanes
are handled in different BBs.  I spotted this when working on the
originally reported issue in PR100778.

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

PR tree-optimization/100778
* tree-vect-slp.c (vect_build_slp_tree_1): Prevent possibly
trapping ops in different BBs.

* gcc.dg/vect/bb-slp-pr100778-1.c: New testcase.

(cherry picked from commit f7a07f5a5d8065e7f11133dd1f4ad3510ab2195b)

4 years agoDaily bump.
GCC Administrator [Tue, 13 Jul 2021 00:18:04 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Mon, 12 Jul 2021 00:18:13 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sun, 11 Jul 2021 00:18:12 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sat, 10 Jul 2021 00:18:32 +0000 (00:18 +0000)] 
Daily bump.

4 years agoc++: concepts TS and explicit specialization [PR101098]
Jason Merrill [Fri, 9 Jul 2021 17:50:01 +0000 (13:50 -0400)] 
c++: concepts TS and explicit specialization [PR101098]

duplicate_decls was not recognizing the explicit specialization as matching
the implicit specialization of g<Y> because
function_requirements_equivalent_p was seeing the C constraint on the
implicit one and not on the explicit.

PR c++/101098

gcc/cp/ChangeLog:

* decl.c (function_requirements_equivalent_p): Only compare
trailing requirements on a specialization.

gcc/testsuite/ChangeLog:

* g++.dg/concepts/explicit-spec1.C: New test.

4 years agoc++: missing dtor with -fno-elide-constructors [PR100838]
Jason Merrill [Mon, 31 May 2021 16:36:25 +0000 (12:36 -0400)] 
c++: missing dtor with -fno-elide-constructors [PR100838]

tf_no_cleanup only applies to the outermost TARGET_EXPR, and we already
clear it for nested calls in build_over_call, but in this case both
constructor calls came from convert_like, so we need to clear it in the
recursive call as well.  This revealed that we were adding an extra
ck_rvalue in direct-initialization cases where it was wrong.

For GCC 11, limit the changes to -fno-elide-constructors.

PR c++/100838

gcc/cp/ChangeLog:

* call.c (convert_like_internal): Clear tf_no_cleanup when
recursing.
(build_user_type_conversion_1): Only add ck_rvalue if
LOOKUP_ONLYCONVERTING.

gcc/testsuite/ChangeLog:

* g++.dg/init/no-elide2.C: New test.

4 years agoc++: argument pack with expansion [PR86355]
Jason Merrill [Wed, 26 May 2021 21:38:42 +0000 (17:38 -0400)] 
c++: argument pack with expansion [PR86355]

This testcase revealed that we were using PACK_EXPANSION_EXTRA_ARGS a lot
more than necessary; use_pack_expansion_extra_args_p meant to use it in the
case of corresponding arguments in different argument packs differing in
whether they are pack expansions, but it was mistakenly also returning true
for the case of a single argument pack containing both expansion and
non-expansion elements.

Surprisingly, just disabling that didn't lead to any regressions in the
testsuite; it seems other changes have prevented us getting to this point
for code that used to exercise it.  So this patch limits the check to
arguments in the same position in the packs, and asserts that we never
actually see a mismatch.

PR c++/86355

gcc/cp/ChangeLog:

* pt.c (use_pack_expansion_extra_args_p): Don't compare
args from the same argument pack.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/alias-decl-variadic2.C: New test.

4 years agoMissing piece in earlier change
Eric Botcazou [Fri, 9 Jul 2021 16:30:54 +0000 (18:30 +0200)] 
Missing piece in earlier change

gcc/ada/
* gcc-interface/utils.c (finish_subprog_decl): Remove obsolete line.

4 years agoipa-sra: Fix thinko when overriding safe_to_import_accesses (PR 101066)
Martin Jambor [Fri, 9 Jul 2021 14:09:53 +0000 (16:09 +0200)] 
ipa-sra: Fix thinko when overriding safe_to_import_accesses (PR 101066)

The "new" IPA-SRA has a more difficult job than the previous
not-truly-IPA version when identifying situations in which a parameter
passed by reference can be passed into a third function and only thee
converted to one passed by value (and possibly "split" at the same
time).

In order to allow this, two conditions must be fulfilled.  First the
call to the third function must happen before any modifications of
memory, because it could change the value passed by reference.
Second, in order to make sure we do not introduce new (invalid)
dereferences, the call must postdominate the entry BB.

The second condition is actually not necessary if the caller function
is also certain to dereference the pointer but the first one must
still hold.  Unfortunately, the code making this overriding decision
also happen to trigger when the first condition is not fulfilled.
This is fixed in the following patch.

gcc/ChangeLog:

2021-06-16  Martin Jambor  <mjambor@suse.cz>

PR ipa/101066
* ipa-sra.c (class isra_call_summary): New member
m_before_any_store, initialize it in the constructor.
(isra_call_summary::dump): Dump the new field.
(ipa_sra_call_summaries::duplicate): Copy it.
(process_scan_results): Set it.
(isra_write_edge_summary): Stream it.
(isra_read_edge_summary): Likewise.
(param_splitting_across_edge): Only override
safe_to_import_accesses if m_before_any_store is set.

gcc/testsuite/ChangeLog:

2021-06-16  Martin Jambor  <mjambor@suse.cz>

PR ipa/101066
* gcc.dg/ipa/pr101066.c: New test.

(cherry picked from commit 763121ccd908f52bc666f277ea2cf42110b3aad9)

4 years agoFix build failure on Windows with older binutils
Eric Botcazou [Fri, 9 Jul 2021 10:08:52 +0000 (12:08 +0200)] 
Fix build failure on Windows with older binutils

This is the build failure on Windows with binutils for which GNU as accepts
the --gdwarf-5 switch but GNU ld generates broken binaries with DWARF 5.

We already have the HAVE_LD_BROKEN_PE_DWARF5 kludge to disable DWARF 5 in
this case but it only tames the DWARF version in the compiler, so the
driver still passes --gdwarf-5 when invoked on an assembly file with -g.

gcc/
PR target/101377
* gcc.c (ASM_DEBUG_DWARF_OPTION): Set again to --gdwarf2 in
the case where HAVE_AS_WORKING_DWARF_N_FLAG is not defined
and HAVE_LD_BROKEN_PE_DWARF5 is defined.

4 years agoDaily bump.
GCC Administrator [Fri, 9 Jul 2021 00:18:01 +0000 (00:18 +0000)] 
Daily bump.

4 years agoc++: Fix noexcept with unevaluated operand [PR101087]
Marek Polacek [Thu, 8 Jul 2021 00:02:18 +0000 (20:02 -0400)] 
c++: Fix noexcept with unevaluated operand [PR101087]

It sounds plausible that this assert

  int f();
  static_assert(noexcept(sizeof(f())));

should pass: sizeof produces a std::size_t and its operand is not
evaluated, so it can't throw.  noexcept should only evaluate to
false for potentially evaluated operands.  Therefore I think that
check_noexcept_r shouldn't walk into operands of sizeof/decltype/
alignof/typeof.

PR c++/101087

gcc/cp/ChangeLog:

* cp-tree.h (unevaluated_p): New.
* except.c (check_noexcept_r): Use it.  Don't walk into
unevaluated operands.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit dee00bf6894be0cabb8f263c993357a6f8444f8b)

4 years agoDo not replace variable op variable in I/O implied DO loop replacement.
Thomas Koenig [Tue, 6 Jul 2021 05:04:09 +0000 (07:04 +0200)] 
Do not replace variable op variable in I/O implied DO loop replacement.

This PR came about because index expressions of the form k+k in
implied DO loops in I/O statements were considered for replacement
by array slices.

Fixed by only doing the transformation if the expression is of the
type expr OP contastant.

gcc/fortran/ChangeLog:

PR fortran/100227
* frontend-passes.c (traverse_io_block): Adjust test for
when a variable is eligible for the transformation to
array slice.

gcc/testsuite/ChangeLog:

PR fortran/100227
* gfortran.dg/implied_do_io_7.f90: New test.

(cherry picked from commit d7e3855d5dd8c001bb65dc7da1cda0249bfc2986)

4 years agofixincludes: AIX socket.h.
Clément Chigot [Mon, 5 Jul 2021 15:19:44 +0000 (11:19 -0400)] 
fixincludes: AIX socket.h.

Add more context to aix_externcpp1 selection to ensure
that the fix is correctly applied even in future AIX versions.

fixincludes/Changelog:
2021-07-01  Clément Chigot  <clement.chigot@atos.net>

* inclhack.def (aix_externcpp1): Improve select regexp.
* fixincl.x: Regenerate.
* tests/base/sys/socket.h: Update.

(cherry picked from commit 03b634c8e0d3e8628ced79fc4f40873e12a3039c)

4 years agoDaily bump.
GCC Administrator [Thu, 8 Jul 2021 00:18:04 +0000 (00:18 +0000)] 
Daily bump.

4 years agoRevert "c++: Improve init handling"
Jason Merrill [Wed, 7 Jul 2021 21:57:40 +0000 (17:57 -0400)] 
Revert "c++: Improve init handling"

Apparently looking through these codes means that in a template, we end up
feeding a TARGET_EXPR to fold_non_dependent_expr, which should never
happen.  This is a broader issue, but for now let's just revert the change.

This reverts commit d9288bd28e24c755a7216311ee5247e7c88270a6.

PR c++/101072

gcc/cp/ChangeLog:

* decl.c (check_initializer): Don't look through STMT_EXPR and
BIND_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-empty14.C: Add -fno-elide-constructors.

4 years agoc++: constexpr aggr init of empty class [PR101040]
Jason Merrill [Thu, 24 Jun 2021 21:32:02 +0000 (17:32 -0400)] 
c++: constexpr aggr init of empty class [PR101040]

This is basically the aggregate initializer version of PR97566; as in that
bug, we are trying to initialize empty field 'obj' in 'single' when there's
no CONSTRUCTOR entry for the 'single' base class subobject of 'derived'.  As
with that bug, the fix is to stop trying to add entries for empty fields,
this time in cxx_eval_bare_aggregate.

The change to the other function isn't necessary for this version of
the patch, but seems worthwhile for robustness anyway.

PR c++/101040
PR c++/97566

gcc/cp/ChangeLog:

* class.c (is_empty_field): Handle null argument.
* constexpr.c (cxx_eval_bare_aggregate): Discard initializer
for empty field.

gcc/testsuite/ChangeLog:

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

4 years agors6000: Harden mma_init_builtins
Peter Bergner [Wed, 7 Jul 2021 16:39:34 +0000 (11:39 -0500)] 
rs6000: Harden mma_init_builtins

The previous MMA patch added some fragile code to initialize its new
built-ins.  This patch hardens the initialization.

2021-07-07  Peter Bergner  <bergner@linux.ibm.com>

gcc/
* config/rs6000/rs6000-call.c (mma_init_builtins): Use VSX_BUILTIN_LXVP
and VSX_BUILTIN_STXVP.

(cherry picked from commit 6278065af07634278ba30029d92a82b089969baa)

4 years agors6000: Add MMA __builtin_vsx_lxvp and __builtin_vsx_stxvp built-ins
Peter Bergner [Fri, 2 Jul 2021 16:27:52 +0000 (11:27 -0500)] 
rs6000: Add MMA __builtin_vsx_lxvp and __builtin_vsx_stxvp built-ins

Add support for the __builtin_vsx_lxvp and __builtin_vsx_stxvp built-ins
to keep in sync with LLVM which added these earlier.

2021-07-02  Peter Bergner  <bergner@linux.ibm.com>

gcc/
* config/rs6000/rs6000-builtin.def (BU_MMA_PAIR_LD, BU_MMA_PAIR_ST):
New macros.
(__builtin_vsx_lxvp, __builtin_vsx_stxvp): New built-ins.
* config/rs6000/rs6000-call.c (rs6000_gimple_fold_mma_builtin): Expand
lxvp and stxvp built-ins.
(mma_init_builtins): Handle lxvp and stxvp built-ins.
(builtin_function_type): Likewise.
* doc/extend.texi (__builtin_vsx_lxvp, __builtin_mma_stxvp): Document.

gcc/testsuite/
* gcc.target/powerpc/mma-builtin-7.c: New test.
* gcc.target/powerpc/mma-builtin-8.c: New test.

(cherry picked from commit 42a9e4e1381ba14d8ef21b331494945c2f51e6be)

4 years agoBackport IEEE 128-bit min/max code.
Michael Meissner [Wed, 7 Jul 2021 16:01:37 +0000 (12:01 -0400)] 
Backport IEEE 128-bit min/max code.

This patch back ports 2 IEEE 128-bit min/max patches from the trunk to GCC
11.  One patch is from June 30th, 2021, and the other from July 1st, 2021.

2021-07-07  Michael Meissner  <meissner@linux.ibm.com>

gcc/
* config/rs6000/rs6000.c (rs6000_maybe_emit_fp_cmove): Add IEEE
128-bit floating point conditional move support.
(have_compare_and_set_mask): Add IEEE 128-bit floating point
types.
* config/rs6000/rs6000.md (mov<mode>cc, IEEE128 iterator): New insn.
(mov<mode>cc_p10, IEEE128 iterator): New insn.
(mov<mode>cc_invert_p10, IEEE128 iterator): New insn.
(fpmask<mode>, IEEE128 iterator): New insn.
(xxsel<mode>, IEEE128 iterator): New insn.

Backported from master:
    2021-07-01 Michael Meissner  <meissner@linux.ibm.com>

gcc/testsuite/
* gcc.target/powerpc/float128-cmove.c: New test.
* gcc.target/powerpc/float128-minmax-3.c: New test.

Backported from master:
    2021-07-01 Michael Meissner  <meissner@linux.ibm.com>

gcc/testsuite/
* gcc.target/powerpc/float128-minmax.c: Adjust expected code for
power10.
* lib/target-supports.exp (check_effective_target_has_arch_pwr10):
New.

Backported from master:
    2021-06-30 Michael Meissner  <meissner@linux.ibm.com>

4 years agotree-optimization/101229 - fix vectorizer SLP hybrid detection with PHIs
Richard Biener [Mon, 28 Jun 2021 09:05:46 +0000 (11:05 +0200)] 
tree-optimization/101229 - fix vectorizer SLP hybrid detection with PHIs

This fixes the missing handling of PHIs in gimple_walk_op which causes
the new vectorizer SLP hybrid detection scheme to fail.

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

PR tree-optimization/101229
* gimple-walk.c (gimple_walk_op): Handle PHIs.

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

(cherry picked from commit f80c4eaca0805bc9e68ed944519519c3dd1c12e1)

4 years agotree-optimization/101173 - fix interchange dependence checking
Richard Biener [Wed, 23 Jun 2021 07:59:28 +0000 (09:59 +0200)] 
tree-optimization/101173 - fix interchange dependence checking

This adjusts the loop interchange dependence checking to properly
guard all dependence checks with DDR_REVERSED_P or its inverse.

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

PR tree-optimization/101173
PR tree-optimization/101280
* gimple-loop-interchange.cc
(tree_loop_interchange::valid_data_dependences): Properly
guard all dependence checks with DDR_REVERSED_P or its
inverse.

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

4 years agomiddle-end/101156 - remove not working optimization in gimplification
Richard Biener [Tue, 22 Jun 2021 10:13:44 +0000 (12:13 +0200)] 
middle-end/101156 - remove not working optimization in gimplification

This removes a premature and not working optimization from the
gimplifier.  When gimplification is requested not to produce a SSA
name we try to avoid generating a copy when we did so anyway but
instead replace the LHS of its definition.  But that only works in
case there are no uses of the SSA name already which is something
we cannot easily check, so the following removes said optimization.

Statistics on the whole bootstrap shows we hit this optimization
only for libiberty/cp-demangle.c and overall we have 21652112
gimplifications where just 240 copies are elided.  Preserving
the optimization would require scanning the original expression
and the pre and post sequences for SSA names and uses, that seems
excessive to avoid these 240 copies.

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

PR middle-end/101156
* gimplify.c (gimplify_expr): Remove premature incorrect
optimization.

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

(cherry picked from commit b4e21c80462682c4e6e5e487fe87107b27f8b4bd)

4 years agotree-optimization/100923 - fix alias-ref construction wrt availability
Richard Biener [Tue, 8 Jun 2021 10:52:12 +0000 (12:52 +0200)] 
tree-optimization/100923 - fix alias-ref construction wrt availability

This PR shows that building an ao_ref from value-numbers is prone to
expose bogus contextual alias info to the oracle.  The following makes
sure to construct ao_refs from SSA names available at the program point
only.

On the way it modifies the awkward valueize_refs[_1] API.

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

PR tree-optimization/100923
* tree-ssa-sccvn.c (valueize_refs_1): Take a pointer to
the operand vector to be valueized.
(valueize_refs): Likewise.
(valueize_shared_reference_ops_from_ref): Adjust.
(valueize_shared_reference_ops_from_call): Likewise.
(vn_reference_lookup_3): Likewise.
(vn_reference_lookup_pieces): Likewise.  Re-valueize
with honoring availability when we are about to create
the ao_ref and valueized before.
(vn_reference_lookup): Likewise.
(vn_reference_insert_pieces): Adjust.

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

(cherry picked from commit 7a56d3d3e99cc77ad8a6a674870c814da6225675)

4 years agotree-optimization/101088 - fix SM invalidation issue
Richard Biener [Wed, 16 Jun 2021 07:49:18 +0000 (09:49 +0200)] 
tree-optimization/101088 - fix SM invalidation issue

When we face a sm_ord vs sm_unord for the same ref during
store sequence merging we assert that the ref is already marked
unsupported.  But it can be that it will only be marked so
during the ongoing merging so instead of asserting mark it here.

Also apply some optimization to not waste resources to search
for already unsupported refs.

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

PR tree-optimization/101088
* tree-ssa-loop-im.c (sm_seq_valid_bb): Only look for
supported refs on edges.  Do not assert same ref but
different kind stores are unsuported but mark them so.
(hoist_memory_references): Only look for supported refs
on exits.

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

(cherry picked from commit 43fc4234ad3d9302d3460385b6fdb5e3f59b6986)

4 years agotree-optimization/101025 - fix store-motion dependence checking
Richard Biener [Fri, 11 Jun 2021 10:06:08 +0000 (12:06 +0200)] 
tree-optimization/101025 - fix store-motion dependence checking

This plugs a hole in store-motion where it fails to perform dependence
checking on conditionally executed but not store-motioned refs.

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

PR tree-optimization/101025
* tree-ssa-loop-im.c (sm_seq_valid_bb): Make sure to process
all refs that require dependence checking.

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

(cherry picked from commit b8b80b8aa3d9a7abbcb59b651ea5e84c2ea12d0b)

4 years agoDaily bump.
GCC Administrator [Wed, 7 Jul 2021 00:18:52 +0000 (00:18 +0000)] 
Daily bump.

4 years agoaix: Power10 assembler invocation.
Clément Chigot [Thu, 10 Jun 2021 02:00:55 +0000 (22:00 -0400)] 
aix: Power10 assembler invocation.

gcc/ChangeLog:

2021-06-09  Clement Chigot  <clement.chigot@atos.net>

* config/rs6000/aix71.h (ASM_CPU_SPEC): Add Power10 directive.
* config/rs6000/aix72.h (ASM_CPU_SPEC): Likewise.

(cherry picked from commit f8b067056ba5dd53f7bc883a1f59833efc26bd3e)

4 years agoaix: collect2 text files in archive
David Edelsohn [Thu, 20 May 2021 18:07:18 +0000 (14:07 -0400)] 
aix: collect2 text files in archive

Rust places text files in archives.  AIX ld ignores such files with a
warning.  The collect2 wrapper for ld had been exiting with a fatal
error if it scanned an archive that contained a non-COFF file.

This patch updates collect2.c to issue a warning and ignore the file
member, matching the behavior of AIX ld.  GCC can encounter archives
created by Rust and should not issue a fatal error.  This changes
fatal_error to warning, with an implicit location and no associated
optimization flag.

gcc/ChangeLog:

2021-05-20  Clement Chigot  <clement.chigot@atos.net>
    David Edelsohn  <dje.gcc@gmail.com>

* collect2.c (scan_prog_file): Issue non-fatal warning for
non-COFF files.

(cherry picked from commit 5a3bf28119c7a8d2d43d26b5eee588ee0e4472e5)

4 years agoDaily bump.
GCC Administrator [Tue, 6 Jul 2021 00:18:24 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Mon, 5 Jul 2021 00:18:01 +0000 (00:18 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sun, 4 Jul 2021 00:18:00 +0000 (00:18 +0000)] 
Daily bump.

4 years agod: Missed RVO optimization with non-POD structs
Iain Buclaw [Sat, 3 Jul 2021 00:42:14 +0000 (02:42 +0200)] 
d: Missed RVO optimization with non-POD structs

The D front-end semantic pass sometimes declares a temporary inside a
return expression.  This is now detected with the RESULT_DECL replacing
the temporary, allowing for RVO to be done.

PR d/101273

gcc/d/ChangeLog:

* toir.cc (IRVisitor::visit (ReturnStatement *)): Detect returns that
use a temporary, and replace with return value.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/pr101273.d: New test.

(cherry picked from commit 152f4d0e4d3b524ce30d05f20e23a44b0dd29765)

4 years agoDaily bump.
GCC Administrator [Sat, 3 Jul 2021 00:18:10 +0000 (00:18 +0000)] 
Daily bump.

4 years agod: RHS value lost when a target_expr modifies LHS in a cond_expr
Iain Buclaw [Fri, 2 Jul 2021 22:13:29 +0000 (00:13 +0200)] 
d: RHS value lost when a target_expr modifies LHS in a cond_expr

To prevent the RHS of an assignment modifying the LHS before the
assignment proper, a target_expr is forced so that function calls that
return with slot optimization modify the temporary instead.  This did
not work for conditional expressions however, to give one example.  So
now the RHS is always forced to a temporary.

PR d/101282

gcc/d/ChangeLog:

* d-codegen.cc (build_assign): Force target_expr on RHS for non-POD
assignment expressions.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/pr101282.d: New test.

(cherry picked from commit c77230856eac2d28eb7bf10985846885c3c8727b)

4 years agojit: fix test-vector-* failures
David Malcolm [Fri, 2 Jul 2021 19:19:47 +0000 (15:19 -0400)] 
jit: fix test-vector-* failures

Fix failures seen on i686 due to relying on exact floating-point
equality when testing results of vector division.

gcc/testsuite/ChangeLog:
* jit.dg/test-vector-rvalues.cc (check_div): Add specialization
for v4f, to avoid relying on exact floating-point equality.
* jit.dg/test-vector-types.cc (check_div): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agojit: fix test-asm failures on i?86
David Malcolm [Fri, 2 Jul 2021 19:19:47 +0000 (15:19 -0400)] 
jit: fix test-asm failures on i?86

On i686, test_i386_basic_asm_4 has:
  error: inconsistent operand constraints in an 'asm'
and test_i386_basic_asm_5 has:
  /tmp/libgccjit-9FsLie/fake.s:9: Error: bad register name `%rdi'
  /tmp/libgccjit-9FsLie/fake.s:10: Error: bad register name `%rsi'

This is only intended as a smoketest of asm support, so only run
it on x86_64.

gcc/testsuite/ChangeLog:
* jit.dg/test-asm.c: Remove i?86-*-* from target specifier.
* jit.dg/test-asm.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: fix issue with symbolic reads with concrete bindings
David Malcolm [Fri, 2 Jul 2021 19:19:47 +0000 (15:19 -0400)] 
analyzer: fix issue with symbolic reads with concrete bindings

gcc/analyzer/ChangeLog:
* store.cc (binding_cluster::get_any_binding): Make symbolic reads
from a cluster with concrete bindings return unknown.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/symbolic-7.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: add region_model_manager::get_or_create_int_cst
David Malcolm [Fri, 2 Jul 2021 19:19:47 +0000 (15:19 -0400)] 
analyzer: add region_model_manager::get_or_create_int_cst

gcc/analyzer/ChangeLog:
* region-model-manager.cc
(region_model_manager::get_or_create_int_cst): New.
(region_model_manager::maybe_undo_optimize_bit_field_compare): Use
it to simplify away a local tree.
* region-model.cc (region_model::on_setjmp): Likewise.
(region_model::on_longjmp): Likewise.
* region-model.h (region_model_manager::get_or_create_int_cst):
New decl.
* store.cc (binding_cluster::zero_fill_region): Use it to simplify
away a local tree.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: fix bitfield endianness issues [PR99212,PR101082]
David Malcolm [Fri, 2 Jul 2021 19:19:46 +0000 (15:19 -0400)] 
analyzer: fix bitfield endianness issues [PR99212,PR101082]

Looks like my patch for PR analyzer/99212 implicitly assumed
little-endian, which the following patch fixes.

Fixes bitfields-1.c on:
- armeb-none-linux-gnueabihf
- cris-elf
- powerpc64-darwin
- s390-linux-gnu

gcc/analyzer/ChangeLog:
PR analyzer/99212
PR analyzer/101082
* engine.cc: Include "target.h".
(impl_run_checkers): Log BITS_BIG_ENDIAN, BYTES_BIG_ENDIAN, and
WORDS_BIG_ENDIAN.
* region-model-manager.cc
(region_model_manager::maybe_fold_binop): Move support for masking
via ARG0 & CST into...
(region_model_manager::maybe_undo_optimize_bit_field_compare):
...this new function.  Flatten by converting from nested
conditionals to a series of early return statements to reject
failures.  Reject if type is not unsigned_char_type_node.
Handle BYTES_BIG_ENDIAN when determining which bits are bound
in the binding_map.
* region-model.h
(region_model_manager::maybe_undo_optimize_bit_field_compare):
New decl.
* store.cc (bit_range::dump): New function.
* store.h (bit_range::dump): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: tweak priority of callstrings in worklist::key_t::cmp
David Malcolm [Fri, 2 Jul 2021 19:19:46 +0000 (15:19 -0400)] 
analyzer: tweak priority of callstrings in worklist::key_t::cmp

While debugging another issue I noticed that the analyzer could fail to
merge nodes for control flow in which one path had called a function
and another path hadn't:

        BB
       /  \
      /    \
 fn call   no fn call
      \    /
       \  /
     join BB

The root cause was that the worklist sort function wasn't prioritizing
call strings, and thus it was fully exploring the "no function called"
path to the exit BB, and only then exploring the "within the function call"
parts of the "funcion called" path.

This patch prioritizes call strings when sorting the worklist so that
the nodes with deeper call strings are processed before those with shallower
call strings, thus allowing such nodes to be merged at the joinpoint.

gcc/analyzer/ChangeLog:
* engine.cc (worklist::key_t::cmp): Move sort by call_string to
before SCC.

gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/loop-0-up-to-n-by-1-with-iter-obj.c: Update
expected number of enodes after the loop.
* gcc.dg/analyzer/paths-8.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: make various region_model member functions const
David Malcolm [Fri, 2 Jul 2021 19:19:46 +0000 (15:19 -0400)] 
analyzer: make various region_model member functions const

gcc/analyzer/ChangeLog:
* region-model.cc (region_model::get_lvalue_1): Make const.
(region_model::get_lvalue): Likewise.
(region_model::get_rvalue_1): Likewise.
(region_model::get_rvalue): Likewise.
(region_model::deref_rvalue): Likewise.
(region_model::get_rvalue_for_bits): Likewise.
* region-model.h (region_model::get_lvalue): Likewise.
(region_model::get_rvalue): Likewise.
(region_model::deref_rvalue): Likewise.
(region_model::get_rvalue_for_bits): Likewise.
(region_model::get_lvalue_1): Likewise.
(region_model::get_rvalue_1): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: bitfield fixes [PR99212]
David Malcolm [Fri, 2 Jul 2021 19:19:45 +0000 (15:19 -0400)] 
analyzer: bitfield fixes [PR99212]

This patch verifies the previous fix for bitfield sizes by implementing
enough support for bitfields in the analyzer to get the test cases to pass.

The patch implements support in the analyzer for reading from a
BIT_FIELD_REF, and support for folding BIT_AND_EXPR of a mask, to handle
the cases generated in tests.

The existing bitfields tests in data-model-1.c turned out to rely on
undefined behavior, in that they were assigning values to a signed
bitfield that were outside of the valid range of values.  I believe that
that's why we were seeing target-specific differences in the test
results (PR analyzer/99212).  The patch updates the test to remove the
undefined behaviors.

gcc/analyzer/ChangeLog:
PR analyzer/99212
* region-model-manager.cc
(region_model_manager::maybe_fold_binop): Add support for folding
BIT_AND_EXPR of compound_svalue and a mask constant.
* region-model.cc (region_model::get_rvalue_1): Implement
BIT_FIELD_REF in terms of...
(region_model::get_rvalue_for_bits): New function.
* region-model.h (region_model::get_rvalue_for_bits): New decl.
* store.cc (bit_range::from_mask): New function.
(selftest::test_bit_range_intersects_p): New selftest.
(selftest::assert_bit_range_from_mask_eq): New.
(ASSERT_BIT_RANGE_FROM_MASK_EQ): New macro.
(selftest::assert_no_bit_range_from_mask_eq): New.
(ASSERT_NO_BIT_RANGE_FROM_MASK): New macro.
(selftest::test_bit_range_from_mask): New selftest.
(selftest::analyzer_store_cc_tests): Call the new selftests.
* store.h (bit_range::intersects_p): New.
(bit_range::from_mask): New decl.
(concrete_binding::get_bit_range): New accessor.
(store_manager::get_concrete_binding): New overload taking
const bit_range &.

gcc/testsuite/ChangeLog:
PR analyzer/99212
* gcc.dg/analyzer/bitfields-1.c: New test.
* gcc.dg/analyzer/data-model-1.c (struct sbits): Make bitfields
explicitly signed.
(test_44): Update test values assigned to the bits to ones that
fit in the range of the bitfield type.  Remove xfails.
(test_45): Remove xfails.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: fix region::get_bit_size for bitfields
David Malcolm [Fri, 2 Jul 2021 19:19:45 +0000 (15:19 -0400)] 
analyzer: fix region::get_bit_size for bitfields

gcc/analyzer/ChangeLog:
* analyzer.h (int_size_in_bits): New decl.
* region.cc (int_size_in_bits): New function.
(region::get_bit_size): Reimplement in terms of the above.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: split out struct bit_range from class concrete_binding
David Malcolm [Fri, 2 Jul 2021 19:19:45 +0000 (15:19 -0400)] 
analyzer: split out struct bit_range from class concrete_binding

gcc/analyzer/ChangeLog:
* store.cc (concrete_binding::dump_to_pp): Move bulk of
implementation to...
(bit_range::dump_to_pp): ...this new function.
(bit_range::cmp): New.
(concrete_binding::overlaps_p): Update for use of bit_range.
(concrete_binding::cmp_ptr_ptr): Likewise.
* store.h (struct bit_range): New.
(class concrete_binding): Replace fields m_start_bit_offset and
m_size_in_bits with new field m_bit_range.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: remove redundant typedef
David Malcolm [Fri, 2 Jul 2021 19:19:44 +0000 (15:19 -0400)] 
analyzer: remove redundant typedef

Delete an overzealous copy&paste.

gcc/analyzer/ChangeLog:
* svalue.h (conjured_svalue::iterator_t): Delete.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: remove unused prototypes
David Malcolm [Fri, 2 Jul 2021 19:19:44 +0000 (15:19 -0400)] 
analyzer: remove unused prototypes

gcc/analyzer/ChangeLog:
* store.h (store::get_direct_binding): Remove unused decl.
(store::get_default_binding): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: show types for poisoned_svalue and compound_svalue
David Malcolm [Fri, 2 Jul 2021 19:19:44 +0000 (15:19 -0400)] 
analyzer: show types for poisoned_svalue and compound_svalue

gcc/analyzer/ChangeLog:
* svalue.cc (poisoned_svalue::dump_to_pp): Dump type.
(compound_svalue::dump_to_pp): Dump any type.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agodiagnostic-show-locus: tweak rejection logic
David Malcolm [Fri, 2 Jul 2021 19:19:44 +0000 (15:19 -0400)] 
diagnostic-show-locus: tweak rejection logic

gcc/ChangeLog:
* diagnostic-show-locus.c (diagnostic_show_locus): Don't reject
printing the same location twice if there are fix-it hints,
multiple locations, or a label.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: fix missing leak after call to strsep [PR100615]
David Malcolm [Fri, 2 Jul 2021 19:19:43 +0000 (15:19 -0400)] 
analyzer: fix missing leak after call to strsep [PR100615]

PR analyzer/100615 reports a missing leak diagnostic.
The issue is that the code calls strsep which the analyzer doesn't
have special knowledge of, and so conservatively assumes that it
could free the pointer, so drops malloc state for it.

Properly "teaching" the analyzer about strsep would require it
to support bifurcating state at a call, which is currently fiddly to
do, so for now this patch notes that strsep doesn't affect the
malloc state machine, allowing the analyzer to correctly detect the leak.

gcc/analyzer/ChangeLog:
PR analyzer/100615
* sm-malloc.cc: Include "analyzer/function-set.h".
(malloc_state_machine::on_stmt): Call unaffected_by_call_p and
bail on the functions it recognizes.
(malloc_state_machine::unaffected_by_call_p): New.

gcc/testsuite/ChangeLog:
PR analyzer/100615
* gcc.dg/analyzer/pr100615.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoanalyzer: fix ICE on NULL change.m_expr [PR100244]
David Malcolm [Fri, 2 Jul 2021 19:19:43 +0000 (15:19 -0400)] 
analyzer: fix ICE on NULL change.m_expr [PR100244]

PR analyzer/100244 reports an ICE on a -Wanalyzer-free-of-non-heap
due to a case where free_of_non_heap::describe_state_change can be
passed a NULL change.m_expr for a suitably complicated symbolic value.

Bulletproof it by checking for change.m_expr being NULL before
dereferencing it.

gcc/analyzer/ChangeLog:
PR analyzer/100244
* sm-malloc.cc (free_of_non_heap::describe_state_change):
Bulletproof against change.m_expr being NULL.

gcc/testsuite/ChangeLog:
PR analyzer/100244
* g++.dg/analyzer/pr100244.C: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 years agoChange EH pointer encodings to PC relative on Windows
Eric Botcazou [Fri, 2 Jul 2021 08:21:11 +0000 (10:21 +0200)] 
Change EH pointer encodings to PC relative on Windows

A big difference between ELF and PE-COFF is that, with the latter, you can
build position-independent executables or DLLs without generating PIC; as
a  matter of fact, flag_pic has historically been forced to 0 for 32-bit:

/* Don't allow flag_pic to propagate since gas may produce invalid code
   otherwise.  */

\
do {
        \
  flag_pic = TARGET_64BIT ? 1 : 0; \
} while (0)

The reason is that the linker builds a .reloc section that collects the
absolute relocations in the generated binary, and the loader uses them to
relocate it at load time if need be (e.g. if --dynamicbase is enabled).

Up to binutils 2.35, the GNU linker didn't build the .reloc section for
executables and defaulted to --enable-auto-image-base for DLLs, which means
that DLLs had an essentially unique load address and, therefore, need not
be relocated by the loader in most cases.

With binutils 2.36 and later, the GNU linker builds a .reloc section for
executables (thus making them PIE), --enable-auto-image-base is disabled
and --dynamicbase is enabled by default, which means that essentially all
the binaries are relocated at load time.

This badly breaks the 32-bit compiler configured to use DWARF-2 EH because
the loader corrupts the .eh_frame section when processing the relocations
contained in the .reloc section.

gcc/
* config/i386/i386.c (asm_preferred_eh_data_format): Always use the
PIC encodings for PE-COFF targets.