Tamar Christina [Wed, 24 Feb 2021 14:57:08 +0000 (14:57 +0000)]
[comitted] Testsuite: Disable PR99149 test on big-endian
This patch disables the test for PR99149 on Big-endian
where for standard AArch64 the patterns are disabled.
gcc/testsuite/ChangeLog:
PR tree-optimization/99149
* g++.dg/vect/pr99149.cc: Disabled on BE.
Iain Sandoe [Tue, 23 Feb 2021 12:54:26 +0000 (12:54 +0000)]
coroutines : Adjust error handling for type-dependent coroutines [PR96251].
Although coroutines are not permitted to be constexpr, generic lambdas
are implicitly from C++17 and, because of this, a generic coroutine lambda
can be marked as potentially constexpr. As per the PR, this then fails when
type substitution is attempted because the check disallowing constexpr in
the coroutines code was overly restrictive.
This changes the error handing to mark the function as 'invalid_constexpr'
but suppresses the error in the case that we are instantiating a constexpr.
gcc/cp/ChangeLog:
PR c++/96251
* coroutines.cc (coro_common_keyword_context_valid_p): Suppress
error reporting when instantiating for a constexpr.
gcc/testsuite/ChangeLog:
PR c++/96251
* g++.dg/coroutines/pr96251.C: New test.
Jakub Jelinek [Wed, 24 Feb 2021 11:10:25 +0000 (12:10 +0100)]
fold-const: Fix up ((1 << x) & y) != 0 folding for vectors [PR99225]
This optimization was written purely with scalar integers in mind,
can work fine even with vectors, but we can't use build_int_cst but
need to use build_one_cst instead.
2021-02-24 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/99225
* fold-const.c (fold_binary_loc) <case NE_EXPR>: In (x & (1 << y)) != 0
to ((x >> y) & 1) != 0 simplifications use build_one_cst instead of
build_int_cst (..., 1). Formatting fixes.
* gcc.c-torture/compile/pr99225.c: New test.
Tamar Christina [Wed, 24 Feb 2021 09:43:22 +0000 (09:43 +0000)]
slp: fix sharing of SLP only patterns.
The attached testcase ICEs due to a couple of issues.
In the testcase you have two SLP instances that share the majority of their
definition with each other. One tree defines a COMPLEX_MUL sequence and the
other tree a COMPLEX_FMA.
The ice happens because:
1. the refcounts are wrong, in particular the FMA case doesn't correctly count
the references for the COMPLEX_MUL that it consumes.
2. when the FMA is created it incorrectly assumes it can just tear apart the MUL
node that it's consuming. This is wrong and should only be done when there is
no more uses of the node, in which case the vector only pattern is no longer
relevant.
To fix the last part the SLP only pattern reset code was moved into
vect_free_slp_tree which results in cleaner code. I also think it does belong
there since that function knows when there are no more uses of the node and so
the pattern should be unmarked, so when the the vectorizer is inspecting the BB
it doesn't find the now invalid vector only patterns.
The patch also clears the SLP_TREE_REPRESENTATIVE when stores are removed such
that we don't hit an error later trying to free the stmt_vec_info again.
Lastly it also tweaks the results of whether a pattern has been detected or not
to return true when another SLP instance has created a pattern that is only used
by a different instance (due to the trees being unshared).
Instead of ICEing this code now produces
adrp x1, .LANCHOR0
add x2, x1, :lo12:.LANCHOR0
movi v1.2s, 0
mov w0, 0
ldr x4, [x1, #:lo12:.LANCHOR0]
ldrsw x3, [x2, 16]
ldr x1, [x2, 8]
ldrsw x2, [x2, 20]
ldr d0, [x4]
ldr d2, [x1, x3, lsl 3]
fcmla v2.2s, v0.2s, v0.2s, #0
fcmla v2.2s, v0.2s, v0.2s, #90
str d2, [x1, x3, lsl 3]
fcmla v1.2s, v0.2s, v0.2s, #0
fcmla v1.2s, v0.2s, v0.2s, #90
str d1, [x1, x2, lsl 3]
ret
PS. This testcase actually shows that the codegen we get in these cases is not
optimal. It should generate a MUL + ADD instead MUL + FMA.
But that's for GCC 12.
gcc/ChangeLog:
PR tree-optimization/99149
* tree-vect-slp-patterns.c (vect_detect_pair_op): Don't recreate the
buffer.
(vect_slp_reset_pattern): Remove.
(complex_fma_pattern::matches): Remove call to vect_slp_reset_pattern.
(complex_mul_pattern::build, complex_fma_pattern::build,
complex_fms_pattern::build): Fix ref counts.
* tree-vect-slp.c (vect_free_slp_tree): Undo SLP only pattern relevancy
when node is being deleted.
(vect_match_slp_patterns_2): Correct result of cache hit on patterns.
(vect_schedule_slp): Invalidate SLP_TREE_REPRESENTATIVE of removed
stores.
* tree-vectorizer.c (vec_info::new_stmt_vec_info): Initialize value.
gcc/testsuite/ChangeLog:
PR tree-optimization/99149
* g++.dg/vect/pr99149.cc: New test.
Matthias Klose [Wed, 24 Feb 2021 09:39:11 +0000 (09:39 +0000)]
Revert: "Don't build insn-extract.o with rtl checking"
This reverts commit
8441545d4f2afb9e9342e0dac378eafd03f00462.
Richard Biener [Wed, 24 Feb 2021 08:18:05 +0000 (09:18 +0100)]
c/99224 - avoid ICEing on invalid __builtin_next_arg
This avoids crashes with __builtin_next_arg on non-parameters. For
the specific testcase we arrive with an anonymous SSA_NAME so that
SSA_NAME_VAR becomes NULL and we crash.
2021-02-24 Richard Biener <rguenther@suse.de>
PR c/99224
* builtins.c (fold_builtin_next_arg): Avoid NULL arg.
* gcc.dg/pr99224.c: New testcase.
GCC Administrator [Wed, 24 Feb 2021 00:16:26 +0000 (00:16 +0000)]
Daily bump.
Peter Bergner [Tue, 23 Feb 2021 23:16:10 +0000 (17:16 -0600)]
rs6000: Add support for compatibility built-ins
The LLVM and GCC teams agreed to rename the __builtin_mma_assemble_pair and
__builtin_mma_disassemble_pair built-ins to __builtin_vsx_assemble_pair and
__builtin_vsx_disassemble_pair respectively. It's too late to remove the
old names, so this patch renames the built-ins to the new names and then
adds support for creating compatibility built-ins (ie, multiple built-in
functions generate the same code) and then creates compatibility built-ins
using the old names.
2021-02-23 Peter Bergner <bergner@linux.ibm.com>
gcc/
* config/rs6000/mma.md (mma_assemble_pair): Rename from this...
(vsx_assemble_pair): ...to this.
(*mma_assemble_pair): Rename from this...
(*vsx_assemble_pair): ...to this.
(mma_disassemble_pair): Rename from this...
(vsx_disassemble_pair): ...to this.
(*mma_disassemble_pair): Rename from this...
(*vsx_disassemble_pair): ...to this.
* config/rs6000/rs6000-builtin.def (BU_MMA_V2, BU_MMA_V3,
BU_COMPAT): New macros.
(mma_assemble_pair): Rename from this...
(vsx_assemble_pair): ...to this.
(mma_disassemble_pair): Rename from this...
(vsx_disassemble_pair): ...to this.
(mma_assemble_pair): New compatibility built-in.
(mma_disassemble_pair): Likewise.
* config/rs6000/rs6000-call.c (struct builtin_compatibility): New.
(RS6000_BUILTIN_COMPAT): Define.
(bdesc_compat): New.
(mma_expand_builtin): Use VSX_BUILTIN_DISASSEMBLE_PAIR_INTERNAL.
(rs6000_gimple_fold_mma_builtin): Use MMA_BUILTIN_DISASSEMBLE_PAIR
and VSX_BUILTIN_ASSEMBLE_PAIR.
(rs6000_init_builtins): Register compatibility built-ins.
(mma_init_builtins): Use VSX_BUILTIN_ASSEMBLE_PAIR,
VSX_BUILTIN_ASSEMBLE_PAIR_INTERNAL, VSX_BUILTIN_DISASSEMBLE_PAIR and
VSX_BUILTIN_DISASSEMBLE_PAIR_INTERNAL.
* doc/extend.texi (__builtin_mma_assemble_pair): Rename from this...
(__builtin_vsx_assemble_pair): ...to this.
(__builtin_mma_disassemble_pair): Rename from this...
(__builtin_vsx_disassemble_pair): ...to this.
gcc/testsuite/
* gcc.target/powerpc/mma-builtin-4.c: Add tests for
__builtin_vsx_assemble_pair and __builtin_vsx_disassemble_pair.
Add __has_builtin tests for built-ins.
Update expected instruction counts.
Martin Sebor [Tue, 23 Feb 2021 21:09:00 +0000 (14:09 -0700)]
PR c++/99074 - crash in dynamic_cast<>() on null pointer
libstdc++-v3/ChangeLog:
PR c++/99074
* libsupc++/dyncast.cc (__dynamic_cast): Return null when
first argument is null.
gcc/testsuite/ChangeLog:
PR c++/99074
* g++.dg/warn/Wnonnull11.C: New test.
Paul Thomas [Tue, 23 Feb 2021 19:29:04 +0000 (19:29 +0000)]
Fortran: Fix for class defined operators [PR99124].
2021-02-23 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/99124
* resolve.c (resolve_fl_procedure): Include class results in
the test for F2018, C15100.
* trans-array.c (get_class_info_from_ss): Do not use the saved
descriptor to obtain the class expression for variables. Use
gfc_get_class_from_expr instead.
gcc/testsuite/
PR fortran/99124
* gfortran.dg/class_defined_operator_2.f03 : New test.
* gfortran.dg/elemental_result_2.f90 : New test.
* gfortran.dg/class_assign_4.f90: Correct the non-conforming
elemental function with an allocatable result with an operator
interface with array dummies and result.
Harald Anlauf [Tue, 23 Feb 2021 18:09:14 +0000 (19:09 +0100)]
PR fortran/99206 - ICE in add_init_expr_to_sym, at fortran/decl.c:1980
Make sure that the string length is properly set during simplification
even when the resulting array is zero-sized.
gcc/fortran/ChangeLog:
PR fortran/99206
* simplify.c (gfc_simplify_reshape): Set string length for
character arguments.
gcc/testsuite/ChangeLog:
PR fortran/99206
* gfortran.dg/reshape_zerosize_4.f90: New test.
Nathan Sidwell [Tue, 23 Feb 2021 15:08:55 +0000 (07:08 -0800)]
c++: typedef for linkage [PR 99208]
Unnamed types with a typedef name for linkage were always troublesome
in modules. This is the underlying cause of that trouble -- we were
creating incorrect type structures. Classes have an implicit
self-reference, and we created that for unnamed classes too. It turns
out we make use of this member, so just not generating it turned into
a rathole. This member is created using the anonymous name -- because
we've not yet met the typedef name. When we retrofit the typedef name
we were checking identifier matching and changing all type variants
with that identifier. Which meant we ended up with a strange typedef
for the self reference. This fixes things to check for DECL identity
of the variants, so we don't smash the self-reference -- that
continues to have the anonymous name.
PR c++/99208
gcc/cp/
* decl.c (name_unnamed_type): Check DECL identity, not IDENTIFIER
identity.
gcc/testsuite/
* g++.dg/modules/pr99208_a.C: New.
* g++.dg/modules/pr99208_b.C: New.
Martin Liska [Tue, 23 Feb 2021 08:01:53 +0000 (09:01 +0100)]
IPA ICF + ASAN: do not merge vars with different alignment
gcc/ChangeLog:
PR sanitizer/99168
* ipa-icf.c (sem_variable::merge): Do not merge 2 variables
with different alignment. That leads to an invalid red zone
size allocated in runtime.
gcc/testsuite/ChangeLog:
PR sanitizer/99168
* c-c++-common/asan/pr99168.c: New test.
Patrick Palka [Tue, 23 Feb 2021 14:40:09 +0000 (09:40 -0500)]
c++: Fix folding of non-dependent BASELINKs [PR95468]
Here, the problem ultimately seems to be that tsubst_copy_and_build,
when called with empty args as we do during non-dependent expression
folding, doesn't touch BASELINKs at all: it delegates to tsubst_copy
which then immediately exits early due to the empty args. This means
that the CAST_EXPR int(1) in the BASELINK A::condition<int(1)> never
gets folded (as part of folding of the overall CALL_EXPR), which later
causes us to crash when performing overload resolution of the rebuilt
CALL_EXPR (which is still in terms of this templated BASELINK).
This doesn't happen when condition() is a namespace-scope function
because then condition<int(1)> is represented by a TEMPLATE_ID_EXPR
rather than by a BASELINK, which does get handled directly from
tsubst_copy_and_build.
This patch fixes this issue by having tsubst_copy_and_build handle
BASELINK directly rather than delegating to tsubst_copy, so that it
processes BASELINKs even when args is empty.
gcc/cp/ChangeLog:
PR c++/95468
* pt.c (tsubst_copy_and_build) <case BASELINK>: New case, copied
over from tsubst_copy.
gcc/testsuite/ChangeLog:
PR c++/95468
* g++.dg/template/non-dependent15.C: New test.
Patrick Palka [Tue, 23 Feb 2021 14:40:03 +0000 (09:40 -0500)]
c++: Micro-optimize instantiation_dependent_expression_p
This makes instantiation_dependent_expression_p avoid calling
potential_constant_expression when processing_template_decl isn't set
(and hence when value_dependent_expression_p is definitely false).
gcc/cp/ChangeLog:
* pt.c (instantiation_dependent_expression_p): Check
processing_template_decl before calling
potential_constant_expression.
Martin Liska [Tue, 23 Feb 2021 10:14:03 +0000 (11:14 +0100)]
Fix UBSAN in __ubsan::Value::getSIntValue
/home/marxin/Programming/gcc2/libsanitizer/ubsan/ubsan_value.cpp:77:25: runtime error: left shift of 0x0000000000000000fffffffffffffffb by 96 places cannot be represented in type '__int128'
#0 0x7ffff754edfe in __ubsan::Value::getSIntValue() const /home/marxin/Programming/gcc2/libsanitizer/ubsan/ubsan_value.cpp:77
#1 0x7ffff7548719 in __ubsan::Value::isNegative() const /home/marxin/Programming/gcc2/libsanitizer/ubsan/ubsan_value.h:190
#2 0x7ffff7542a34 in handleShiftOutOfBoundsImpl /home/marxin/Programming/gcc2/libsanitizer/ubsan/ubsan_handlers.cpp:338
#3 0x7ffff75431b7 in __ubsan_handle_shift_out_of_bounds /home/marxin/Programming/gcc2/libsanitizer/ubsan/ubsan_handlers.cpp:370
#4 0x40067f in main (/home/marxin/Programming/testcases/a.out+0x40067f)
#5 0x7ffff72c8b24 in __libc_start_main (/lib64/libc.so.6+0x27b24)
#6 0x4005bd in _start (/home/marxin/Programming/testcases/a.out+0x4005bd)
Differential Revision: https://reviews.llvm.org/D97263
Cherry-pick from
16ede0956cb1f4b692dfa619ccfa6ab1de28e19b.
Kito Cheng [Thu, 18 Feb 2021 07:47:05 +0000 (15:47 +0800)]
config.sub, config.guess : Import upstream 2021-01-25.
Hi
Does it update config.sub and config.guess, I know it's already
stage 4, but the config.* stuff update should be harmless things,
and we need this for RISC-V big-endian support, which is already
supported in binutils 2.36.
This imports from:
sha1
6faca61810d335c7837f320733fe8e15a1431fc2
ChangeLog:
* config.guess: Import latest upstream.
* config.sub: Import latest upstream.
Jakub Jelinek [Tue, 23 Feb 2021 08:49:48 +0000 (09:49 +0100)]
fold-const: Fix ICE in fold_read_from_constant_string on invalid code [PR99204]
fold_read_from_constant_string and expand_expr_real_1 have code to optimize
constant reads from string (tree vs. rtl).
If the STRING_CST array type has zero low bound, index is fold converted to
sizetype and so the compare_tree_int works fine, but if it has some other
low bound, it calls size_diffop_loc and that function from 2 sizetype
operands creates a ssizetype difference. expand_expr_real_1 then uses
tree_fits_uhwi_p + compare_tree_int and so works fine, but fold-const.c
only checked if index is INTEGER_CST and calls compare_tree_int, which means
for negative index it will succeed and result in UB in the compiler.
2021-02-23 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/99204
* fold-const.c (fold_read_from_constant_string): Check that
tree_fits_uhwi_p (index) rather than just that index is INTEGER_CST.
* gfortran.dg/pr99204.f90: New test.
Jakub Jelinek [Tue, 23 Feb 2021 08:30:18 +0000 (09:30 +0100)]
libstdc++: Fix up constexpr std::char_traits<char>::compare [PR99181]
Because of LWG 467, std::char_traits<char>::lt compares the values
cast to unsigned char rather than char, so even when char is signed
we get unsigned comparision. std::char_traits<char>::compare uses
__builtin_memcmp and that works the same, but during constexpr evaluation
we were calling __gnu_cxx::char_traits<char_type>::compare. As
char_traits::lt is not virtual, __gnu_cxx::char_traits<char_type>::compare
used __gnu_cxx::char_traits<char_type>::lt rather than
std::char_traits<char>::lt and thus compared chars as signed if char is
signed.
This change fixes it by inlining __gnu_cxx::char_traits<char_type>::compare
into std::char_traits<char>::compare by hand, so that it calls the right
lt method.
2021-02-23 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/99181
* include/bits/char_traits.h (char_traits<char>::compare): For
constexpr evaluation don't call
__gnu_cxx::char_traits<char_type>::compare but do the comparison loop
directly.
* testsuite/21_strings/char_traits/requirements/char/99181.cc: New
test.
Jakub Jelinek [Tue, 23 Feb 2021 08:26:23 +0000 (09:26 +0100)]
libstdc++: Fix up parallel_backend_serial.h [PR97549]
In GCC 10, parallel_backend.h just included parallel_backend_{serial,tbb}.h and
did nothing beyond that, and parallel_backend_tbb.h provided directly
namespace __pstl { namespace __par_backend { ... } }
and defined everything in there, while parallel_backend_serial.h did:
namespace __pstl { namespace __serial { ... } } and had this
namespace __pstl { namespace __par_backend { using namespace __pstl::__serial; } }
at the end.
In GCC 11, parallel_backend.h does:
namespace __pstl { namespace __par_backend = __serial_backend; }
after including parallel_backend_serial.h or
namespace __pstl { namespace __par_backend = __tbb_backend; }
after including parallel_backend_tbb.h. The latter then has:
namespace __pstl { namespace __tbb_backend { ... } }
and no using etc. at the end, while parallel_backend_serial.h changed to:
namespace __pstl { namespace __serial_backend { ... } }
but has this leftover block from the GCC 10 times. Even changing that
using namespace __pstl::__serial;
to
using namespace __pstl::__serial_backend;
doesn't work, as it clashes with
namespace __pstl { namespace __par_backend = __serial_backend; }
in parallel_backend.h.
2021-02-23 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/97549
* include/pstl/parallel_backend_serial.h: Remove __pstl::__par_backend.
Kewen Lin [Mon, 14 Dec 2020 09:38:49 +0000 (03:38 -0600)]
rs6000: Use rldimi for vec init instead of shift + ior
This patch is to teach unsigned int vector init to use rldimi to
merge two integers instead of shift and ior. It also adds one
required splitter made by Segher.
An rl*imi is usually written as an IOR of an ASHIFT or similar, and
an AND of a register with a constant mask. In some cases combine
knows that that AND doesn't do anything (because all zero bits in
that mask correspond to bits known to be already zero), and then no
pattern matches. This patch adds a define_split for such cases.
It uses nonzero_bits in the condition of the splitter, but does not
need it afterwards for the instruction to be recognised. This is
necessary because later passes can see fewer nonzero_bits.
Because it is a splitter, combine will only use it when starting with
three insns (or more), even though the result is just one. This isn't
a huge problem in practice, but some possible combinations still won't
happen.
Bootstrapped/regtested on powerpc64le-linux-gnu P9 and
powerpc64-linux-gnu P8, also SPEC2017 build/run passed on P9.
gcc/ChangeLog:
2020-02-23 Segher Boessenkool <segher@kernel.crashing.org>
Kewen Lin <linkw@gcc.gnu.org>
* config/rs6000/rs6000.md (*rotl<mode>3_insert_3): Renamed to...
(rotl<mode>3_insert_3): ...this.
(plus_ior_xor): New code_iterator.
(define_split for GPR rl*imi): New splitter.
* config/rs6000/vsx.md (vsx_init_v4si): Use gen_rotldi3_insert_3
for integer merging.
gcc/testsuite/ChangeLog:
* gcc.target/powerpc/vec-init-10.c: New test.
Patrick Palka [Tue, 23 Feb 2021 02:49:25 +0000 (21:49 -0500)]
libstdc++: Fix endianness issue with IBM long double [PR98384]
The code in std::to_chars for extracting the high- and low-order parts
of an IBM long double value does the right thing on powerpc64le, but not
on powerpc64be. This patch makes the extraction endian-agnostic, which
fixes the execution FAIL of to_chars/long_double.cc on powerpc64be.
libstdc++-v3/ChangeLog:
PR libstdc++/98384
* src/c++17/floating_to_chars.cc (get_ieee_repr): Extract
the high- and low-order parts from an IBM long double value
in an endian-agnostic way.
Joseph Myers [Tue, 23 Feb 2021 00:55:10 +0000 (00:55 +0000)]
Update gcc sv.po.
* sv.po: Update.
Hans-Peter Nilsson [Tue, 23 Feb 2021 00:43:50 +0000 (01:43 +0100)]
g++.dg/warn/Wplacement-new-size-1.C, -2, -6: Fix for default_packed targets
Looking at commit
de05c19d5fd6, that adjustment to these
tests apparently assumed that the testsuite is run (only) on
targets where structure memory layout has padding as per
"natural alignment". For cris-elf, a target with no padding
in structure memory layout, these tests have been failing
since that commit.
Tested cris-elf and x86_64-linux, committed as obvious.
gcc/testsuite:
* g++.dg/warn/Wplacement-new-size-1.C,
g++.dg/warn/Wplacement-new-size-2.C,
g++.dg/warn/Wplacement-new-size-6.C: Adjust for
default_packed targets.
GCC Administrator [Tue, 23 Feb 2021 00:16:34 +0000 (00:16 +0000)]
Daily bump.
David Malcolm [Mon, 22 Feb 2021 23:46:05 +0000 (18:46 -0500)]
analyzer: handle error/error_at_line [PR99196]
PR analyzer/99196 describes a false positive from -fanalyzer due to
the analyzer not "knowing" that calls to GNU libc's error(3) with a
nonzero status terminate the process and thus don't return.
This patch fixes the false positive by special-casing "error" and
"error_at_line".
gcc/analyzer/ChangeLog:
PR analyzer/99196
* engine.cc (exploded_node::on_stmt): Provide terminate_path
flag as a way for on_call_pre to terminate the current analysis
path.
* region-model-impl-calls.cc (call_details::num_args): New.
(region_model::impl_call_error): New.
* region-model.cc (region_model::on_call_pre): Add param
"out_terminate_path". Handle "error" and "error_at_line".
* region-model.h (call_details::num_args): New decl.
(region_model::on_call_pre): Add param "out_terminate_path".
(region_model::impl_call_error): New decl.
gcc/testsuite/ChangeLog:
PR analyzer/99196
* gcc.dg/analyzer/error-1.c: New test.
* gcc.dg/analyzer/error-2.c: New test.
* gcc.dg/analyzer/error-3.c: New test.
H.J. Lu [Fri, 19 Feb 2021 23:44:38 +0000 (15:44 -0800)]
Require SHF_GNU_RETAIN support for retain tests
Since retain attribute requires SHF_GNU_RETAIN, run retain tests only
if SHF_GNU_RETAIN is supported.
PR testsuite/99173
* c-c++-common/attr-retain-5.c: Require R_flag_in_section.
* c-c++-common/attr-retain-6.c: Likewise.
* c-c++-common/attr-retain-7.c: Likewise.
* c-c++-common/attr-retain-8.c: Likewise.
* c-c++-common/attr-retain-9.c: Likewise.
Kyrylo Tkachov [Mon, 22 Feb 2021 21:24:41 +0000 (21:24 +0000)]
aarch64: Add internal tune flag to minimise VL-based scalar ops
This patch introduces an internal tune flag to break up VL-based scalar ops
into a GP-reg scalar op with the VL read kept separate. This can be preferable on some CPUs.
I went for a tune param rather than extending the rtx costs as our RTX costs tables aren't set up to track
this intricacy.
I've confirmed that on the simple loop:
void vadd (int *dst, int *op1, int *op2, int count)
{
for (int i = 0; i < count; ++i)
dst[i] = op1[i] + op2[i];
}
we now split the incw into a cntw outside the loop and the add inside.
+ cntw x5
...
loop:
- incw x4
+ add x4, x4, x5
gcc/ChangeLog:
* config/aarch64/aarch64-tuning-flags.def (cse_sve_vl_constants):
Define.
* config/aarch64/aarch64.md (add<mode>3): Force CONST_POLY_INT immediates
into a register when the above is enabled.
* config/aarch64/aarch64.c (neoversev1_tunings):
AARCH64_EXTRA_TUNE_CSE_SVE_VL_CONSTANTS.
(aarch64_rtx_costs): Use AARCH64_EXTRA_TUNE_CSE_SVE_VL_CONSTANTS.
gcc/testsuite/
* gcc.target/aarch64/sve/cse_sve_vl_constants_1.c: New test.
Michael Meissner [Mon, 22 Feb 2021 20:54:39 +0000 (15:54 -0500)]
Fix a comment line that was too long.
libgcc/
2021-02-22 Michael Meissner <meissner@linux.ibm.com>
* dfp-bit.c (BFP_TO_DFP): Fix a comment line that was too long.
Michael Meissner [Mon, 22 Feb 2021 20:33:29 +0000 (15:33 -0500)]
Add conversions between _Float128 and Decimal.
This patch implements conversions between _Float128 and the 3 Decimal floating
types. It does this by extendending the dfp-bit conversions to add a new
binary floating point type (KF), and doing the conversions in the same manner
as the other binary/decimal conversions.
For conversions from _Float128 to Decimal, this patch uses a function
(__sprintfkf) instead of the sprintf function to convert long double values to
strings. The __sprintfkf function determines if GLIBC 2.32 or newer is used
and calls the IEEE 128-bit version of sprintf (__sprintfieee128). If the GLIBC
is earlier than 2.32, the code will convert _Float128 to __ibm128 and then use
the normal sprintf to convert this value.
For conversions from Decimal to _Float128, this patch uses a function
(__strtokf) instead of strtold to convert the strings from the Decimal
conversion to long double. The __strtokf function determines if GLIBC 2.32 or
newer is used, and if it is, calls the IEEE 128-bit version (__strtoieee128).
If the GLIBC is earlier than 2.32, the code will call strtold and convert the
__ibm128 value to _Float128.
These functions will primarily be used if/when the default PowerPC long double
type is changed to IEEE 128-bit, but they could also be used if the user
explicitly converts _Float128 to/from a Decimal type.
libgcc/
2021-02-22 Michael Meissner <meissner@linux.ibm.com>
* config/rs6000/_dd_to_kf.c: New file.
* config/rs6000/_kf_to_dd.c: New file.
* config/rs6000/_kf_to_sd.c: New file.
* config/rs6000/_kf_to_td.c: New file.
* config/rs6000/_sd_to_kf.c: New file.
* config/rs6000/_sprintfkf.c: New file.
* config/rs6000/_sprintfkf.h: New file.
* config/rs6000/_strtokf.h: New file.
* config/rs6000/_strtokf.c: New file.
* config/rs6000/_td_to_kf.c: New file.
* config/rs6000/quad-float128.h: Add new declarations.
* config/rs6000/t-float128 (fp128_dec_funcs): New macro.
(fp128_decstr_funcs): New macro.
(ibm128_dec_funcs): New macro.
(fp128_ppc_funcs): Add the new conversions.
(fp128_dec_objs): Force Decimal <-> __float128 conversions to be
compiled with -mabi=ieeelongdouble.
(fp128_decstr_objs): Force __float128 <-> string conversions to be
compiled with -mabi=ibmlongdouble.
(ibm128_dec_objs): Force Decimal <-> __float128 conversions to be
compiled with -mabi=ieeelongdouble.
(FP128_CFLAGS_DECIMAL): New macro.
(IBM128_CFLAGS_DECIMAL): New macro.
* dfp-bit.c (DFP_TO_BFP): Add PowerPC _Float128 support.
(BFP_TO_DFP): Add PowerPC _Float128 support.
* dfp-bit.h (BFP_KIND): Add new binary floating point kind for
IEEE 128-bit floating point.
(DFP_TO_BFP): Add PowerPC _Float128 support.
(BFP_TO_DFP): Add PowerPC _Float128 support.
(BFP_SPRINTF): New macro.
Hans-Peter Nilsson [Mon, 22 Feb 2021 19:36:01 +0000 (20:36 +0100)]
g++.dg/warn/Warray-bounds-10..13: Fix for 32-bit newlib targets
See gcc/config/newlib-stdint.h, where targets that have
LONG_TYPE_SIZE == 32, get __INT32_TYPE__ defined to "long
int".
All these tests have "typedef __INT32_TYPE__ int32_t;".
Thus the tests fail for 32-bit newlib targets due to related
warning messages being matched to "aka int" where the
emitted message for these targets have "aka long int".
Tested cris-elf and x86_64-linux, committed as obvious.
gcc/testsuite:
* g++.dg/warn/Warray-bounds-10.C, g++.dg/warn/Warray-bounds-11.C,
g++.dg/warn/Warray-bounds-12.C, g++.dg/warn/Warray-bounds-13.C:
Handle __INT32_TYPE__ being "long int".
Hans-Peter Nilsson [Wed, 17 Feb 2021 18:05:35 +0000 (19:05 +0100)]
testsuite/gcc.target/cris/biap.c: Add a Y+=X*2 to the Y+=X*4.
Also, tweak the scan-assembler regexps to include a tab,
lest they may spuriously match file-paths in the emitted
assembly code, should some be added at some point. And, add
"mul", "move" and (non-addi-)"add" to insns that shouldn't
appear.
gcc/testsuite:
* gcc.target/cris/biap.c: Add a Y+=X*2 to the Y+=X*4.
Hans-Peter Nilsson [Wed, 17 Feb 2021 18:10:11 +0000 (19:10 +0100)]
testsuite/gcc.target/cris/biap-mul.c: New test.
gcc/testsuite:
* gcc.target/cris/biap-mul.c: New test.
Hans-Peter Nilsson [Wed, 17 Feb 2021 18:37:18 +0000 (19:37 +0100)]
cris: Fix addi insn mult vs. shift canonicalization
Ever since the canonicalization clean-up of (mult X (1 << N)) into
(ashift X N) outside addresses, the CRIS addi patterns have been
unmatched. No big deal.
Unfortunately, nobody thought of adjusting reloaded addresses, so
transforming mult into a shift has to be a kludged for when reload
decides that it has to move an address like (plus (mult reg0 4) reg1)
into a register, as happens building libgfortran. (No, simplify_rtx
et al don't automatically DTRT.) Something less kludgy would make
sense if it wasn't for the current late development stage and reload
being deprecated. I don't know whether this issue is absent for LRA,
though.
I added a testsuite for the reload issue, despite being exposed by a
libgfortran build, so the issue would be covered by C/C++ builds, but
to the CRIS test-suite, not as a generic test, to avoid bad feelings
from anyone preferring short test-times to redundant coverage.
gcc:
* config/cris/cris.c (cris_print_operand) <'T'>: Change
valid operand from is now an addi mult-value to shift-value.
* config/cris/cris.md (*addi): Change expression of scaled
operand from mult to ashift.
* config/cris/cris.md (*addi_reload): New insn_and_split.
gcc/testsuite:
* gcc.target/cris/torture/sync-reload-mul-1.c: New test.
Nathan Sidwell [Mon, 22 Feb 2021 15:43:56 +0000 (07:43 -0800)]
c++: Recursing header imports and other duplicates [PR 99174]
The fix for 98741 introduced two issues. (a) recursive header units
iced because we tried to read the preprocessor state after having
failed to read the config. (b) we could have duplicate imports of
named modules in our pending queue, and that would lead to duplicate
requests for pathnames, which coupled with the use of a null-pathname
to indicate we'd asked could lead to desynchronization with the module
mapper. Fixed by adding a 'visited' flag to module state, so we ask
exactly once.
PR c++/99174
gcc/cp
* module.cc (struct module_state): Add visited_p flag.
(name_pending_imports): Use it to avoid duplicate requests.
(preprocess_module): Don't read preprocessor state if we failed to
load a module's config.
gcc/testsuite/
* g++.dg/modules/pr99174-1_a.C: New.
* g++.dg/modules/pr99174-1_b.C: New.
* g++.dg/modules/pr99174-1_c.C: New.
* g++.dg/modules/pr99174.H: New.
John David Anglin [Mon, 22 Feb 2021 15:32:34 +0000 (15:32 +0000)]
Add mi_thunk support for vcalls on hppa.
gcc/ChangeLog:
PR target/85074
* config/pa/pa.c (TARGET_ASM_CAN_OUTPUT_MI_THUNK): Define as
hook_bool_const_tree_hwi_hwi_const_tree_true.
(pa_asm_output_mi_thunk): Add support for nonzero vcall_offset.
Nathan Sidwell [Mon, 22 Feb 2021 14:43:32 +0000 (06:43 -0800)]
c++: cross-header-unit template definitions [PR 99153]
A member function can be defined in a different header-file than the
one defining the class. In such situations we must unmark the decl as
imported. When the entity is a template we failed to unmark the
template_decl.
Perhaps the duplication of these flags on the template_decl from the
underlying decl is an error. I set on the fence about it for a long
time during development, but I don't think now is the time to change
that (barring catastrophic bugs).
PR c++/99153
gcc/cp/
* decl.c (duplicate_decls): Move DECL_MODULE_IMPORT_P propagation
to common-path.
* module.cc (set_defining_module): Add assert.
gcc/testsuite/
* g++.dg/modules/pr99153_a.H: New.
* g++.dg/modules/pr99153_b.H: New.
Andre Vieira [Mon, 22 Feb 2021 13:41:46 +0000 (13:41 +0000)]
ira: Make sure allocno copies are ordered [PR98791]
gcc/ChangeLog:
2021-02-22 Andre Vieira <andre.simoesdiasvieira@arm.com>
PR rtl-optimization/98791
* ira-conflicts.c (process_regs_for_copy): Don't create allocno copies
for unordered modes.
gcc/testsuite/ChangeLog:
2021-02-22 Andre Vieira <andre.simoesdiasvieira@arm.com>
PR rtl-optimization/98791
* gcc.target/aarch64/sve/pr98791.c: New test.
Tobias Burnus [Mon, 22 Feb 2021 12:20:26 +0000 (13:20 +0100)]
Fortran/OpenMP: Fix optional dummy procedures [PR99171]
gcc/fortran/ChangeLog:
PR fortran/99171
* trans-openmp.c (gfc_omp_is_optional_argument): Regard optional
dummy procs as nonoptional as no special treatment is needed.
libgomp/ChangeLog:
PR fortran/99171
* testsuite/libgomp.fortran/dummy-procs-1.f90: New test.
Martin Liska [Sat, 20 Feb 2021 10:47:12 +0000 (11:47 +0100)]
Fix ICE in tree_inlinable_function_p.
After g:
1a2a7096e5e20d736c6138179470b21aa5a74864 we forbid inlining
for a VLA types. What we miss is setting inline_forbidden_reason
variable.
Fixes:
./xgcc -B. -O3 -c /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/pr99122-2.c -Winline
during GIMPLE pass: local-fnsummary
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/pr99122-2.c: In function ‘foo’:
/home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/pr99122-2.c:21:1: internal compiler error: Segmentation fault
21 | }
| ^
0xe8b2ca crash_signal
/home/marxin/Programming/gcc/gcc/toplev.c:327
0x1a92733 pp_format(pretty_printer*, text_info*)
/home/marxin/Programming/gcc/gcc/pretty-print.c:1096
0x1a76b90 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
/home/marxin/Programming/gcc/gcc/diagnostic.c:1244
0x1a79994 diagnostic_impl
/home/marxin/Programming/gcc/gcc/diagnostic.c:1406
0x1a79994 warning(int, char const*, ...)
/home/marxin/Programming/gcc/gcc/diagnostic.c:1527
0xf1bb16 tree_inlinable_function_p(tree_node*)
/home/marxin/Programming/gcc/gcc/tree-inline.c:4123
0xc3f1c5 compute_fn_summary(cgraph_node*, bool)
/home/marxin/Programming/gcc/gcc/ipa-fnsummary.c:3110
0xc3f937 compute_fn_summary_for_current
/home/marxin/Programming/gcc/gcc/ipa-fnsummary.c:3160
0xc3f937 execute
/home/marxin/Programming/gcc/gcc/ipa-fnsummary.c:4768
gcc/ChangeLog:
* tree-inline.c (inline_forbidden_p): Set
inline_forbidden_reason.
Richard Biener [Mon, 22 Feb 2021 08:30:49 +0000 (09:30 +0100)]
dump SLP subgraph before costing
This adds another dump of the SLP subgraph we're throwing at costing.
2021-02-22 Richard Biener <rguenther@suse.de>
* tree-vect-slp.c (vect_bb_vectorization_profitable_p): Dump
costed subgraph.
Richard Biener [Mon, 22 Feb 2021 07:36:55 +0000 (08:36 +0100)]
tree-optimization/99165 - fix ICE in store-merging w/ non-call EH
This adds a missing accumulation to ret.
2021-02-22 Richard Biener <rguenther@suse.de>
PR tree-optimization/99165
* gimple-ssa-store-merging.c (pass_store_merging::process_store):
Accumulate changed to ret.
* g++.dg/pr99165.C: New testcase.
GCC Administrator [Mon, 22 Feb 2021 00:16:19 +0000 (00:16 +0000)]
Daily bump.
Harald Anlauf [Sun, 21 Feb 2021 20:44:24 +0000 (21:44 +0100)]
PR fortran/99169 - Do not clobber allocatable intent(out) dummy argument
gcc/fortran/ChangeLog:
* trans-expr.c (gfc_conv_procedure_call): Do not add clobber to
allocatable intent(out) argument.
gcc/testsuite/ChangeLog:
* gfortran.dg/intent_optimize_3.f90: New test.
Uros Bizjak [Sun, 21 Feb 2021 17:41:29 +0000 (18:41 +0100)]
Revert: "i386: Remove REG_ALLOC_ORDER definition"
This reverts commit
4c61e35f20fe2ffeb9421dbd6f26c767a234a4a0.
GCC Administrator [Sun, 21 Feb 2021 00:16:18 +0000 (00:16 +0000)]
Daily bump.
Mike Frysinger [Sun, 14 Feb 2021 02:25:28 +0000 (21:25 -0500)]
libiberty: autogenerate aclocal.m4
Move custom macros to acinclude.m4 so we can autogenerate aclocal.m4
with aclocal. This matches every other project in the tree.
libiberty/ChangeLog:
* Makefile.in (ACLOCAL, ACLOCAL_AMFLAGS, $(srcdir)/aclocal.m4): Define.
(configure_deps): Rename to ...
(aclocal_deps): ... this. Replace aclocal.m4 with acinclude.m4.
($(srcdir)/configure): Replace $(configure_deps) with
$(srcdir)/aclocal.m4.
* aclocal.m4: Move libiberty macros to acinclude.m4, then regenerate.
* acinclude.m4: New file.
* configure: Regenerate.
David Edelsohn [Fri, 19 Feb 2021 23:38:18 +0000 (18:38 -0500)]
testsuite: skip attr-retain-?.c on AIX
The attr-retain-?.c tests assume ELF file syntax / semantics. Some of the
tests skip AIX because of other requirements, and some explicitly skip
Darwin. This patch adds AIX to the explicit skip list.
gcc/testsuite/ChangeLog:
* c-c++-common/attr-retain-5.c: Skip on AIX.
* c-c++-common/attr-retain-6.c: Same.
* c-c++-common/attr-retain-7.c: Same.
* c-c++-common/attr-retain-8.c: Same.
* c-c++-common/attr-retain-9.c: Same.
Ilya Leoshkevich [Wed, 17 Feb 2021 13:40:03 +0000 (14:40 +0100)]
IBM Z: Fix long double <-> DFP conversions
When switching the s390 backend to store long doubles in vector
registers, the patterns for long double <-> DFP conversions were
forgotten. This did not cause observable problems so far, because
libdfp calls are emitted instead of pfpo. However, when building
libdfp itself, this leads to infinite recursion.
gcc/ChangeLog:
PR target/99134
* config/s390/vector.md (trunctf<DFP_ALL:mode>2_vr): New
pattern.
(trunctf<DFP_ALL:mode>2): Likewise.
(trunctdtf2_vr): Likewise.
(trunctdtf2): Likewise.
(extend<DFP_ALL:mode>tf2_vr): Likewise.
(extend<DFP_ALL:mode>tf2): Likewise.
(extendtftd2_vr): Likewise.
(extendtftd2): Likewise.
gcc/testsuite/ChangeLog:
PR target/99134
* gcc.target/s390/vector/long-double-from-decimal128.c: New test.
* gcc.target/s390/vector/long-double-from-decimal32.c: New test.
* gcc.target/s390/vector/long-double-from-decimal64.c: New test.
* gcc.target/s390/vector/long-double-to-decimal128.c: New test.
* gcc.target/s390/vector/long-double-to-decimal32.c: New test.
* gcc.target/s390/vector/long-double-to-decimal64.c: New test.
Ilya Leoshkevich [Wed, 17 Feb 2021 15:15:42 +0000 (16:15 +0100)]
IBM Z: Improve FPRX2 <-> TF conversions
gcc/ChangeLog:
* config/s390/vector.md (*fprx2_to_tf): Rename to fprx2_to_tf,
add memory alternative.
(tf_to_fprx2): New pattern.
GCC Administrator [Sat, 20 Feb 2021 00:16:26 +0000 (00:16 +0000)]
Daily bump.
Nathan Sidwell [Fri, 19 Feb 2021 21:10:27 +0000 (13:10 -0800)]
c++: Incorrect module-number ordering [PR 98741]
One of the very strong invariants in modules is that module numbers
are allocated such that (other than the current TU), all imports have
lesser module numbers, and also that the binding vector is only
appended to with increasing module numbers. This broke down when
module-directives became a thing and the preprocessing became entirely
decoupled from parsing. We'd load header units and their macros (but
not symbols of course) during preprocessing. Then we'd load named
modules during parsing. This could lead to the situation where a
header unit appearing after a named import had a lower module number
than the import. Consequently, if they both bound the same
identifier, the binding vector would be misorderd and bad things
happen.
This patch restores a pending import queue I previously had, but in
simpler form (hurrah). During preprocessing we queue all
module-directives and when we meet one for a header unit we do the
minimal loading for all of the queue, so they get appropriate
numbering. Then we load the preprocessor state for the header unit.
PR c++/98741
gcc/cp/
* module.cc (pending_imports): New.
(declare_module): Adjust test condition.
(name_pending_imports): New.
(preprocess_module): Reimplement using pending_imports.
(preprocessed_module): Move name-getting to name_pending_imports.
* name-lookup.c (append_imported_binding_slot): Assert module
ordering is increasing.
gcc/testsuite/
* g++.dg/modules/pr98741_a.H: New.
* g++.dg/modules/pr98741_b.H: New.
* g++.dg/modules/pr98741_c.C: New.
* g++.dg/modules/pr98741_d.C: New.
Jerry DeLisle [Fri, 19 Feb 2021 20:47:54 +0000 (12:47 -0800)]
fortran: Object types should be declared before use in NAMELIST.
gcc/fortran/ChangeLog:
PR fortran/98686
* match.c (gfc_match_namelist): If BT_UNKNOWN, check for
IMPLICIT NONE and and issue an error, otherwise set the type
to its IMPLICIT type so that any subsequent use of objects will
will confirm their types.
gcc/testsuite/ChangeLog:
PR fortran/98686
* gfortran.dg/namelist_4.f90: Modify.
* gfortran.dg/namelist_98.f90: New test.
Joseph Myers [Fri, 19 Feb 2021 20:45:43 +0000 (20:45 +0000)]
Update gcc fr.po.
* fr.po: Update.
Ian Lance Taylor [Fri, 19 Feb 2021 02:54:38 +0000 (18:54 -0800)]
libgo: update to Go1.16 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/293793
Harald Anlauf [Fri, 19 Feb 2021 19:21:27 +0000 (20:21 +0100)]
PR fortran/99147 - Sanitizer detects heap-use-after-free in gfc_add_flavor
Reverse order of conditions to avoid invalid read.
gcc/fortran/ChangeLog:
* symbol.c (gfc_add_flavor): Reverse order of conditions.
Joseph Myers [Fri, 19 Feb 2021 18:23:36 +0000 (18:23 +0000)]
Update .po files.
gcc/po/
* be.po, da.po, de.po, el.po, es.po, fi.po, fr.po, hr.po, id.po,
ja.po, nl.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po,
zh_TW.po: Update.
libcpp/po/
* be.po, ca.po, da.po, de.po, el.po, eo.po, es.po, fi.po, fr.po,
id.po, ja.po, nl.po, pt_BR.po, ru.po, sr.po, sv.po, tr.po, uk.po,
vi.po, zh_CN.po, zh_TW.po: Update.
Martin Sebor [Fri, 19 Feb 2021 18:06:06 +0000 (11:06 -0700)]
PR c/97172 - ICE: tree code 'ssa_name' is not supported in LTO streams
gcc/ChangeLog:
PR c/97172
* attribs.c (init_attr_rdwr_indices): Guard vblist use.
(attr_access::free_lang_data): Remove a spurious test.
gcc/testsuite/ChangeLog:
PR c/97172
* gcc.dg/pr97172.c: Add test cases.
Nathan Sidwell [Fri, 19 Feb 2021 17:18:13 +0000 (09:18 -0800)]
c++: Inform of CMI reads [PR 99166]
When successfully reading a module CMI, the user gets no indication of
where that CMI was located. I originally didn't consider this a
problem -- the read was successful after all. But it can make it
difficult to interact with build systems, particularly when caching
can be involved. Grovelling over internal dump files is not really
useful to the user. Hence this option, which is similar to the
-flang-info-include-translate variants, and allows the user to ask for
all, or specific module read notification.
gcc/c-family/
* c.opt (flang-info-module-read, flang-info-module-read=): New.
gcc/
* doc/invoke.texi (flang-info-module-read): Document.
gcc/cp/
* module.cc (note_cmis): New.
(struct module_state): Add inform_read_p bit.
(module_state::do_import): Inform of CMI location, if enabled.
(init_modules): Canonicalize note_cmis entries.
(handle_module_option): Handle -flang-info-module-read=FOO.
gcc/testsuite/
* g++.dg/modules/pr99166_a.X: New.
* g++.dg/modules/pr99166_b.C: New.
* g++.dg/modules/pr99166_c.C: New.
* g++.dg/modules/pr99166_d.C: New.
Tobias Burnus [Fri, 19 Feb 2021 17:07:26 +0000 (18:07 +0100)]
Fortran: Fix coarray handling for gfc_dep_resolver [PR99010]
Check failed if identical = false was requested or for -fcoarray=single
if an array ref was for a coindexed scalar.
gcc/fortran/ChangeLog:
PR fortran/99010
* dependency.c (gfc_dep_resolver): Fix coarray handling.
gcc/testsuite/ChangeLog:
PR fortran/99010
* gfortran.dg/coarray/array_temporary-1.f90: New test.
Tobias Burnus [Fri, 19 Feb 2021 17:05:31 +0000 (18:05 +0100)]
Fortran: Fix DTIO with type ICE [PR99146]
gcc/fortran/ChangeLog:
PR fortran/99146
* interface.c:
gcc/testsuite/ChangeLog:
PR fortran/99146
* gfortran.dg/dtio_36.f90: New test.
Martin Liska [Fri, 19 Feb 2021 16:29:23 +0000 (17:29 +0100)]
Fix typo in param description.
gcc/ChangeLog:
PR translation/99167
* params.opt: Fix typo.
Richard Biener [Fri, 19 Feb 2021 08:38:52 +0000 (09:38 +0100)]
middle-end/99122 - more VLA inlining fixes
This avoids declaring a function with VLA arguments or return values
as inlineable. IPA CP still ICEs, so the testcase has that disabled.
2021-02-19 Richard Biener <rguenther@suse.de>
PR middle-end/99122
* tree-inline.c (inline_forbidden_p): Do not inline functions
with VLA arguments or return value.
* gcc.dg/pr99122-3.c: New testcase.
Jakub Jelinek [Fri, 19 Feb 2021 12:05:47 +0000 (13:05 +0100)]
arm: Fix ICE with -fstack-protector -mpure-code [PR98998]
The vla15.C testcase ICEs with
-mcpu=cortex-m1 -mpure-code -fstack-protector -mthumb
as what force_const_mem returns (a SYMBOL_REF) is not a valid
memory address.
Previously the code was moving the address of the force_const_mem
into a register rather than the content of that MEM, so that instruction
must have been supported and loading from a MEM with a single REG base ought
to be valid too.
2021-02-19 Jakub Jelinek <jakub@redhat.com>
PR target/98998
* config/arm/arm.md (*stack_protect_combined_set_insn,
*stack_protect_combined_test_insn): If force_const_mem result
is not valid general operand, force its address into the destination
register first.
* gcc.target/arm/pure-code/pr98998.c: New test.
Jakub Jelinek [Fri, 19 Feb 2021 11:14:39 +0000 (12:14 +0100)]
tree-cfg: Fix up gimple_merge_blocks FORCED_LABEL handling [PR99034]
The verifiers require that DECL_NONLOCAL or EH_LANDING_PAD_NR
labels are always the first label if there is more than one label.
When merging blocks, we don't honor that though.
On the following testcase, we try to merge blocks:
<bb 13> [count: 0]:
<L2>:
S::~S (&s);
and
<bb 15> [count: 0]:
<L0>:
resx 1
where <L2> is landing pad and <L0> is FORCED_LABEL. And the code puts
the FORCED_LABEL before the landing pad label, violating the verification
requirements.
The following patch fixes it by moving the FORCED_LABEL after the
DECL_NONLOCAL or EH_LANDING_PAD_NR label if it is the first label.
2021-02-19 Jakub Jelinek <jakub@redhat.com>
PR ipa/99034
* tree-cfg.c (gimple_merge_blocks): If bb a starts with eh landing
pad or non-local label, put FORCED_LABELs from bb b after that label
rather than before it.
* g++.dg/opt/pr99034.C: New test.
Jonathan Wakely [Fri, 19 Feb 2021 09:54:04 +0000 (09:54 +0000)]
libstdc++: Fix __thread_relax for non-gthreads non-x86 targets
My recent change to the preprocessor conditions in __thread_relax() was
supposed to also change the __gthread_yield() call to __thread_yield(),
which has the right preprocessor checks. Instead I just removed the
check for _GLIBCXX_USE_SCHED_YIELD which means the __gthread_yield()
call will be ill-formed for non-gthreads targets, and targets without
sched_yield(). This fixes it properly.
libstdc++-v3/ChangeLog:
* include/bits/atomic_wait.h (__thread_relax()): Call
__thread_yield() not __gthread_yield().
Tobias Burnus [Fri, 19 Feb 2021 09:42:15 +0000 (10:42 +0100)]
Fortran: Fix ubound simplifcation [PR99027]
gcc/fortran/ChangeLog:
PR fortran/99027
* simplify.c (simplify_bound_dim): Honor DIMEN_ELEMENT
when using dim=.
gcc/testsuite/ChangeLog:
PR fortran/99027
* gfortran.dg/ubound_1.f90: New test.
Andre Vieira [Fri, 19 Feb 2021 09:13:02 +0000 (09:13 +0000)]
aarch64: Check predicate when using gen_vec_duplicate [PR98657]
Prevents generation of a vec_duplicate with illegal predicate in
<ASHIFT:optab><mode>3.
gcc/ChangeLog:
2021-02-19 Andre Vieira <andre.simoesdiasvieira@arm.com>
PR target/98657
* config/aarch64/aarch64-sve.md (<ASHIFT:optab><mode>3): Use
expand_vector_broadcast' to emit the vec_duplicate operand.
gcc/testsuite/ChangeLog:
2021-02-19 Andre Vieira <andre.simoesdiasvieira@arm.com>
PR target/98657
* gcc.target/aarch64/sve/pr98657.c: New test.
Ayush Mittal [Fri, 19 Feb 2021 04:59:03 +0000 (21:59 -0700)]
[PATCH v2] libiberty(argv.c): Fix memory leak in expandargv
libiberty:
* argv.c (expandargv): free allocated buffer if read fails.
Jason Merrill [Fri, 19 Feb 2021 02:27:37 +0000 (21:27 -0500)]
c++: Tweak PR969626 patch
It occurred to me that other types of conversions use rvaluedness_matches_p,
but those uses don't affect overload resolution, so we shouldn't look at the
flag for them. Fixing that made decltype64.C compile successfully, because
the non-template candidate was a perfect match, so we now wouldn't consider
the broken template. Changing the argument to const& makes it no longer a
perfect match (because of the added const), so we again get the infinite
recursion.
This illustrates the limited nature of this optimization/recursion break; it
works for most copy/move constructors because the constructor we're looking
for is almost always a perfect match. If it happens to help improve compile
time for other calls, that's just a bonus.
gcc/cp/ChangeLog:
PR c++/96926
* call.c (perfect_conversion_p): Limit rvalueness
test to reference bindings.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/decltype64.C: Change argument to const&.
David Malcolm [Fri, 19 Feb 2021 02:28:26 +0000 (21:28 -0500)]
jit: fix ICE on BUILT_IN_TRAP [PR99126]
gcc/jit/ChangeLog:
PR jit/99126
* jit-builtins.c
(gcc::jit::builtins_manager::get_builtin_function_by_id):
Update assertion to reject BUILT_IN_NONE.
(gcc::jit::builtins_manager::ensure_optimization_builtins_exist):
New.
* jit-builtins.h
(gcc::jit::builtins_manager::ensure_optimization_builtins_exist):
New decl.
* jit-playback.c (gcc::jit::playback::context::replay): Call it.
Remove redundant conditional on bm.
gcc/testsuite/ChangeLog:
PR jit/99126
* jit.dg/test-trap.c: New test.
Jason Merrill [Sat, 13 Feb 2021 05:40:11 +0000 (00:40 -0500)]
c++: Tuple of self-dependent classes [PR96926]
When compiling this testcase, trying to resolve the initialization for the
tuple member ends up recursively considering the same set of tuple
constructor overloads, and since two of them separately depend on
is_constructible, the one we try second fails to instantiate
is_constructible because we're still in the middle of instantiating it the
first time.
Fixed by implementing an optimization that someone suggested we were already
doing: if we see a non-template candidate that is a perfect match for all
arguments, we can skip considering template candidates at all. It would be
enough to do this only when LOOKUP_DEFAULTED, but it shouldn't hurt in other
cases.
gcc/cp/ChangeLog:
PR c++/96926
* call.c (perfect_conversion_p): New.
(perfect_candidate_p): New.
(add_candidates): Ignore templates after a perfect non-template.
gcc/testsuite/ChangeLog:
PR c++/96926
* g++.dg/cpp0x/overload4.C: New test.
GCC Administrator [Fri, 19 Feb 2021 00:16:21 +0000 (00:16 +0000)]
Daily bump.
Vladimir N. Makarov [Thu, 18 Feb 2021 22:49:26 +0000 (17:49 -0500)]
[PR96264] LRA: Check output insn hard regs when updating available rematerialization after the insn
Insn for rematerialization can contain a clobbered hard register. We
can not move such insn through another insn setting up the same hard
register. The patch adds such check.
gcc/ChangeLog:
PR rtl-optimization/96264
* lra-remat.c (reg_overlap_for_remat_p): Check also output insn
hard regs.
gcc/testsuite/ChangeLog:
PR rtl-optimization/96264
* gcc.target/powerpc/pr96264.c: New.
H.J. Lu [Mon, 15 Feb 2021 19:31:12 +0000 (11:31 -0800)]
Add retain attribute to place symbols in SHF_GNU_RETAIN section
When building Linux kernel, ld in bninutils 2.36 with GCC 11 generates
thousands of
ld: warning: orphan section `.data.event_initcall_finish' from `init/main.o' being placed in section `.data.event_initcall_finish'
ld: warning: orphan section `.data.event_initcall_start' from `init/main.o' being placed in section `.data.event_initcall_start'
ld: warning: orphan section `.data.event_initcall_level' from `init/main.o' being placed in section `.data.event_initcall_level'
Since these sections are marked with SHF_GNU_RETAIN, they are placed in
separate sections. They become orphan sections since they aren't expected
in the Linux kernel linker script. But orphan sections normally don't work
well with the Linux kernel linker script and the resulting kernel crashed.
Add the "retain" attribute to place symbols in separate SHF_GNU_RETAIN
sections. Issue a warning if the configured assembler/linker doesn't
support SHF_GNU_RETAIN.
gcc/
PR target/99113
* varasm.c (get_section): Replace SUPPORTS_SHF_GNU_RETAIN with
looking up the retain attribute.
(resolve_unique_section): Likewise.
(get_variable_section): Likewise.
(switch_to_section): Likewise. Warn when a symbol without the
retain attribute and a symbol with the retain attribute are
placed in the section with the same name, instead of the used
attribute.
* doc/extend.texi: Document the "retain" attribute.
gcc/c-family/
PR target/99113
* c-attribs.c (c_common_attribute_table): Add the "retain"
attribute.
(handle_retain_attribute): New function.
gcc/testsuite/
PR target/99113
* c-c++-common/attr-retain-1.c: New test.
* c-c++-common/attr-retain-2.c: Likewise.
* c-c++-common/attr-retain-3.c: Likewise.
* c-c++-common/attr-retain-4.c: Likewise.
* c-c++-common/attr-retain-5.c: Likewise.
* c-c++-common/attr-retain-6.c: Likewise.
* c-c++-common/attr-retain-7.c: Likewise.
* c-c++-common/attr-retain-8.c: Likewise.
* c-c++-common/attr-retain-9.c: Likewise.
* c-c++-common/pr99113.c: Likewise.
* gcc.c-torture/compile/attr-retain-1.c: Likewise.
* gcc.c-torture/compile/attr-retain-2.c: Likewise.
* c-c++-common/attr-used.c: Don't expect SHF_GNU_RETAIN section.
* c-c++-common/attr-used-2.c: Likewise.
* c-c++-common/attr-used-3.c: Likewise.
* c-c++-common/attr-used-4.c: Likewise.
* c-c++-common/attr-used-9.c: Likewise.
* gcc.c-torture/compile/attr-used-retain-1.c: Likewise.
* gcc.c-torture/compile/attr-used-retain-2.c: Likewise.
* c-c++-common/attr-used-5.c: Don't expect warning for the used
attribute nor SHF_GNU_RETAIN section.
* c-c++-common/attr-used-6.c: Likewise.
* c-c++-common/attr-used-7.c: Likewise.
* c-c++-common/attr-used-8.c: Likewise.
Nathan Sidwell [Thu, 18 Feb 2021 20:46:25 +0000 (12:46 -0800)]
c++: header-unit build capability [PR 99023]
This defect really required building header-units and include translation
of pieces of the standard library. This adds smarts to the modules
test harness to do that -- accept .X files as the source file, but
provide '-x c++-system-header $HDR' in the options. The .X file will
be considered by the driver to be a linker script and ignored (with a
warning).
Using this we can add 2 tests that end up building list_initializer
and iostream, along with a test that iostream's build
include-translates list_initializer's #include. That discovered a set
of issues with the -flang-info-include-translate=HDR handling, also
fixed and documented here.
PR c++/99023
gcc/cp/
* module.cc (canonicalize_header_name): Use
cpp_probe_header_unit.
(maybe_translate_include): Fix note_includes comparison.
(init_modules): Fix note_includes string termination.
libcpp/
* include/cpplib.h (cpp_find_header_unit): Rename to ...
(cpp_probe_header_unit): ... this.
* internal.h (_cp_find_header_unit): Declare.
* files.c (cpp_find_header_unit): Break apart to ..
(test_header_unit): ... this, and ...
(_cpp_find_header_unit): ... and, or and ...
(cpp_probe_header_unit): ... this.
* macro.c (cpp_get_token_1): Call _cpp_find_header_unit.
gcc/
* doc/invoke.texi (flang-info-include-translate): Document header
lookup behaviour.
gcc/testsuite/
* g++.dg/modules/modules.exp: Bail on cross-testing. Add support
for .X files.
* g++.dg/modules/pr99023_a.X: New.
* g++.dg/modules/pr99023_b.X: New.
Jakub Jelinek [Thu, 18 Feb 2021 21:17:52 +0000 (22:17 +0100)]
c: Fix ICE with -fexcess-precision=standard [PR99136]
The following testcase ICEs on i686-linux, because c_finish_return wraps
c_fully_folded retval back into EXCESS_PRECISION_EXPR, but when the function
return type is void, we don't call convert_for_assignment on it that would
then be fully folded again, but just put the retval into RETURN_EXPR's
operand, so nothing removes it anymore and during gimplification we
ICE as EXCESS_PRECISION_EXPR is not handled.
This patch fixes it by not adding that EXCESS_PRECISION_EXPR in functions
returning void, the return value is ignored and all we need is evaluate any
side-effects of the expression.
2021-02-18 Jakub Jelinek <jakub@redhat.com>
PR c/99136
* c-typeck.c (c_finish_return): Don't wrap retval into
EXCESS_PRECISION_EXPR in functions that return void.
* gcc.dg/pr99136.c: New test.
Nathan Sidwell [Thu, 18 Feb 2021 15:33:12 +0000 (07:33 -0800)]
c++: Remove obsolete dg-module-headers [PR 99023]
PR99023's testcase is highlighting some missing functionality of the
modules test harness. I did have some partial support, but it's only
use in one place for a now-obsolete test. This patch expunges that
support so I can add better functionality now I understand better what
is necessary.
PR c++/99023
gcc/testsuite/
* g++.dg/modules/modules.exp: Remove dg-module-headers support
* g++.dg/modules/alias-2_a.H: Delete.
* g++.dg/modules/sys/alias-2_a.H: Delete.
Nathan Sidwell [Thu, 18 Feb 2021 18:31:02 +0000 (10:31 -0800)]
c++: Remove large abi-specific tests [PR 99150]
Remove the two large and incorrectly abi-specific testcases I added.
Replacement tests will be forthcoming.
PR c++/99150
gcc/testsuite/
* g++.dg/modules/pr99023_a.H: Delete.
* g++.dg/modules/pr99023_b.H: Delete.
Jakub Jelinek [Thu, 18 Feb 2021 15:21:52 +0000 (16:21 +0100)]
c++: Fix -std=c++20 ICE on virtual method call [PR99132]
On the following testcase we ICE in C++20 mode during cp_get_callee_fndecl
-> constexpr evaluation.
It is only in C++20 mode on this testcase because virtual methods can't
be constexpr in C++17 and earlier and so potential_constant_expression_1
rejects it earlier.
And the ICE is caused by genericization changing the h PARM_DECL from having
B<C *> type to B<C *> & DECL_BY_REFERENCE and the constexpr evaluation
not being able to deal with that.
I think this just shows that we shouldn't do the constexpr evaluation during
genericization and later, and other spots e.g. during gimplification
also don't call cp_get_callee_fndecl but cp_get_callee_fndecl_nofold.
After all, cp_fold has already been run and it did the folding if there
was any opportunity to do so. And furthermore, what that cp_genericize_r
spot does is check for any left-over immediate function calls (which can be
ATM just std::source_location::current() call) and immediate functions
outside of immediate functions can't have addresses leaked into the IL,
so it will be always a direct call anyway. And immediate functions
themselves don't make it into genericization/gimplification.
2021-02-18 Jakub Jelinek <jakub@redhat.com>
PR c++/99132
* cp-gimplify.c (cp_genericize_r) <case CALL_EXPR>: Use
cp_get_callee_fndecl_nofold instead of cp_get_callee_fndecl to check
for immediate function calls.
* g++.dg/cpp2a/constexpr-virtual18.C: New test.
Richard Biener [Thu, 18 Feb 2021 11:28:26 +0000 (12:28 +0100)]
middle-end/99122 - Issues with VLA parameter inlining
The following instructs IPA not to inline calls with VLA parameters
and adjusts inlining not to create invalid view-converted VLA
parameters on mismatch and makes the error_mark paths with debug
stmts actually work.
The first part avoids the ICEs with the testcases already.
2021-02-18 Richard Biener <rguenther@suse.de>
PR middle-end/99122
* ipa-fnsummary.c (analyze_function_body): Set
CIF_FUNCTION_NOT_INLINABLE for VLA parameter calls.
* tree-inline.c (insert_init_debug_bind): Pass NULL for
error_mark_node values.
(force_value_to_type): Do not build V_C_Es for WITH_SIZE_EXPR
values.
(setup_one_parameter): Delay force_value_to_type until when
it's needed.
* gcc.dg/pr99122-1.c: New testcase.
* gcc.dg/pr99122-2.c: Likewise.
Hans-Peter Nilsson [Tue, 16 Feb 2021 21:27:53 +0000 (22:27 +0100)]
match.pd: Restrict clz cmp 0 replacement by single_use, PR99142
If we're not going to eliminate the clz, it's better for the
comparison to use that result than its input, so we don't
extend the lifetime of the input. Also, an additional use
of the result is more likely cheaper than a compare of the
input, in particular considering that the clz may have made
available a non-zero condition matching the original use.
The "s" modifier doesn't stop this situation, as the
transformation wouldn't result in "an expression with more
than one operator"; a gating single_use condition on the
result is necessary.
gcc:
PR tree-optimization/99142
* match.pd (clz cmp 0): Gate replacement on single_use of clz result.
gcc/testsuite:
PR tree-optimization/99142
* gcc.dg/tree-ssa/pr99142.c: New test.
Jakub Jelinek [Thu, 18 Feb 2021 09:32:57 +0000 (10:32 +0100)]
i386: Avoid C++ global constructors in every object that includes i386.h
When looking at recog.o when working on the recog.[ch] changes to make sure
I have not introduced runtime construction of recog_data variable, I have
noticed that at least in unoptimized build, every single *.o file that
included i386.h has lots of runtime constructors for all the PTA_*
variables.
As we now require C++11, the following patch makes those constexpr so that
they don't need runtime initialization.
I've verified that ~ 8276 bytes long _Z41__static_initialization_and_destruction_0ii
at -O0 is gone from every *.o that included i386.h (and doesn't really need
any global ctors anymore).
2021-02-18 Jakub Jelinek <jakub@redhat.com>
* wide-int-bitmask.h (wide_int_bitmask::wide_int_bitmask (),
wide_int_bitmask::wide_int_bitmask (uint64_t),
wide_int_bitmask::wide_int_bitmask (uint64_t, uint64_t),
wide_int_bitmask::operator ~ () const,
wide_int_bitmask::operator | (wide_int_bitmask) const,
wide_int_bitmask::operator & (wide_int_bitmask) const): Use constexpr
instead of inline.
* config/i386/i386.h (PTA_3DNOW, PTA_3DNOW_A, PTA_64BIT, PTA_ABM,
PTA_AES, PTA_AVX, PTA_BMI, PTA_CX16, PTA_F16C, PTA_FMA, PTA_FMA4,
PTA_FSGSBASE, PTA_LWP, PTA_LZCNT, PTA_MMX, PTA_MOVBE, PTA_NO_SAHF,
PTA_PCLMUL, PTA_POPCNT, PTA_PREFETCH_SSE, PTA_RDRND, PTA_SSE, PTA_SSE2,
PTA_SSE3, PTA_SSE4_1, PTA_SSE4_2, PTA_SSE4A, PTA_SSSE3, PTA_TBM,
PTA_XOP, PTA_AVX2, PTA_BMI2, PTA_RTM, PTA_HLE, PTA_PRFCHW, PTA_RDSEED,
PTA_ADX, PTA_FXSR, PTA_XSAVE, PTA_XSAVEOPT, PTA_AVX512F, PTA_AVX512ER,
PTA_AVX512PF, PTA_AVX512CD, PTA_NO_TUNE, PTA_SHA, PTA_PREFETCHWT1,
PTA_CLFLUSHOPT, PTA_XSAVEC, PTA_XSAVES, PTA_AVX512DQ, PTA_AVX512BW,
PTA_AVX512VL, PTA_AVX512IFMA, PTA_AVX512VBMI, PTA_CLWB, PTA_MWAITX,
PTA_CLZERO, PTA_NO_80387, PTA_PKU, PTA_AVX5124VNNIW, PTA_AVX5124FMAPS,
PTA_AVX512VPOPCNTDQ, PTA_SGX, PTA_AVX512VNNI, PTA_GFNI, PTA_VAES,
PTA_AVX512VBMI2, PTA_VPCLMULQDQ, PTA_AVX512BITALG, PTA_RDPID,
PTA_PCONFIG, PTA_WBNOINVD, PTA_AVX512VP2INTERSECT, PTA_PTWRITE,
PTA_AVX512BF16, PTA_WAITPKG, PTA_MOVDIRI, PTA_MOVDIR64B, PTA_ENQCMD,
PTA_CLDEMOTE, PTA_SERIALIZE, PTA_TSXLDTRK, PTA_AMX_TILE, PTA_AMX_INT8,
PTA_AMX_BF16, PTA_UINTR, PTA_HRESET, PTA_KL, PTA_WIDEKL, PTA_AVXVNNI,
PTA_X86_64_BASELINE, PTA_X86_64_V2, PTA_X86_64_V3, PTA_X86_64_V4,
PTA_CORE2, PTA_NEHALEM, PTA_WESTMERE, PTA_SANDYBRIDGE, PTA_IVYBRIDGE,
PTA_HASWELL, PTA_BROADWELL, PTA_SKYLAKE, PTA_SKYLAKE_AVX512,
PTA_CASCADELAKE, PTA_COOPERLAKE, PTA_CANNONLAKE, PTA_ICELAKE_CLIENT,
PTA_ICELAKE_SERVER, PTA_TIGERLAKE, PTA_SAPPHIRERAPIDS, PTA_ALDERLAKE,
PTA_KNL, PTA_BONNELL, PTA_SILVERMONT, PTA_GOLDMONT, PTA_GOLDMONT_PLUS,
PTA_TREMONT, PTA_KNM): Use constexpr instead of const.
Jakub Jelinek [Thu, 18 Feb 2021 08:45:19 +0000 (09:45 +0100)]
array-bounds: Fix up ICE on overaligned variables [PR99109]
check_mem_ref builds artificial arrays for variables that don't have
array type.
The C standard says:
"For the purposes of these operators, a pointer to an object that is not an element of an
array behaves the same as a pointer to the first element of an array of length one with the
type of the object as its element type."
so it isn't completely wrong and does simplify the function.
But, layout_type can fail if the size of the element type is not a multiple
of its alignment (i.e. overaligned types) and we then ICE because of that.
The following patch uses TYPE_MAIN_VARIANT in those cases instead, but only
for the types that need it, as for the diagnostics it is better to use the
typedef names etc. that were really used in the source if possible.
2021-02-18 Jakub Jelinek <jakub@redhat.com>
PR middle-end/99109
* gimple-array-bounds.cc (build_zero_elt_array_type): Rename to ...
(build_printable_array_type): ... this. Add nelts argument. For
overaligned eltype, use TYPE_MAIN_VARIANT (eltype) instead. If
nelts, call build_array_type_nelts.
(array_bounds_checker::check_mem_ref): Use build_printable_array_type
instead of build_zero_elt_array_type and build_array_type_nelts.
* g++.dg/warn/Warray-bounds-17.C: New test.
Jakub Jelinek [Thu, 18 Feb 2021 08:16:28 +0000 (09:16 +0100)]
i386: Fix up df uses in i386 splitters [PR99104]
The following testcase started ICEing with my recent changes to enable
split4 after sel-sched, but it seems the bug is more general.
Some of the i386 splitter condition functions use and rely on df, but
the split passes don't really df_analyze/df_finish_pass, so the DF info
may be stale or not computed at all - the particular ICE is because
there is a new bb and df_get_live_out (bb) returns NULL on it as the
live or lr problem has not been computed yet.
This patch fixes it by not calling ix86_ok_to_clobber_flags from
ix86_avoid_lea_for_add where it wasn't ever needed because the splitters
using that function as condition have (clobber FLAGS) in their pattern.
And, changes the ix86_avoid_lea_for_addr using splitter from normal splitter
to peephole2 splitter that uses peep2_regno_dead_p infrastructure to
determine if FLAGS is dead. Also, it saves and restores recog_data
variable around the call to distance_non_agu_define and doesn't call
extract_insn_data there, because split_insns or peephole2_insns just
clear recog_data.insn and then fill in recog_data.operand array, and so
might not match what extract_insn will do on the insn at all.
2021-02-18 Jakub Jelinek <jakub@redhat.com>
PR target/99104
* config/i386/i386.c (distance_non_agu_define): Don't call
extract_insn_cached here.
(ix86_lea_outperforms): Save and restore recog_data around call
to distance_non_agu_define and distance_agu_use.
(ix86_ok_to_clobber_flags): Remove.
(ix86_avoid_lea_for_add): Don't call ix86_ok_to_clobber_flags.
(ix86_avoid_lea_for_addr): Likewise. Adjust function comment.
* config/i386/i386.md (*lea<mode>): Change from define_insn_and_split
into define_insn. Move the splitting to define_peephole2 and
check there using peep2_regno_dead_p if FLAGS_REG is dead.
* gcc.dg/pr99104.c: New test.
GCC Administrator [Thu, 18 Feb 2021 00:16:29 +0000 (00:16 +0000)]
Daily bump.
David Malcolm [Wed, 17 Feb 2021 22:50:52 +0000 (17:50 -0500)]
testsuite: add regression test for PR analyzer/94596
This use-after-free false positive affected GCC 10, but seems to be
fixed in trunk for GCC 11; adding a reduced version as a regression
test.
gcc/testsuite/ChangeLog:
PR analyzer/94596
* gcc.dg/analyzer/pr94596.c: New test.
Nathan Sidwell [Wed, 17 Feb 2021 18:43:21 +0000 (10:43 -0800)]
c++: Macros need to be GTY-reachable [PR 99023]
I'd missed that macros were allocated from GC storage, and that they can
become unattached from an identifier, and therefore not GC-reachable.
And then bad things happen. Fixed by making the module machinery's
reference vector a GC root.
PR c++/99023
gcc/cp/
* module.cc (struct macro_export): Add GTY markers.
(macro_exports): Likewise, us a va_gc Vector.
gcc/testsuite/
* g++.dg/modules/pr99023_a.H: New.
* g++.dg/modules/pr99023_b.H: New.
David Malcolm [Wed, 17 Feb 2021 15:37:16 +0000 (10:37 -0500)]
analyzer: fix false leak involving params [PR98969]
This patch updates the svalue liveness code so that the initial value
of parameters at top-level functions to the analysis are treated as
live (since the values are presumably still live within the
outside-of-the-analysis calling code).
This fixes the false leak in PR analyzer/98969 seen on:
void
test (long int i)
{
struct foo *f = (struct foo *)i;
f->expr = __builtin_malloc (1024);
}
since the calling code can presumably still access the allocated
buffer via:
((struct foo *)i)->expr
The patch also removes the expected leak warnings from
g++.dg/analyzer/pr99064.C and gcc.dg/analyzer/pr96841.c, which now
appear to me to be false positives.
gcc/analyzer/ChangeLog:
PR analyzer/98969
* constraint-manager.cc (dead_svalue_purger::should_purge_p):
Update for change to svalue::live_p.
* program-state.cc (sm_state_map::on_liveness_change): Likewise.
(program_state::detect_leaks): Likewise.
* region-model-reachability.cc (reachable_regions::init_cluster):
When dealing with a symbolic region, if the underlying pointer is
implicitly live, add the region to the reachable regions.
* region-model.cc (region_model::compare_initial_and_pointer):
Move logic for detecting initial values of params to
initial_svalue::initial_value_of_param_p.
* svalue.cc (svalue::live_p): Convert "live_svalues" from a
reference to a pointer; support it being NULL.
(svalue::implicitly_live_p): Convert first param from a
refererence to a pointer.
(region_svalue::implicitly_live_p): Likewise.
(constant_svalue::implicitly_live_p): Likewise.
(initial_svalue::implicitly_live_p): Likewise. Treat the initial
values of params for the top level frame as still live.
(initial_svalue::initial_value_of_param_p): New function, taken
from a test in region_model::compare_initial_and_pointer.
(unaryop_svalue::implicitly_live_p): Convert first param from a
refererence to a pointer.
(binop_svalue::implicitly_live_p): Likewise.
(sub_svalue::implicitly_live_p): Likewise.
(unmergeable_svalue::implicitly_live_p): Likewise.
* svalue.h (svalue::live_p): Likewise.
(svalue::implicitly_live_p): Likewise.
(region_svalue::implicitly_live_p): Likewise.
(constant_svalue::implicitly_live_p): Likewise.
(initial_svalue::implicitly_live_p): Likewise.
(initial_svalue::initial_value_of_param_p): New decl.
(unaryop_svalue::implicitly_live_p): Convert first param from a
refererence to a pointer.
(binop_svalue::implicitly_live_p): Likewise.
(sub_svalue::implicitly_live_p): Likewise.
(unmergeable_svalue::implicitly_live_p): Likewise.
gcc/testsuite/ChangeLog:
PR analyzer/98969
* g++.dg/analyzer/pr99064.C: Convert dg-bogus to dg-warning.
* gcc.dg/analyzer/pr96841.c: Add -Wno-analyzer-too-complex to
options. Remove false leak directive.
* gcc.dg/analyzer/pr98969.c (test_1): Remove xfail from leak
false positive.
(test_3): New.
Julian Brown [Wed, 10 Feb 2021 19:18:13 +0000 (11:18 -0800)]
openacc: Strided array sections and components of derived-type arrays
This patch disallows selecting components of array sections in update
directives for OpenACC, as specified in OpenACC 3.0, "2.14.4. Update
Directive":
In Fortran, members of variables of derived type may appear, including
a subarray of a member. Members of subarrays of derived type may
not appear.
The diagnostic for attempting to use the same construct on other
directives has also been improved.
gcc/fortran/
* openmp.c (resolve_omp_clauses): Disallow selecting components
of arrays of derived type.
gcc/testsuite/
* gfortran.dg/goacc/array-with-dt-2.f90: Remove expected errors.
* gfortran.dg/goacc/array-with-dt-6.f90: New test.
* gfortran.dg/goacc/mapping-tests-2.f90: Update expected error.
* gfortran.dg/goacc/ref_inquiry.f90: Update expected errors.
* gfortran.dg/gomp/ref_inquiry.f90: Likewise.
libgomp/
* testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90: Remove
expected errors.
Julian Brown [Thu, 21 Jan 2021 14:54:54 +0000 (06:54 -0800)]
openacc: Fix lowering for derived-type mappings through array elements
This patch fixes lowering of derived-type mappings which select elements
of arrays of derived types, and similar. These would previously lead
to ICEs.
With this change, OpenACC directives can pass through constructs that
are no longer recognized by the gimplifier, hence alterations are needed
there also.
gcc/fortran/
* trans-openmp.c (gfc_trans_omp_clauses): Handle element selection
for arrays of derived types.
gcc/
* gimplify.c (gimplify_scan_omp_clauses): Handle ATTACH_DETACH
for non-decls.
gcc/testsuite/
* gfortran.dg/goacc/array-with-dt-1.f90: New test.
* gfortran.dg/goacc/array-with-dt-3.f90: Likewise.
* gfortran.dg/goacc/array-with-dt-4.f90: Likewise.
* gfortran.dg/goacc/array-with-dt-5.f90: Likewise.
* gfortran.dg/goacc/derived-chartypes-1.f90: Re-enable test.
* gfortran.dg/goacc/derived-chartypes-2.f90: Likewise.
* gfortran.dg/goacc/derived-classtypes-1.f95: Uncomment
previously-broken directives.
libgomp/
* testsuite/libgomp.oacc-fortran/derivedtypes-arrays-1.f90: New test.
* testsuite/libgomp.oacc-fortran/update-dt-array.f90: Likewise.
Jakub Jelinek [Wed, 17 Feb 2021 14:03:25 +0000 (15:03 +0100)]
c++: Fix up build_zero_init_1 once more [PR99106]
My earlier build_zero_init_1 patch for flexible array members created
an empty CONSTRUCTOR. As the following testcase shows, that doesn't work
very well because the middle-end doesn't expect CONSTRUCTOR elements with
incomplete type (that the empty CONSTRUCTOR at the end of outer CONSTRUCTOR
had).
The following patch just doesn't add any CONSTRUCTOR for the flexible array
members, it doesn't seem to be needed.
2021-02-17 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/99106
* init.c (build_zero_init_1): For flexible array members just return
NULL_TREE instead of returning empty CONSTRUCTOR with non-complete
ARRAY_TYPE.
* g++.dg/ubsan/pr99106.C: New test.
Nathan Sidwell [Wed, 17 Feb 2021 13:33:45 +0000 (05:33 -0800)]
c++: More set_identifier_type_value fixing [PR 99116]
My recent change looked under template_parms in two places, but that
was covering up a separate problem. We were attempting to set the
identifier_type_value of a template_parm into the template_parm
scope. The peeking stopped us doing that, but confused poplevel,
leaving an identifier value lying around. This fixes the underlying
problem in do_pushtag -- we only need to set the identifier_type_value
directly when we're in a template_parm scope (a later pushdecl will
push the actual template_decl). for non-class non-template-parm
bindings do_pushdecl already ends up manipulating
identifier_type_value correctly.
PR c++/99116
gcc/cp/
* name-lookup.c (do_pushdecl): Don't peek under template_parm
bindings here ...
(set_identifier_type_value_with_scope): ... or here.
(do_pushtag): Only set_identifier_type_value_with_scope at
non-class template parm scope, and use parent scope.
gcc/testsuite/
* g++.dg/lookup/pr99116-1.C: New.
* g++.dg/lookup/pr99116-2.C: New.
Nathan Sidwell [Wed, 17 Feb 2021 13:28:09 +0000 (05:28 -0800)]
c++: ICE with header-units [PR 99071]
This ICE was caused by dereferencing the wrong pointer and not finding the
expected thing there. Pointers are like that.
PR c++/99071
gcc/cp/
* name-lookup.c (maybe_record_mergeable_decl): Deref the correct
pointer.
gcc/testsuite/
* g++.dg/modules/pr99071_a.H: New.
* g++.dg/modules/pr99071_b.H: New.
Xi Ruoyao [Wed, 17 Feb 2021 11:57:13 +0000 (11:57 +0000)]
mips: Avoid out-of-bounds access in mips_symbol_insns [PR98491]
An invalid use of MSA_SUPPORTED_MODE_P was causing an ICE on
mips64el with -mmsa. The detailed analysis is posted on bugzilla.
gcc/ChangeLog:
2021-02-17 Xi Ruoyao <xry111@mengyan1223.wang>
PR target/98491
* config/mips/mips.c (mips_symbol_insns): Do not use
MSA_SUPPORTED_MODE_P if mode is MAX_MACHINE_MODE.
Patrick Palka [Wed, 17 Feb 2021 01:49:12 +0000 (20:49 -0500)]
c++: Revert EXPR_LOCATION change to build_aggr_init_expr [PR96997]
My change in r10-7718 to make build_aggr_init_expr set EXPR_LOCATION
(mimicking build_target_expr) causes the debuginfo regression PR96997.
Given that this change is mostly independent of the rest of the commit,
and that the only fallout of reverting it is a less accurate error
message location in a testcase introduced in the same commit, it seems
the best way forward is to just revert this part of the commit.
gcc/cp/ChangeLog:
PR debug/96997
PR c++/94034
* tree.c (build_aggr_init_expr): Revert r10-7718 change.
gcc/testsuite/ChangeLog:
PR debug/96997
PR c++/94034
* g++.dg/cpp1y/constexpr-nsdmi7b.C: Adjust expected location of
"call to non-'constexpr' function" error message.
GCC Administrator [Wed, 17 Feb 2021 00:16:20 +0000 (00:16 +0000)]
Daily bump.
Ian Lance Taylor [Mon, 15 Feb 2021 02:59:07 +0000 (18:59 -0800)]
compiler: unalias receiver type in export data
Test case is https://golang.org/cl/292009.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/291991
Nathan Sidwell [Tue, 16 Feb 2021 20:23:12 +0000 (12:23 -0800)]
c++: directives-only preprocessing and include translation [PR 99050]
We make sure files end in \n by placing one at the limit of the buffer
(just past the end of what is read). We need to do the same for
buffers generated via include-translation. Fortunately they have
space.
libcpp/
* files.c (_cpp_stack_file): Make buffers end in unread \n.
gcc/testsuite/
* g++.dg/modules/pr99050_a.H: New.
* g++.dg/modules/pr99050_b.C: New.
Marek Polacek [Wed, 10 Feb 2021 20:24:25 +0000 (15:24 -0500)]
c-family: ICE with assume_aligned attribute [PR99062]
We ICE in handle_assume_aligned_attribute since r271338 which added
@@ -2935,8 +2936,8 @@ handle_assume_aligned_attribute (tree *node, tree name, tree args, int,
/* The misalignment specified by the second argument
must be non-negative and less than the alignment. */
warning (OPT_Wattributes,
- "%qE attribute argument %E is not in the range [0, %E)",
- name, val, align);
+ "%qE attribute argument %E is not in the range [0, %wu]",
+ name, val, tree_to_uhwi (align) - 1);
*no_add_attrs = true;
return NULL_TREE;
}
because align is INT_MIN and tree_to_uhwi asserts tree_fits_uhwi_p -- which
ALIGN does not and the prior tree_fits_shwi_p check is fine with it, as
well as the integer_pow2p check.
Since neither of the arguments to assume_aligned can be negative, I've
hoisted the tree_int_cst_sgn check. And add the missing "argument"
word to an existing warning.
gcc/c-family/ChangeLog:
PR c++/99062
* c-attribs.c (handle_assume_aligned_attribute): Check that the
alignment argument is non-negative. Tweak a warning message.
gcc/testsuite/ChangeLog:
PR c++/99062
* gcc.dg/attr-assume_aligned-4.c: Adjust dg-warning.
* g++.dg/ext/attr-assume-aligned.C: New test.