Jonathan Wakely [Thu, 17 Mar 2022 14:36:07 +0000 (14:36 +0000)]
libstdc++: Avoid including <algorithm> in <filesystem> [PR92546]
This only affects Windows, but reduces the preprocessed size of
<filesystem> significantly.
libstdc++-v3/ChangeLog:
PR libstdc++/92546
* include/bits/fs_path.h (path::make_preferred): Use
handwritten loop instead of std::replace.
Jonathan Wakely [Thu, 17 Mar 2022 13:33:07 +0000 (13:33 +0000)]
libstdc++: Rewrite __moneypunct_cache::_M_cache [PR104966]
GCC thinks the following can lead to a buffer overflow when __ns.size()
equals zero:
const basic_string<_CharT>& __ns = __mp.negative_sign();
_M_negative_sign_size = __ns.size();
__negative_sign = new _CharT[_M_negative_sign_size];
__ns.copy(__negative_sign, _M_negative_sign_size);
This happens because operator new might be replaced with something that
writes to this->_M_negative_sign_size and so the basic_string::copy call
could use a non-zero size to write to a zero-length buffer.
The solution suggested by Richi is to cache the size in a local variable
so that the compiler knows it won't be changed between the allocation
and the copy.
This commit goes further and rewrites the whole function to use RAII and
delay all modifications of *this until after all allocations have
succeeded. The RAII helper type caches the size and copies the string
and owns the memory until told to release it.
libstdc++-v3/ChangeLog:
PR middle-end/104966
* include/bits/locale_facets_nonio.tcc
(__moneypunct_cache::_M_cache): Replace try-catch with RAII and
make all string copies before any stores to *this.
Jakub Jelinek [Thu, 17 Mar 2022 17:49:00 +0000 (18:49 +0100)]
libatomic: Improve 16-byte atomics on Intel AVX [PR104688]
As mentioned in the PR, the latest Intel SDM has added:
"Processors that enumerate support for Intel® AVX (by setting the feature flag CPUID.01H:ECX.AVX[bit 28])
guarantee that the 16-byte memory operations performed by the following instructions will always be
carried out atomically:
• MOVAPD, MOVAPS, and MOVDQA.
• VMOVAPD, VMOVAPS, and VMOVDQA when encoded with VEX.128.
• VMOVAPD, VMOVAPS, VMOVDQA32, and VMOVDQA64 when encoded with EVEX.128 and k0 (masking disabled).
(Note that these instructions require the linear addresses of their memory operands to be 16-byte
aligned.)"
The following patch deals with it just on the libatomic library side so far,
currently (since ~ 2017) we emit all the __atomic_* 16-byte builtins as
library calls since and this is something that we can hopefully backport.
The patch simply introduces yet another ifunc variant that takes priority
over the pure CMPXCHG16B one, one that checks AVX and CMPXCHG16B bits and
on non-Intel clears the AVX bit during detection for now (if AMD comes
with the same guarantee, we could revert the config/x86/init.c hunk),
which implements 16-byte atomic load as vmovdqa and 16-byte atomic store
as vmovdqa followed by mfence.
2022-03-17 Jakub Jelinek <jakub@redhat.com>
PR target/104688
* Makefile.am (IFUNC_OPTIONS): Change on x86_64 to -mcx16 -mcx16.
(libatomic_la_LIBADD): Add $(addsuffix _16_2_.lo,$(SIZEOBJS)) for
x86_64.
* Makefile.in: Regenerated.
* config/x86/host-config.h (IFUNC_COND_1): For x86_64 define to
both AVX and CMPXCHG16B bits.
(IFUNC_COND_2): Define.
(IFUNC_NCOND): For x86_64 define to 2 * (N == 16).
(MAYBE_HAVE_ATOMIC_CAS_16, MAYBE_HAVE_ATOMIC_EXCHANGE_16,
MAYBE_HAVE_ATOMIC_LDST_16): Define to IFUNC_COND_2 rather than
IFUNC_COND_1.
(HAVE_ATOMIC_CAS_16): Redefine to 1 whenever IFUNC_ALT != 0.
(HAVE_ATOMIC_LDST_16): Redefine to 1 whenever IFUNC_ALT == 1.
(atomic_compare_exchange_n): Define whenever IFUNC_ALT != 0
on x86_64 for N == 16.
(__atomic_load_n, __atomic_store_n): Redefine whenever IFUNC_ALT == 1
on x86_64 for N == 16.
(atomic_load_n, atomic_store_n): New functions.
* config/x86/init.c (__libat_feat1_init): On x86_64 clear bit_AVX
if CPU vendor is not Intel.
Jonathan Wakely [Thu, 17 Mar 2022 12:23:02 +0000 (12:23 +0000)]
libstdc++: Fix comment in testsuite utility
libstdc++-v3/ChangeLog:
* testsuite/util/testsuite_character.h: Fix comment.
Richard Biener [Thu, 17 Mar 2022 07:10:59 +0000 (08:10 +0100)]
tree-optimization/104960 - unsplit edges after late sinking
Something went wrong when testing the earlier patch to move the
late sinking to before the late phiopt for PR102008. The following
makes sure to unsplit edges after the late sinking since the split
edges confuse the following phiopt leading to missed optimizations.
I've went for a new pass parameter for this to avoid changing the
CFG after the early sinking pass at this point.
2022-03-17 Richard Biener <rguenther@suse.de>
PR tree-optimization/104960
* passes.def: Add pass parameter to pass_sink_code, mark
last one to unsplit edges.
* tree-ssa-sink.cc (pass_sink_code::set_pass_param): New.
(pass_sink_code::execute): Always execute TODO_cleanup_cfg
when we need to unsplit edges.
* gcc.dg/gimplefe-37.c: Adjust to allow either the true
or false edge to have a forwarder.
Jakub Jelinek [Thu, 17 Mar 2022 08:23:45 +0000 (09:23 +0100)]
gimplify: Emit clobbers for TARGET_EXPR_SLOT vars later [PR103984]
As mentioned in the PR, we emit a bogus uninitialized warning but
easily could emit wrong-code for it or similar testcases too.
The bug is that we emit clobber for a TARGET_EXPR_SLOT too early:
D.2499.e = B::qux (&h); [return slot optimization]
D.2516 = 1;
try
{
B::B (&D.2498, &h);
try
{
_2 = baz (&D.2498);
D.2499.f = _2;
D.2516 = 0;
try
{
try
{
bar (&D.2499);
}
finally
{
C::~C (&D.2499);
}
}
finally
{
D.2499 = {CLOBBER(eol)};
}
}
finally
{
D.2498 = {CLOBBER(eol)};
}
}
catch
{
if (D.2516 != 0) goto <D.2517>; else goto <D.2518>;
<D.2517>:
A::~A (&D.2499.e);
goto <D.2519>;
<D.2518>:
<D.2519>:
}
The CLOBBER for D.2499 is essentially only emitted on the non-exceptional
path, if B::B or baz throws, then there is no CLOBBER for it but there
is a conditional destructor A::~A (&D.2499.e). Now, ehcleanup1
sink_clobbers optimization assumes that clobbers in the EH cases are
emitted after last use and so sinks the D.2499 = {CLOBBER(eol)}; later,
so we then have
# _3 = PHI <1(3), 0(9)>
<L2>:
D.2499 ={v} {CLOBBER(eol)};
D.2498 ={v} {CLOBBER(eol)};
if (_3 != 0)
goto <bb 11>; [INV]
else
goto <bb 15>; [INV]
<bb 11> :
_35 = D.2499.a;
if (&D.2499.b != _35)
where that _35 = D.2499.a comes from inline expansion of the A::~A dtor,
and that is a load from a clobbered memory.
Now, what the gimplifier sees in this case is a CLEANUP_POINT_EXPR with
somewhere inside of it a TARGET_EXPR for D.2499 (with the C::~C (&D.2499)
cleanup) which in its TARGET_EXPR_INITIAL has another TARGET_EXPR for
D.2516 bool flag which has CLEANUP_EH_ONLY which performs that conditional
A::~A (&D.2499.e) call.
The following patch ensures that CLOBBERs (and asan poisoning) are emitted
after even those gimple_push_cleanup pushed cleanups from within the
TARGET_EXPR_INITIAL gimplification (i.e. the last point where the slot could
be in theory used). In my first version of the patch I've done it by just
moving the
/* Add a clobber for the temporary going out of scope, like
gimplify_bind_expr. */
if (gimplify_ctxp->in_cleanup_point_expr
&& needs_to_live_in_memory (temp))
{
...
}
block earlier in gimplify_target_expr, but that regressed a couple of tests
where temp is marked TREE_ADDRESSABLE only during (well, very early during
that) the gimplification of TARGET_EXPR_INITIAL, so we didn't emit e.g. on
pr80032.C or stack2.C tests any clobbers for the slots and thus stack slot
reuse wasn't performed.
So that we don't regress those tests, this patch gimplifies
TARGET_EXPR_INITIAL as before, but doesn't emit it directly into pre_p,
emits it into a temporary sequence. Then emits the CLOBBER cleanup
into pre_p, then asan poisoning if needed, then appends the
TARGET_EXPR_INITIAL temporary sequence and finally adds TARGET_EXPR_CLEANUP
gimple_push_cleanup. The earlier a GIMPLE_WCE appears in the sequence, the
outer try/finally or try/catch it is.
So, with this patch the part of the testcase in gimple dump cited above
looks instead like:
try
{
D.2499.e = B::qux (&h); [return slot optimization]
D.2516 = 1;
try
{
try
{
B::B (&D.2498, &h);
_2 = baz (&D.2498);
D.2499.f = _2;
D.2516 = 0;
try
{
bar (&D.2499);
}
finally
{
C::~C (&D.2499);
}
}
finally
{
D.2498 = {CLOBBER(eol)};
}
}
catch
{
if (D.2516 != 0) goto <D.2517>; else goto <D.2518>;
<D.2517>:
A::~A (&D.2499.e);
goto <D.2519>;
<D.2518>:
<D.2519>:
}
}
finally
{
D.2499 = {CLOBBER(eol)};
}
2022-03-17 Jakub Jelinek <jakub@redhat.com>
PR middle-end/103984
* gimplify.cc (gimplify_target_expr): Gimplify type sizes and
TARGET_EXPR_INITIAL into a temporary sequence, then push clobbers
and asan unpoisioning, then append the temporary sequence and
finally the TARGET_EXPR_CLEANUP clobbers.
* g++.dg/opt/pr103984.C: New test.
Thomas Schwinge [Wed, 16 Mar 2022 13:19:41 +0000 (14:19 +0100)]
Enhance further testcases to verify Openacc 'kernels' decomposition
gcc/testsuite/
* c-c++-common/goacc-gomp/nesting-1.c: Enhance.
* c-c++-common/goacc/kernels-loop-g.c: Likewise.
* c-c++-common/goacc/nesting-1.c: Likewise.
* gcc.dg/goacc/nested-function-1.c: Likewise.
* gfortran.dg/goacc/common-block-3.f90: Likewise.
* gfortran.dg/goacc/nested-function-1.f90: Likewise.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/acc_prof-kernels-1.c:
Enhance.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-g.c: Likewise.
* testsuite/libgomp.oacc-fortran/if-1.f90: Likewise.
Thomas Schwinge [Wed, 16 Mar 2022 11:15:01 +0000 (12:15 +0100)]
Enhance further testcases to verify handling of OpenACC privatization level [PR90115]
As originally introduced in commit
11b8286a83289f5b54e813f14ff56d730c3f3185
"[OpenACC privatization] Largely extend diagnostics and corresponding testsuite
coverage [PR90115]".
PR middle-end/90115
gcc/testsuite/
* c-c++-common/goacc-gomp/nesting-1.c: Enhance.
* gfortran.dg/goacc/common-block-3.f90: Likewise.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/acc_prof-kernels-1.c: Enhance.
* testsuite/libgomp.oacc-fortran/if-1.f90: Likewise.
GCC Administrator [Thu, 17 Mar 2022 00:17:00 +0000 (00:17 +0000)]
Daily bump.
Roger Sayle [Wed, 16 Mar 2022 23:28:21 +0000 (23:28 +0000)]
Fix strange binary corruption with last commit.
2022-03-16 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* config/i386/sse.md: Delete corrupt character/typo.
Roger Sayle [Wed, 16 Mar 2022 23:20:34 +0000 (23:20 +0000)]
PR c/98198: ICE-on-invalid-code error recovery.
This is Christophe Lyon's fix to PR c/98198, an ICE-on-invalid-code
regression affecting mainline, and a suitable testcase.
Tested on x86_64-pc-linux-gnu with make bootstrap and make -k check
with no new failures. Ok for mainline?
2022-03-16 Christophe Lyon <christophe.lyon@arm.com>
Roger Sayle <roger@nextmovesoftware.com>
gcc/c-family/ChangeLog
PR c/98198
* c-attribs.cc (decl_or_type_attrs): Add error_mark_node check.
gcc/testsuite/ChangeLog
PR c/98198
* gcc.dg/pr98198.c: New test case.
Roger Sayle [Wed, 16 Mar 2022 23:15:20 +0000 (23:15 +0000)]
PR target/94680: Clear upper bits of V2DF using movq (like V2DI).
This simple i386 patch unblocks a more significant change. The testcase
gcc.target/i386/sse2-pr94680.c isn't quite testing what's intended, and
alas the fix for PR target/94680 doesn't (yet) handle V2DF mode.
For the first test from sse2-pr94680.c, below
v2df foo_v2df (v2df x) {
return __builtin_shuffle (x, (v2df) { 0, 0 }, (v2di) { 0, 2 });
}
GCC on x86_64-pc-linux-gnu with -O2 currently generates:
movhpd .LC0(%rip), %xmm0
ret
.LC0:
.long 0
.long 0
which passes the test as it contains a mov insn and no xor.
Alas reading a zero from the constant pool isn't quite the
desired implementation. With this patch we now generate:
movq %xmm0, %xmm0
ret
The same code as we generate for V2DI, and add a stricter
test case. This implementation generalizes the sse2_movq128
to V2DI and V2DF modes using a VI8F_128 mode iterator and
renames it *sse2_movq128_<mode>. A new define_expand is
introduced for sse2_movq128 so that the exisiting builtin
interface (CODE_FOR_sse2_movq128) remains the same.
2022-03-16 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR target/94680
* config/i386/sse.md (sse2_movq128): New define_expand to
preserve previous named instruction.
(*sse2_movq128_<mode>): Renamed from sse2_movq128, and
generalized to VI8F_128 (both V2DI and V2DF).
gcc/testsuite/ChangeLog
PR target/94680
* gcc.target/i386/sse2-pr94680-2.c: New stricter V2DF test case.
Jonathan Wakely [Wed, 16 Mar 2022 20:35:47 +0000 (20:35 +0000)]
libstdc++: Fix symbol versioning for Solaris 11.3 [PR103407]
The new std::from_chars implementation means that those symbols are now
defined on Solaris 11.3, which lacks uselocale. They were not present in
gcc-11, but the linker script gives them the GLIBCXX_3.4.29 symbol
version because that is the version where they appeared for systems with
uselocale.
This makes the version for those symbols depend on whether uselocale is
available or not, so that they get version GLIBCXX_3.4.30 on targets
where they weren't defined in gcc-11.
In order to avoid needing separate ABI baseline files for Solaris 11.3
and 11.4, the ABI checker program now treats the floating-point
std::from_chars overloads as undesignated if they are not found in the
baseline symbols file. This means they can be left out of the SOlaris
baseline without causing the check-abi target to fail.
libstdc++-v3/ChangeLog:
PR libstdc++/103407
* config/abi/pre/gnu.ver: Make version for std::from_chars
depend on HAVE_USELOCALE macro.
* testsuite/util/testsuite_abi.cc (compare_symbols): Treat
std::from_chars for floating-point types as undesignated if
not found in the baseline symbols file.
Ian Lance Taylor [Wed, 16 Mar 2022 17:31:57 +0000 (10:31 -0700)]
libgo: update to final Go 1.18 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/393377
David Malcolm [Wed, 16 Mar 2022 14:54:44 +0000 (10:54 -0400)]
analyzer: early rejection of disabled warnings [PR104955]
Avoid generating execution paths for warnings that are ultimately
rejected due to -Wno-analyzer-* flags.
This improves the test case from taking at least several minutes
(before I killed it) to taking under a second.
This doesn't fix the slowdown seen in PR analyzer/104955 with large
numbers of warnings when the warnings are still enabled.
gcc/analyzer/ChangeLog:
PR analyzer/104955
* diagnostic-manager.cc (get_emission_location): New.
(diagnostic_manager::diagnostic_manager): Initialize
m_num_disabled_diagnostics.
(diagnostic_manager::add_diagnostic): Reject diagnostics that
will eventually be rejected due to being disabled.
(diagnostic_manager::emit_saved_diagnostics): Log the number
of disabled diagnostics.
(diagnostic_manager::emit_saved_diagnostic): Split out logic for
determining emission location to get_emission_location.
* diagnostic-manager.h
(diagnostic_manager::m_num_disabled_diagnostics): New field.
* engine.cc (stale_jmp_buf::get_controlling_option): New.
(stale_jmp_buf::emit): Use it.
* pending-diagnostic.h
(pending_diagnostic::get_controlling_option): New vfunc.
* region-model.cc
(poisoned_value_diagnostic::get_controlling_option): New.
(poisoned_value_diagnostic::emit): Use it.
(shift_count_negative_diagnostic::get_controlling_option): New.
(shift_count_negative_diagnostic::emit): Use it.
(shift_count_overflow_diagnostic::get_controlling_option): New.
(shift_count_overflow_diagnostic::emit): Use it.
(dump_path_diagnostic::get_controlling_option): New.
(dump_path_diagnostic::emit): Use it.
(write_to_const_diagnostic::get_controlling_option): New.
(write_to_const_diagnostic::emit): Use it.
(write_to_string_literal_diagnostic::get_controlling_option): New.
(write_to_string_literal_diagnostic::emit): Use it.
* sm-file.cc (double_fclose::get_controlling_option): New.
(double_fclose::emit): Use it.
(file_leak::get_controlling_option): New.
(file_leak::emit): Use it.
* sm-malloc.cc (mismatching_deallocation::get_controlling_option):
New.
(mismatching_deallocation::emit): Use it.
(double_free::get_controlling_option): New.
(double_free::emit): Use it.
(possible_null_deref::get_controlling_option): New.
(possible_null_deref::emit): Use it.
(possible_null_arg::get_controlling_option): New.
(possible_null_arg::emit): Use it.
(null_deref::get_controlling_option): New.
(null_deref::emit): Use it.
(null_arg::get_controlling_option): New.
(null_arg::emit): Use it.
(use_after_free::get_controlling_option): New.
(use_after_free::emit): Use it.
(malloc_leak::get_controlling_option): New.
(malloc_leak::emit): Use it.
(free_of_non_heap::get_controlling_option): New.
(free_of_non_heap::emit): Use it.
* sm-pattern-test.cc (pattern_match::get_controlling_option): New.
(pattern_match::emit): Use it.
* sm-sensitive.cc
(exposure_through_output_file::get_controlling_option): New.
(exposure_through_output_file::emit): Use it.
* sm-signal.cc (signal_unsafe_call::get_controlling_option): New.
(signal_unsafe_call::emit): Use it.
* sm-taint.cc (tainted_array_index::get_controlling_option): New.
(tainted_array_index::emit): Use it.
(tainted_offset::get_controlling_option): New.
(tainted_offset::emit): Use it.
(tainted_size::get_controlling_option): New.
(tainted_size::emit): Use it.
(tainted_divisor::get_controlling_option): New.
(tainted_divisor::emit): Use it.
(tainted_allocation_size::get_controlling_option): New.
(tainted_allocation_size::emit): Use it.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/many-disabled-diagnostics.c: New test.
* gcc.dg/plugin/analyzer_gil_plugin.c
(gil_diagnostic::get_controlling_option): New.
(double_save_thread::emit): Use it.
(fncall_without_gil::emit): Likewise.
(pyobject_usage_without_gil::emit): Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Jonathan Wakely [Fri, 11 Mar 2022 14:36:18 +0000 (14:36 +0000)]
libstdc++: Ensure that std::from_chars is declared when supported
This adjusts the declarations in <charconv> to match when the definition
is present. This solves the issue that std::from_chars is present on
Solaris 11.3 (using fast_float) but was not declared in the header
(because the declarations were guarded by _GLIBCXX_HAVE_USELOCALE).
Additionally, do not define __cpp_lib_to_chars unless both from_chars
and to_chars are supported (which is only true for IEEE float and
double). We might still provide from_chars (via strtold) but if to_chars
isn't provided, we shouldn't define the feature test macro.
Finally, this simplifies some of the preprocessor checks in the bodies
of std::from_chars in src/c++17/floating_from_chars.cc and hoists the
repeated code for the strtod version into a new function template.
N.B. the long double overload of std::from_chars will always be defined
if the float and double overloads are defined. We can always use one of
strtold or fast_float's binary64 routines (although the latter might
produce errors for some long double values if they are not representable
as binary64).
libstdc++-v3/ChangeLog:
* include/std/charconv (__cpp_lib_to_chars): Only define when
both from_chars and to_chars are supported for floating-point
types.
(from_chars, to_chars): Adjust preprocessor conditions guarding
declarations.
* include/std/version (__cpp_lib_to_chars): Adjust condition to
match <charconv> definition.
* src/c++17/floating_from_chars.cc (from_chars_strtod): New
function template.
(from_chars): Simplify preprocessor checks and use
from_chars_strtod when appropriate.
Siddhesh Poyarekar [Wed, 16 Mar 2022 15:15:47 +0000 (20:45 +0530)]
tree-optimization/104941: Actually assign the conversion result
Assign the result of fold_convert to offset. Also make the useless
conversion check lighter since the two way check is not needed here.
gcc/ChangeLog:
PR tree-optimization/104941
* tree-object-size.cc (size_for_offset): Make useless conversion
check lighter and assign result of fold_convert to OFFSET.
gcc/testsuite/ChangeLog:
PR tree-optimization/104941
* gcc.dg/builtin-dynamic-object-size-0.c (S1, S2): New structs.
(test_alloc_nested_structs, g): New functions.
(main): Call test_alloc_nested_structs.
Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
Marcel Vollweiler [Wed, 16 Mar 2022 14:38:54 +0000 (07:38 -0700)]
OpenMP, Fortran: Bugfix for omp_set_num_teams.
This patch fixes a small bug in the omp_set_num_teams implementation.
libgomp/ChangeLog:
* fortran.c (omp_set_num_teams_8_): Call omp_set_num_teams instead of
omp_set_max_active_levels.
* testsuite/libgomp.fortran/icv-8.f90: New test.
H.J. Lu [Sun, 13 Mar 2022 15:57:51 +0000 (08:57 -0700)]
x86: Also check _SOFT_FLOAT in <x86gprintrin.h>
Push target("general-regs-only") in <x86gprintrin.h> if x87 is enabled.
gcc/
PR target/104890
* config/i386/x86gprintrin.h: Also check _SOFT_FLOAT before
pushing target("general-regs-only").
gcc/testsuite/
PR target/104890
* gcc.target/i386/pr104890.c: New test.
Kito Cheng [Tue, 15 Mar 2022 01:04:03 +0000 (09:04 +0800)]
RISC-V: Add version info for zk, zkn and zks
We just expand `zk`, `zkn` and `zks` before, but need version for
combine them back.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_version_table):
Add version info for zk, zks and zkn.
LiaoShihua [Tue, 8 Mar 2022 03:30:51 +0000 (11:30 +0800)]
RISC-V: Handle combine extension in canonical ordering.
The crypto extension have several shorthand extensions that don't consist of any extra instructions.
Take zk for example, while the extension would imply zkn, zkr, zkt.
The 3 extensions should also combine back into zk to maintain the canonical order in isa strings.
This patch addresses the above.
And if the other extension has the same situation, you can add them in riscv_combine_info[]
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc
(riscv_combine_info): New.
(riscv_subset_list::handle_combine_ext): Combine back into zk to
maintain the canonical order in isa strings.
(riscv_subset_list::parse): Ditto.
* config/riscv/riscv-subset.h (handle_combine_ext): New.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/predef-17.c: New test.
Richard Biener [Wed, 16 Mar 2022 12:39:31 +0000 (13:39 +0100)]
tree-optimization/102008 - restore if-conversion of adjacent loads
The following re-orders the newly added code sinking pass before
the last phiopt pass which performs hoisting of adjacent loads
with the intent to enable if-conversion on those.
I've added the aarch64 specific testcase from the PR.
2022-03-16 Richard Biener <rguenther@suse.de>
PR tree-optimization/102008
* passes.def: Move the added code sinking pass before the
preceeding phiopt pass.
* gcc.target/aarch64/pr102008.c: New testcase.
Patrick Palka [Wed, 16 Mar 2022 12:26:11 +0000 (08:26 -0400)]
c++: further lookup_member simplification
As a minor followup to r12-7656-gffe9c0a0d3564a, this condenses the
handling of ambiguity and access w.r.t. the value of 'protect' so that
the logic is more clear.
gcc/cp/ChangeLog:
* search.cc (lookup_member): Simplify by handling all values
of protect together in the ambiguous case. Don't modify protect.
Patrick Palka [Wed, 16 Mar 2022 12:25:54 +0000 (08:25 -0400)]
c++: fold calls to std::move/forward [PR96780]
A well-formed call to std::move/forward is equivalent to a cast, but the
former being a function call means the compiler generates debug info,
which persists even after the call gets inlined, for an operation that's
never interesting to debug.
This patch addresses this problem by folding calls to std::move/forward
and other cast-like functions into simple casts as part of the frontend's
general expression folding routine. This behavior is controlled by a
new flag -ffold-simple-inlines, and otherwise by -fno-inline, so that
users can enable this folding with -O0 (which implies -fno-inline).
After this patch with -O2 and a non-checking compiler, debug info size
for some testcases from range-v3 and cmcstl2 decreases by as much as ~10%
and overall compile time and memory usage decreases by ~2%.
PR c++/96780
gcc/ChangeLog:
* doc/invoke.texi (C++ Dialect Options): Document
-ffold-simple-inlines.
gcc/c-family/ChangeLog:
* c.opt: Add -ffold-simple-inlines.
gcc/cp/ChangeLog:
* cp-gimplify.cc (cp_fold) <case CALL_EXPR>: Fold calls to
std::move/forward and other cast-like functions into simple
casts.
gcc/testsuite/ChangeLog:
* g++.dg/opt/pr96780.C: New test.
Siddhesh Poyarekar [Wed, 16 Mar 2022 10:40:51 +0000 (16:10 +0530)]
tree-optimization/104942: Retain sizetype conversions till the end
Retain the sizetype alloc_object_size to guarantee the assertion in
size_for_offset and to avoid adding a conversion there. nop conversions
are eliminated at the end anyway in dynamic object size computation.
gcc/ChangeLog:
PR tree-optimization/104942
* tree-object-size.cc (alloc_object_size): Remove STRIP_NOPS.
gcc/testsuite/ChangeLog:
PR tree-optimization/104942
* gcc.dg/builtin-dynamic-object-size-0.c (alloc_func_long,
test_builtin_malloc_long): New functions.
(main): Use it.
Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
Jakub Jelinek [Wed, 16 Mar 2022 10:04:16 +0000 (11:04 +0100)]
aarch64: Fix up RTL sharing bug in aarch64_load_symref_appropriately [PR104910]
We unshare all RTL created during expansion, but when
aarch64_load_symref_appropriately is called after expansion like in the
following testcases, we use imm in both HIGH and LO_SUM operands.
If imm is some RTL that shouldn't be shared like a non-sharable CONST,
we get at least with --enable-checking=rtl a checking ICE, otherwise might
just get silently wrong code.
The following patch fixes that by copying it if it can't be shared.
2022-03-16 Jakub Jelinek <jakub@redhat.com>
PR target/104910
* config/aarch64/aarch64.cc (aarch64_load_symref_appropriately): Copy
imm rtx.
* gcc.dg/pr104910.c: New test.
Roger Sayle [Wed, 16 Mar 2022 09:27:33 +0000 (09:27 +0000)]
Performance/size improvement to single_use when matching GIMPLE.
This patch improves the implementation of single_use as used in code
generated from match.pd for patterns using :s. The current implementation
contains the logic "has_zero_uses (t) || has_single_use (t)" which
performs a loop over the uses to first check if there are zero non-debug
uses [which is rare], then another loop over these uses to check if there
is exactly one non-debug use. This can be better implemented using a
single loop.
This function is currently inlined over 800 times in gimple-match.cc,
whose .o on x86_64-pc-linux-gnu is now up to 30 Mbytes, so speeding up
and shrinking this function should help offset the growth in match.pd
for GCC 12.
I've also done an analysis of the stage3 sizes of gimple-match.o on
x86_64-pc-linux-gnu, which I believe is dominated by debug information,
the .o file is 30MB in stage3, but only 4.8M in stage2. Before my
proposed patch gimple-match.o is
31385160 bytes. The patch as proposed
yesterday (using a single loop in single_use) reduces that to
31105040
bytes, saving 280120 bytes. The suggestion to remove the "inline"
keyword saves only 56 more bytes, but annotating ATTRIBUTE_PURE on a
function prototype was curiously effective, saving 1888 bytes.
before:
31385160
after:
31105040 saved 280120
-inline:
31104984 saved 56
+pure:
31103096 saved 1888
2022-03-16 Roger Sayle <roger@nextmovesoftware.com>
Richard Biener <rguenther@suse.de>
gcc/ChangeLog
* gimple-match-head.cc (single_use): Implement inline using a
single loop.
Roger Sayle [Wed, 16 Mar 2022 09:25:34 +0000 (09:25 +0000)]
Some minor HONOR_NANS improvements to match.pd
Tweak the constant folding of X CMP X in when X can't be a NaN.
2022-03-16 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* match.pd (X CMP X -> true): Test tree_expr_maybe_nan_p
instead of HONOR_NANS.
(X LTGT X -> false): Enable if X is not tree_expr_maybe_nan_p, as
this can't trap/signal.
Thomas Schwinge [Wed, 16 Mar 2022 07:02:39 +0000 (08:02 +0100)]
OpenACC privatization diagnostics vs. 'assert' [PR102841]
It's an orthogonal concern why these diagnostics do appear at all for
non-offloaded OpenACC constructs (where they're not relevant at all); PR90115.
Depending on how 'assert' is implemented, it may cause temporaries to be
created, and/or may lower into 'COND_EXPR's, and
'gcc/gimplify.cc:gimplify_cond_expr' uses 'create_tmp_var (type, "iftmp")'.
Fix-up for commit
11b8286a83289f5b54e813f14ff56d730c3f3185
"[OpenACC privatization] Largely extend diagnostics and
corresponding testsuite coverage [PR90115]".
PR testsuite/102841
libgomp/
* testsuite/libgomp.oacc-c-c++-common/host_data-7.c: Adjust.
liuhongt [Wed, 16 Mar 2022 07:59:57 +0000 (15:59 +0800)]
Don't fold __builtin_ia32_blendvpd w/o sse4.2.
__builtin_ia32_blendvpd is defined under sse4.1 and gimple folded
to ((v2di) c) < 0 ? b : a where vec_cmpv2di is under sse4.2 w/o which
it's veclowered to scalar operations and not combined back in rtl.
gcc/ChangeLog:
PR target/104946
* config/i386/i386-builtin.def (BDESC): Add
CODE_FOR_sse4_1_blendvpd for IX86_BUILTIN_BLENDVPD.
* config/i386/i386.cc (ix86_gimple_fold_builtin): Don't fold
__builtin_ia32_blendvpd w/o sse4.2
gcc/testsuite/ChangeLog:
* gcc.target/i386/sse4_1-blendvpd-1.c: New test.
Chung-Ju Wu [Wed, 16 Mar 2022 03:20:00 +0000 (03:20 +0000)]
MAINTAINERS: Add myself to DCO section
ChangeLog:
* MAINTAINERS: Add myself to DCO section.
GCC Administrator [Wed, 16 Mar 2022 00:16:44 +0000 (00:16 +0000)]
Daily bump.
David Malcolm [Tue, 15 Mar 2022 21:56:29 +0000 (17:56 -0400)]
analyzer: add test coverage for PR 95000
PR analyzer/95000 isn't fixed yet; add test coverage with XFAILs.
gcc/testsuite/ChangeLog:
PR analyzer/95000
* gcc.dg/analyzer/pr95000-1.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Tue, 15 Mar 2022 21:55:14 +0000 (17:55 -0400)]
analyzer: presize m_cluster_map in store copy ctor
Testing cc1 on pr93032-mztools-unsigned-char.c
Benchmark #1: (without patch)
Time (mean ± σ): 338.8 ms ± 13.6 ms [User: 323.2 ms, System: 14.2 ms]
Range (min … max): 326.7 ms … 363.1 ms 10 runs
Benchmark #2: (with patch)
Time (mean ± σ): 332.3 ms ± 12.8 ms [User: 316.6 ms, System: 14.3 ms]
Range (min … max): 322.5 ms … 357.4 ms 10 runs
Summary
./cc1.new ran 1.02 ± 0.06 times faster than ./cc1.old
gcc/analyzer/ChangeLog:
* store.cc (store::store): Presize m_cluster_map.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Peter Bergner [Tue, 15 Mar 2022 13:46:47 +0000 (08:46 -0500)]
rs6000: Fix invalid address passed to __builtin_mma_disassemble_acc [PR104923]
The mma_disassemble_output_operand predicate is too lenient on the types
of addresses it will accept, leading to combine creating invalid address
that eventually lead to ICEs in LRA. The solution is to restrict the
addresses to indirect, indexed or those valid for quad memory accesses.
2022-03-15 Peter Bergner <bergner@linux.ibm.com>
gcc/
PR target/104923
* config/rs6000/predicates.md (mma_disassemble_output_operand): Restrict
acceptable MEM addresses.
gcc/testsuite/
PR target/104923
* gcc.target/powerpc/pr104923.c: New test.
Patrick Palka [Tue, 15 Mar 2022 12:50:24 +0000 (08:50 -0400)]
c++: extraneous access error with ambiguous lookup [PR103177]
When a lookup is ambiguous, lookup_member still attempts to check
access of the first member found before diagnosing the ambiguity and
propagating the error, and this may cause us to issue an extraneous
access error as in the testcase below (for B1::foo).
This patch fixes this by swapping the order of the ambiguity and access
checks within lookup_member. In passing, since the only thing that could
go wrong during lookup_field_r is ambiguity, we might as well hardcode
that in lookup_member and get rid of lookup_field_info::errstr.
PR c++/103177
gcc/cp/ChangeLog:
* search.cc (lookup_field_info::errstr): Remove this data
member.
(lookup_field_r): Don't set errstr.
(lookup_member): Check ambiguity before checking access.
Simplify accordingly after errstr removal. Exit early upon
error or empty result.
gcc/testsuite/ChangeLog:
* g++.dg/lookup/ambig6.C: New test.
Jakub Jelinek [Tue, 15 Mar 2022 12:34:33 +0000 (13:34 +0100)]
riscv: Allow -Wno-psabi to turn off ABI warnings [PR91229]
While checking if all targets honor -Wno-psabi for ABI related warnings
or messages, I found that almost all do, except for riscv.
In the testsuite when we want to ignore ABI related messages we
typically use -Wno-psabi -w, but it would be nice to get rid of those
-w uses eventually.
The following allows silencing those warnings with -Wno-psabi rather than
just -w even on riscv.
2022-03-15 Jakub Jelinek <jakub@redhat.com>
PR target/91229
* config/riscv/riscv.cc (riscv_pass_aggregate_in_fpr_pair_p,
riscv_pass_aggregate_in_fpr_and_gpr_p): Pass OPT_Wpsabi instead of 0
to warning calls.
Jakub Jelinek [Tue, 15 Mar 2022 09:24:22 +0000 (10:24 +0100)]
i386: Use no-mmx,no-sse for LIBGCC2_UNWIND_ATTRIBUTE [PR104890]
Regardless of the outcome of the general-regs-only stuff in x86gprintrin.h,
apparently general-regs-only is much bigger hammer than no-sse, and e.g.
using 387 instructions in the unwinder isn't a big deal, it never needs
to realign the stack because of it.
So, the following patch uses no-sse (and adds no-mmx to it, even when not
strictly needed).
2022-03-15 Jakub Jelinek <jakub@redhat.com>
PR target/104890
* config/i386/i386.h (LIBGCC2_UNWIND_ATTRIBUTE): Use no-mmx,no-sse
instead of general-regs-only.
Roger Sayle [Tue, 15 Mar 2022 09:05:28 +0000 (09:05 +0000)]
PR tree-optimization/101895: Fold VEC_PERM to help recognize FMA.
This patch resolves PR tree-optimization/101895 a missed optimization
regression, by adding a costant folding simplification to match.pd to
simplify the transform "mult; vec_perm; plus" into "vec_perm; mult; plus"
with the aim that keeping the multiplication and addition next to each
other allows them to be recognized as fused-multiply-add on suitable
targets. This transformation requires a tweak to match.pd's
vec_same_elem_p predicate to handle CONSTRUCTOR_EXPRs using the same
SSA_NAME_DEF_STMT idiom used for constructors elsewhere in match.pd.
The net effect is that the following code example:
void foo(float * __restrict__ a, float b, float *c) {
a[0] = c[0]*b + a[0];
a[1] = c[2]*b + a[1];
a[2] = c[1]*b + a[2];
a[3] = c[3]*b + a[3];
}
when compiled on x86_64-pc-linux-gnu with -O2 -march=cascadelake
currently generates:
vbroadcastss %xmm0, %xmm0
vmulps (%rsi), %xmm0, %xmm0
vpermilps $216, %xmm0, %xmm0
vaddps (%rdi), %xmm0, %xmm0
vmovups %xmm0, (%rdi)
ret
but with this patch now generates the improved:
vpermilps $216, (%rsi), %xmm1
vbroadcastss %xmm0, %xmm0
vfmadd213ps (%rdi), %xmm0, %xmm1
vmovups %xmm1, (%rdi)
ret
2022-03-15 Roger Sayle <roger@nextmovesoftware.com>
Marc Glisse <marc.glisse@inria.fr>
Richard Biener <rguenther@suse.de>
gcc/ChangeLog
PR tree-optimization/101895
* match.pd (vec_same_elem_p): Handle CONSTRUCTOR_EXPR def.
(plus (vec_perm (mult ...) ...) ...): New reordering simplification.
gcc/testsuite/ChangeLog
PR tree-optimization/101895
* gcc.target/i386/pr101895.c: New test case.
Jakub Jelinek [Tue, 15 Mar 2022 08:15:27 +0000 (09:15 +0100)]
c++: Fix up cp_parser_skip_to_pragma_eol [PR104623]
We ICE on the following testcase, because we tentatively parse it multiple
times and the erroneous attribute syntax results in
cp_parser_skip_to_end_of_statement, which when seeing CPP_PRAGMA (can be
any deferred one, OpenMP/OpenACC/ivdep etc.) it calls
cp_parser_skip_to_pragma_eol, which calls cp_lexer_purge_tokens_after.
That call purges all the tokens from CPP_PRAGMA until CPP_PRAGMA_EOL,
excluding the initial CPP_PRAGMA though (but including the final
CPP_PRAGMA_EOL). This means the second time we parse this, we see
CPP_PRAGMA with no tokens after it from the pragma, most importantly
not the CPP_PRAGMA_EOL, so either if it is the last pragma in the TU,
we ICE, or if there are other pragmas we treat everything in between
as a pragma.
I've tried various things, including making the CPP_PRAGMA token
itself also purged, or changing the cp_parser_skip_to_end_of_statement
(and cp_parser_skip_to_end_of_block_or_statement) to call it with
NULL instead of token, so that this purging isn't done there,
but each patch resulted in lots of regressions.
But removing the purging altogether surprisingly doesn't regress anything,
and I think it is the right thing, if we e.g. parse tentatively, why can't
we parse the pragma multiple times or at least skip over it?
2022-03-15 Jakub Jelinek <jakub@redhat.com>
PR c++/104623
* parser.cc (cp_parser_skip_to_pragma_eol): Don't purge any tokens.
* g++.dg/gomp/pr104623.C: New test.
Jakub Jelinek [Tue, 15 Mar 2022 08:12:03 +0000 (09:12 +0100)]
ifcvt: Punt if not onlyjump_p for find_if_case_{1,2} [PR104814]
find_if_case_{1,2} implicitly assumes conditional jumps and rewrites them,
so if they have extra side-effects or are say asm goto, things don't work
well, either the side-effects are lost or we could ICE.
In particular, the testcase below on s390x has there a doloop instruction
that decrements a register in addition to testing it for non-zero and
conditionally jumping based on that.
The following patch fixes that by punting for !onlyjump_p case, i.e.
if there are side-effects in the jump instruction or it isn't a plain PC
setter.
Also, it assumes BB_END (test_bb) will be always non-NULL, because basic
blocks with 2 non-abnormal successor edges should always have some instruction
at the end that determines which edge to take.
2022-03-15 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/104814
* ifcvt.cc (find_if_case_1, find_if_case_2): Punt if test_bb doesn't
end with onlyjump_p. Assume BB_END (test_bb) is always non-NULL.
* gcc.c-torture/execute/pr104814.c: New test.
Martin Sebor [Tue, 15 Mar 2022 00:23:08 +0000 (18:23 -0600)]
Avoid -Wdangling-pointer for by-transparent-reference arguments [PR104436].
This change avoids -Wdangling-pointer for by-value arguments transformed
into by-transparent-reference.
Resolves:
PR middle-end/104436 - spurious -Wdangling-pointer assigning local address to a class passed by value
gcc/ChangeLog:
PR middle-end/104436
* gimple-ssa-warn-access.cc (pass_waccess::check_dangling_stores):
Check for warning suppression. Avoid by-value arguments transformed
into by-transparent-reference.
gcc/testsuite/ChangeLog:
PR middle-end/104436
* c-c++-common/Wdangling-pointer-8.c: New test.
* g++.dg/warn/Wdangling-pointer-5.C: New test.
GCC Administrator [Tue, 15 Mar 2022 00:16:49 +0000 (00:16 +0000)]
Daily bump.
Joseph Myers [Mon, 14 Mar 2022 22:28:33 +0000 (22:28 +0000)]
Update gcc de.po, fr.po, sv.po
* de.po, fr.po, sv.po: Update.
Roger Sayle [Mon, 14 Mar 2022 18:12:55 +0000 (18:12 +0000)]
Fix libitm.c/memset-1.c test fails with new peephole2s.
My sincere apologies for the breakage, but alas handling SImode in the
recently added "xorl;movb -> movzbl" peephole2 turns out to be slightly
more complicated that just using SWI48 as a mode iterator. I'd failed
to check the machine description carefully, but the *zero_extend<mode>si2
define_insn is conditionally defined, based on x86 target tuning using
TARGET_ZERO_EXTEND_WITH_AND, and therefore unavailable on 486 and pentium
unless optimizing the code for size. It turns out that the libitm testsuite
specifies -m486 with make check RUNTESTFLAGS="--target_board='unix{-m32}'"
and therefore encounters/catches oversight.
Fixed by adding the appropriate conditions to the new peephole2 patterns.
2022-03-14 Roger Sayle <roger@nextmovesoftware.com>
Uroš Bizjak <ubizjak@gmail.com>
gcc/ChangeLog
* config/i386/i386.md (peephole2 xorl;movb -> movzbl): Disable
transformation when *zero_extend<mode>si2 is not available.
gcc/testsuite/ChangeLog
* gcc.target/i386/pr98335.c: Skip this test if tuning for i486
or pentium, and not optimizing for size.
Xi Ruoyao [Fri, 11 Mar 2022 03:07:00 +0000 (11:07 +0800)]
Enable libsanitizer build on mips64
Bootstrapped and regtested on mips64-linux-gnuabi64.
bootstrap-ubsan revealed 3 bugs (PR 104842, 104843, 104851).
bootstrap-asan did not reveal any new bug.
gcc/
* config/mips/mips.h (SUBTARGET_SHADOW_OFFSET): Define.
* config/mips/mips.cc (mips_option_override): Make
-fsanitize=address imply -fasynchronous-unwind-tables. This is
needed by libasan for stack backtrace on MIPS.
(mips_asan_shadow_offset): Return SUBTARGET_SHADOW_OFFSET.
gcc/testsuite:
* c-c++-common/asan/global-overflow-1.c: Skip for MIPS with some
optimization levels because inaccurate debug info is causing
dg-output mismatch on line numbers.
* g++.dg/asan/large-func-test-1.C: Likewise.
libsanitizer/
* configure.tgt: Enable build on mips*64*-*-linux*.
Xi Ruoyao [Fri, 11 Mar 2022 02:59:29 +0000 (10:59 +0800)]
libsanitizer: cherry-pick
db7bca28638e from upstream
libsanitizer/
* sanitizer_common/sanitizer_atomic_clang.h: Ensures to only
include sanitizer_atomic_clang_mips.h for O32.
Jakub Jelinek [Mon, 14 Mar 2022 13:49:09 +0000 (14:49 +0100)]
lra: Fix up debug_p handling in lra_substitute_pseudo [PR104778]
The following testcase ICEs on powerpc-linux, because lra_substitute_pseudo
substitutes (const_int 1) into a subreg operand. First a subreg of subreg
of a reg appears in a debug insn (which surely is invalid outside of
debug insns, but in debug insns we allow even what is normally invalid in
RTL like subregs which the target doesn't like, because either dwarf2out
is able to handle it, or we just throw away the location expression,
making some var <optimized out>.
lra_substitute_pseudo already has some code to deal with specifically
SUBREG of REG with the REG being substituted for VOIDmode constant,
but that doesn't cover this case, so the following patch extends
lra_substitute_pseudo for debug_p mode to treat stuff like e.g.
combiner's subst function to ensure we don't lose mode which is essential
for the IL.
2022-03-14 Jakub Jelinek <jakub@redhat.com>
PR debug/104778
* lra.cc (lra_substitute_pseudo): For debug_p mode, simplify
SUBREG, ZERO_EXTEND, SIGN_EXTEND, FLOAT or UNSIGNED_FLOAT if recursive
call simplified the first operand into VOIDmode constant.
* gcc.target/powerpc/pr104778.c: New test.
Jonathan Wakely [Fri, 11 Mar 2022 14:52:38 +0000 (14:52 +0000)]
libstdc++: Fix reading UTF-8 characters for 16-bit targets [PR104875]
The current code in read_utf8_code_point assumes that integer promotion
will create a 32-bit int, but that's not true for 16-bit targets like
msp430 and avr. This changes the intermediate variables used for each
octet from unsigned char to char32_t, so that (c << N) works correctly
when N > 8.
libstdc++-v3/ChangeLog:
PR libstdc++/104875
* src/c++11/codecvt.cc (read_utf8_code_point): Use char32_t to
hold octets that will be left-shifted.
Jonathan Wakely [Fri, 11 Mar 2022 18:33:40 +0000 (18:33 +0000)]
top-level: Fix comment about --enable-libstdcxx in configure
The custom option for enabling/disabling libstdc++ is not spelled the
same as the directory name:
AC_ARG_ENABLE(libstdcxx,
AS_HELP_STRING([--disable-libstdcxx],
[do not build libstdc++-v3 directory])
The comment referring to it later use the wrong name.
ChangeLog:
* configure.ac: Fix incorrect option in comment.
* configure: Regenerate.
Jakub Jelinek [Mon, 14 Mar 2022 09:47:38 +0000 (10:47 +0100)]
c++: Reject __builtin_clear_padding on non-trivially-copyable types with one exception [PR102586]
As mentioned by Jason in the PR, non-trivially-copyable types (or non-POD
for purposes of layout?) types can be base classes of derived classes in
which the padding in those non-trivially-copyable types can be reused for
some real data members or even the layout can change and data members can
be moved to other positions.
__builtin_clear_padding is right now used for multiple purposes,
in <atomic> where it isn't used yet but was planned as the main spot
it can be used for trivially copyable types only, ditto for std::bit_cast
where we also use it. It is used for OpenMP long double atomics too but
long double is trivially copyable, and lastly for -ftrivial-auto-var-init=.
The following patch restricts the builtin to pointers to trivially-copyable
types, with the exception when it is called directly on an address of a
variable, in that case already the FE can verify it is the complete object
type and so it is safe to clear all the paddings in it.
2022-03-14 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/102586
gcc/
* doc/extend.texi (__builtin_clear_padding): Clearify that for C++
argument type should be pointer to trivially-copyable type unless it
is address of a variable or parameter.
gcc/cp/
* call.cc (build_cxx_call): Diagnose __builtin_clear_padding where
first argument's type is pointer to non-trivially-copyable type unless
it is address of a variable or parameter.
gcc/testsuite/
* g++.dg/cpp2a/builtin-clear-padding1.C: New test.
Jakub Jelinek [Mon, 14 Mar 2022 09:44:38 +0000 (10:44 +0100)]
i386: Fix up _mm_loadu_si{16,32} [PR99754]
These intrinsics are supposed to do an unaligned may_alias load
of a 16-bit or 32-bit value and store it as the first element of
a 128-bit integer vector, with all other elements cleared.
The current _mm_storeu_* implementation implements that correctly, uses
__*_u types to do the store and extracts the first element of a vector into
it.
But _mm_loadu_si{16,32} gets it all wrong. It performs an aligned
non-may_alias load and because _mm_set_epi{16,32} has the args reversed,
it also inserts it into the last vector element instead of first.
The following patch fixes that.
Note, while the Intrinsics guide for _mm_loadu_si32 says SSE2,
for _mm_loadu_si16 it says strangely SSE. But the intrinsics
returns __m128i, which is only defined in emmintrin.h, and
_mm_set_epi16 is also only SSE2 and later in emmintrin.h.
Even clang defines it in emmintrin.h and ends up with inlining
failure when calling _mm_loadu_si16 from sse,no-sse2 function.
So, isn't that a bug in the intrinsic guide instead?
2022-03-14 Jakub Jelinek <jakub@redhat.com>
PR target/99754
* config/i386/emmintrin.h (_mm_loadu_si32): Put loaded value into
first rather than last element of the vector, use __m32_u to do
a really unaligned load, use just 0 instead of (int)0.
(_mm_loadu_si16): Put loaded value into first rather than last
element of the vector, use __m16_u to do a really unaligned load,
use just 0 instead of (short)0.
* gcc.target/i386/pr99754-1.c: New test.
* gcc.target/i386/pr99754-2.c: New test.
Jakub Jelinek [Mon, 14 Mar 2022 09:40:47 +0000 (10:40 +0100)]
Spelling fix - cannott -> cannot [PR104899]
This fixes typos and while changing that, also uses %< %> around attribute
names and fixes up formatting.
2022-03-14 Jakub Jelinek <jakub@redhat.com>
PR other/104899
* config/bfin/bfin.cc (bfin_handle_longcall_attribute): Fix a typo
in diagnostic message - cannott -> cannot. Use %< and %> around
names of attribute. Avoid too long line.
* range-op.cc (operator_logical_and::op1_range): Fix up a typo
in comment - cannott -> cannot. Use 2 spaces after . instead of one.
liuhongt [Thu, 24 Feb 2022 06:42:14 +0000 (14:42 +0800)]
Don't fold builtin into gimple when isa mismatches.
The patch fixes ICE in ix86_gimple_fold_builtin.
gcc/ChangeLog:
PR target/104666
* config/i386/i386-expand.cc
(ix86_check_builtin_isa_match): New func.
(ix86_expand_builtin): Move code to
ix86_check_builtin_isa_match and call it.
* config/i386/i386-protos.h
(ix86_check_builtin_isa_match): Declare.
* config/i386/i386.cc (ix86_gimple_fold_builtin): Don't fold
builtin into gimple when isa mismatches.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr104666.c: New test.
GCC Administrator [Mon, 14 Mar 2022 00:16:20 +0000 (00:16 +0000)]
Daily bump.
Iain Buclaw [Sun, 13 Mar 2022 11:28:05 +0000 (12:28 +0100)]
d: Merge upstream dmd
02a3fafc6, druntime
26b58167, phobos
16cb085b5.
D front-end changes:
- Import dmd v2.099.0.
- The deprecation period for D1-style operators has ended, any use
of the D1 overload operators will now result in a compiler error.
- `scope' as a type constraint on class, struct, union, and enum
declarations has been deprecated.
- Fix segmentation fault when emplacing a new front-end Expression
node during CTFE (PR104835).
D runtime changes:
- Import druntime v2.099.0.
- Fix C bindings for stdint types (PR104738).
- Fix bus error when allocating new array on the GC (PR104742).
- Fix bus error when allocating new pointer on the GC (PR104745).
Phobos changes:
- Import phobos v2.099.0.
- New function `bind' in `std.functional'.
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd
02a3fafc6.
* dmd/VERSION: Update version to v2.099.0.
* imports.cc (ImportVisitor::visit (EnumDeclaration *)): Don't cache
decl in front-end AST node.
(ImportVisitor::visit (AggregateDeclaration *)): Likewise.
(ImportVisitor::visit (ClassDeclaration *)): Likewise.
libphobos/ChangeLog:
* libdruntime/MERGE: Merge upstream druntime
26b58167.
* src/MERGE: Merge upstream phobos
16cb085b5.
Tobias Burnus [Sun, 13 Mar 2022 09:23:07 +0000 (10:23 +0100)]
texi + c-target.def: Fix typos
gcc/c-family/ChangeLog:
* c-target.def (check_string_object_format_arg): Fix description typo.
gcc/ChangeLog:
* doc/invoke.texi: Fix typos.
* doc/tm.texi.in: Remove duplicated word.
* doc/tm.texi: Regenerate.
libgomp/ChangeLog:
* libgomp.texi: Fix typo.
GCC Administrator [Sun, 13 Mar 2022 00:16:20 +0000 (00:16 +0000)]
Daily bump.
Patrick Palka [Sat, 12 Mar 2022 20:00:51 +0000 (15:00 -0500)]
c++: naming a dependently-scoped template for CTAD [PR104641]
In order to be able to perform CTAD for a dependently-scoped template
(such as A<T>::B in the testcase below), we need to permit a
typename-specifier to resolve to a template as per [dcl.type.simple]/3,
at least when it appears in a CTAD-enabled context.
This patch implements this using a new tsubst flag tf_tst_ok to control
when a TYPENAME_TYPE is allowed to name a template, and sets this flag
when substituting into the type of a CAST_EXPR, CONSTRUCTOR or VAR_DECL
(each of which is a CTAD-enabled context).
PR c++/104641
gcc/cp/ChangeLog:
* cp-tree.h (tsubst_flags::tf_tst_ok): New flag.
* decl.cc (make_typename_type): Allow a typename-specifier to
resolve to a template when tf_tst_ok, in which case return
a CTAD placeholder for the template.
* pt.cc (tsubst_decl) <case VAR_DECL>: Set tf_tst_ok when
substituting the type.
(tsubst): Clear tf_tst_ok and remember if it was set.
<case TYPENAME_TYPE>: Pass tf_tst_ok to make_typename_type
appropriately.
(tsubst_copy) <case CAST_EXPR>: Set tf_tst_ok when substituting
the type.
(tsubst_copy_and_build) <case CAST_EXPR>: Likewise.
<case CONSTRUCTOR>: Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/class-deduction107.C: New test.
Patrick Palka [Sat, 12 Mar 2022 20:00:49 +0000 (15:00 -0500)]
c++: ICE with bad conversion shortcutting [PR104622]
When shortcutting bad argument conversions during overload resolution,
we assume conversions get computed in sequential order and that therefore
the conversion array is incomplete iff the last conversion is missing.
But this assumption turns out to be wrong for templates, because during
deduction check_non_deducible_conversion can compute an argument
conversion out of order.
So in the testcase below, at the end of add_template_candidate the
conversion array looks like {bad_conv, NULL, good_conv} where the last
conversion was computed during deduction and the first one later from
add_function_candidate. We need to add this candidate to bad_fns since
not all of its argument conversions were computed, but we don't do so
because the last conversion isn't missing.
This patch fixes this by checking for a missing conversion exhaustively
instead. In passing, this cleans up check_non_deducible_conversion given
that the only values of 'strict' we expect to see here the enumerators
of unification_kind_t.
PR c++/104622
gcc/cp/ChangeLog:
* call.cc (missing_conversion_p): Define.
(add_candidates): Use it.
* pt.cc (check_non_deducible_conversion): Change type of strict
parameter to unification_kind_t and directly test for DEDUCE_CALL.
gcc/testsuite/ChangeLog:
* g++.dg/template/conv18.C: New test.
Patrick Palka [Sat, 12 Mar 2022 20:00:40 +0000 (15:00 -0500)]
c++: return-type-req in constraint using only outer tparms [PR104527]
Here the template context for the atomic constraint has two levels of
template parameters, but since it depends only on the innermost parameter
T we use a single-level argument vector (built by get_mapped_args) during
substitution into the atom. We eventually pass this vector to
do_auto_deduction as part of checking the return-type-requirement within
the atom, but do_auto_deduction expects outer_targs to be a full set of
arguments for sake of satisfaction.
This patch fixes this by making get_mapped_args always return an
argument vector whose depth corresponds to the template depth of the
context in which the atomic constraint expression was written, instead
of the highest parameter level that the expression happens to use.
PR c++/104527
gcc/cp/ChangeLog:
* constraint.cc (normalize_atom): Set
ATOMIC_CONSTR_EXPR_FROM_CONCEPT_P appropriately.
(get_mapped_args): Make static, adjust parameters. Always
return a vector whose depth corresponds to the template depth of
the context of the atomic constraint expression. Micro-optimize
by passing false as exact to safe_grow_cleared and by collapsing
a multi-level depth-one argument vector.
(satisfy_atom): Adjust call to get_mapped_args and
diagnose_atomic_constraint.
(diagnose_atomic_constraint): Replace map parameter with an args
parameter.
* cp-tree.h (ATOMIC_CONSTR_EXPR_FROM_CONCEPT_P): Define.
(get_mapped_args): Remove declaration.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-return-req4.C: New test.
Patrick Palka [Sat, 12 Mar 2022 19:57:59 +0000 (14:57 -0500)]
c++: ICE with non-constant satisfaction value [PR98644]
Here during satisfaction, the expression of the atomic constraint after
substitution is (int *) NON_LVALUE_EXPR <1> != 0B, which is not a C++
constant expression due to the reinterpret_cast, but TREE_CONSTANT is
set since its value is otherwise effectively constant. We then call
maybe_constant_value on it, which proceeds via its fail-fast path to
exit early without clearing TREE_CONSTANT. But satisfy_atom relies
on checking TREE_CONSTANT of the result of maybe_constant_value in order
to detect non-constant satisfaction.
This patch fixes this by making the fail-fast path of maybe_constant_value
clear TREE_CONSTANT in this case, like cxx_eval_outermost_constant_expr
in the normal path would have done.
PR c++/98644
gcc/cp/ChangeLog:
* constexpr.cc (mark_non_constant): Define, split out from ...
(cxx_eval_outermost_constant_expr): ... here.
(maybe_constant_value): Use it.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-pr98644.C: New test.
* g++.dg/parse/array-size2.C: Remove expected diagnostic about a
narrowing conversion.
Co-authored-by: Jason Merrill <jason@redhat.com>
Patrick Palka [Sat, 12 Mar 2022 19:57:56 +0000 (14:57 -0500)]
c++: give fold expressions a location
This improves diagnostic quality for unsatisfied atomic constraints
that consist of a fold expression, e.g. in concepts/diagnostic3.C
the "evaluated to false" diagnostic now points to the expression:
.../diagnostic3.C:10:22: note: the expression ‘(foo<Ts> && ...) [with Ts = {int, char}]’ evaluated to ‘false’
10 | requires (foo<Ts> && ...)
| ~~~~~~~~~~~~^~~~
gcc/cp/ChangeLog:
* semantics.cc (finish_unary_fold_expr): Use input_location
instead of UNKNOWN_LOCATION.
(finish_binary_fold_expr): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/concepts/diagnostic3.C: Adjusted expected location of
"evaluated to false" diagnostics.
Segher Boessenkool [Fri, 11 Mar 2022 21:15:18 +0000 (21:15 +0000)]
rs6000: Do not use rs6000_cpu for .machine ppc and ppc64 (PR104829)
Fixes:
77eccbf39ed5
rs6000.h has
#define PROCESSOR_POWERPC PROCESSOR_PPC604
#define PROCESSOR_POWERPC64 PROCESSOR_RS64A
which means that if you use things like -mcpu=powerpc -mvsx it will no
longer work after my latest .machine patch. This causes GCC build errors
in some cases, not a good idea (even if the errors are actually
pre-existing: using -mvsx with a machine that does not have VSX cannot
work properly).
2022-03-11 Segher Boessenkool <segher@kernel.crashing.org>
PR target/104829
* config/rs6000/rs6000.cc (rs6000_machine_from_flags): Don't output
"ppc" and "ppc64" based on rs6000_cpu.
Thomas Schwinge [Fri, 11 Mar 2022 21:31:51 +0000 (22:31 +0100)]
OpenACC 'kernels' decomposition: resolve wrong-code cases unless manually making certain variables addressable [PR100280, PR104892]
Currently in OpenACC 'kernels' decomposition, there is special handling of
'GOMP_MAP_FORCE_TOFROM', documented to be done to avoid "internal compiler
errors in later passes". For performance reasons, the current repetitive
to/from device copying for every region is not ideal, compared to using
'present' clauses, as done for almost all other 'GOMP_MAP_*'. Also, the
current special handling (incomplete, evidently) is the reason for the PR104892
misbehavior. For PR100280 etc. we've resolved all such known ICEs -- removing
the special handling for 'GOMP_MAP_FORCE_TOFROM' now resolves PR104892.
PR middle-end/100280
PR middle-end/104892
gcc/
* omp-oacc-kernels-decompose.cc (omp_oacc_kernels_decompose_1):
Remove special handling of 'GOMP_MAP_FORCE_TOFROM'.
gcc/testsuite/
* c-c++-common/goacc/kernels-decompose-2.c: Adjust.
* c-c++-common/goacc/kernels-decompose-pr100400-1-1.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr100400-1-2.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr100400-1-3.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr100400-1-4.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104061-1-1.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104061-1-2.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104061-1-3.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104061-1-4.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104132-1.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104133-1.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104774-1.c: Likewise.
* gfortran.dg/goacc/classify-kernels.f95: Likewise.
* gfortran.dg/goacc/kernels-decompose-2.f95: Likewise.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/declare-vla.c: Adjust.
* testsuite/libgomp.oacc-c-c++-common/default-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-decompose-1.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-reduction-1.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Likewise.
* testsuite/libgomp.oacc-fortran/asyncwait-1.f90: Likewise.
* testsuite/libgomp.oacc-fortran/kernels-reduction-1.f90:
Likewise.
Thomas Schwinge [Fri, 11 Mar 2022 14:11:25 +0000 (15:11 +0100)]
OpenACC 'kernels' decomposition: wrong-code cases unless manually making certain variables addressable [PR104892]
Document a few examples of the status quo.
PR middle-end/104892
libgomp/
* testsuite/libgomp.oacc-c-c++-common/kernels-decompose-1.c: Point
to PR104892.
* testsuite/libgomp.oacc-c-c++-common/default-1.c: Likewise,
enable '--param=openacc-kernels=decompose' and adjust.
* testsuite/libgomp.oacc-c-c++-common/kernels-reduction-1.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Likewise.
* testsuite/libgomp.oacc-fortran/kernels-reduction-1.f90:
Likewise.
Thomas Schwinge [Fri, 11 Mar 2022 14:10:59 +0000 (15:10 +0100)]
Enhance further testcases to verify handling of OpenACC privatization level [PR90115]
As originally introduced in commit
11b8286a83289f5b54e813f14ff56d730c3f3185
"[OpenACC privatization] Largely extend diagnostics and corresponding testsuite
coverage [PR90115]".
PR middle-end/90115
libgomp/
* testsuite/libgomp.oacc-c-c++-common/default-1.c: Enhance.
* testsuite/libgomp.oacc-c-c++-common/kernels-reduction-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Likewise.
* testsuite/libgomp.oacc-fortran/kernels-reduction-1.f90: Likewise.
Thomas Schwinge [Thu, 17 Feb 2022 13:18:57 +0000 (14:18 +0100)]
OpenACC 'kernels' decomposition: Mark variables used in 'present' clauses as addressable [PR100280, PR104086]
... like in recent commit
9b32c1669aad5459dd053424f9967011348add83
"OpenACC 'kernels' decomposition: Mark variables used in synthesized
data clauses as addressable [PR100280]". Otherwise, we may run into
'gcc/omp-low.cc:lower_omp_target':
13125 else if (is_gimple_reg (var))
13126 {
13127 gcc_assert (offloaded);
PR middle-end/100280
PR middle-end/104086
gcc/
* omp-oacc-kernels-decompose.cc (omp_oacc_kernels_decompose_1):
Mark variables used in 'present' clauses as addressable.
* omp-low.cc (scan_sharing_clauses) <OMP_CLAUSE_MAP>: Gracefully
handle duplicate 'OMP_CLAUSE_MAP_DECL_MAKE_ADDRESSABLE'.
gcc/testsuite/
* c-c++-common/goacc/kernels-decompose-pr104086-1.c: Adjust,
extend.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/declare-vla-kernels-decompose-ice-1.c:
Merge this...
* testsuite/libgomp.oacc-c-c++-common/declare-vla-kernels-decompose.c:
..., and this...
* testsuite/libgomp.oacc-c-c++-common/declare-vla.c: ... into
this, and adjust.
* testsuite/libgomp.oacc-c-c++-common/kernels-decompose-1.c:
Extend.
Thomas Schwinge [Tue, 18 Jan 2022 16:22:14 +0000 (17:22 +0100)]
Add 'c-c++-common/goacc/kernels-decompose-pr104086-1.c' [PR104086]
..., currently XFAILed with 'dg-ice', as it runs into
'gcc/omp-low.cc:lower_omp_target':
13125 else if (is_gimple_reg (var))
13126 {
13127 gcc_assert (offloaded);
This means, the recent PR100280 etc. changes are still not sufficient.
gcc/testsuite/
PR middle-end/104086
* c-c++-common/goacc/kernels-decompose-pr104086-1.c: New file.
Thomas Schwinge [Thu, 17 Feb 2022 11:46:57 +0000 (12:46 +0100)]
Add 'gcc/tree.cc:user_omp_clause_code_name' [PR65095]
Re PR65095 "Adapt OpenMP diagnostic messages for OpenACC", move C/C++
front end 'gcc/c-family/c-omp.cc:c_omp_map_clause_name' to generic
'gcc/tree.cc:user_omp_clause_code_name' . No functional change.
PR other/65095
gcc/
* tree-core.h (user_omp_claus_code_name): Declare function.
* tree.cc (user_omp_clause_code_name): New function.
gcc/c/
* c-typeck.cc (handle_omp_array_sections_1)
(c_oacc_check_attachments): Call 'user_omp_clause_code_name'
instead of 'c_omp_map_clause_name'.
gcc/cp/
* semantics.cc (handle_omp_array_sections_1)
(cp_oacc_check_attachments): Call 'user_omp_clause_code_name'
instead of 'c_omp_map_clause_name'.
gcc/c-family/
* c-common.h (c_omp_map_clause_name): Remove.
* c-omp.cc (c_omp_map_clause_name): Remove.
Roger Sayle [Sat, 12 Mar 2022 09:20:52 +0000 (09:20 +0000)]
PR middle-end/98420: Don't fold x - x to 0.0 with -frounding-math
This patch addresses PR middle-end/98420, which is inappropriate constant
folding of x - x to 0.0 (in match.pd) when -frounding-math is specified.
Specifically, x - x may be -0.0 with FE_DOWNWARD as the rounding mode.
To summarize, the desired IEEE behaviour, x - x for floating point x,
(1) can't be folded to 0.0 by default, due to the possibility of NaN or Inf
(2) can be folded to 0.0 with -ffinite-math-only
(3) can't be folded to 0.0 with -ffinite-math-only -frounding-math
(4) can be folded with -ffinite-math-only -frounding-math -fno-signed-zeros
2022-03-12 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR middle-end/98420
* match.pd (minus @0 @0): Additional checks for -fno-rounding-math
(the defaut) or -fno-signed-zeros.
gcc/testsuite/ChangeLog
PR middle-end/98420
* gcc.dg/pr98420.c: New test case.
Michael Meissner [Sat, 12 Mar 2022 00:47:09 +0000 (19:47 -0500)]
Fix DImode to TImode sign extend issue
PR target/104868 had had an issue where my code that updated the DImode to
TImode sign extension for power10 failed. In looking at the failure
message, the reason is when extendditi2 tries to split the insn, it
generates an insn that does not satisfy its constraints:
(set (reg:V2DI 65 1)
(vec_duplicate:V2DI (reg:DI 0)))
The reason is vsx_splat_v2di does not allow GPR register 0 when the will
be generating a mtvsrdd instruction. In the definition of the mtvsrdd
instruction, if the RA register is 0, it means clear the upper 64 bits of
the vector instead of moving register GPR 0 to those bits.
When I wrote the extendditi2 pattern, I forgot that mtvsrdd had that
behavior so I used a 'r' constraint instead of 'b'. In the rare case
where the value is in GPR register 0, this split will fail.
This patch uses the right constraint for extendditi2.
2022-03-11 Michael Meissner <meissner@linux.ibm.com>
gcc/
PR target/104868
* config/rs6000/vsx.md (extendditi2): Use a 'b' constraint when
moving from a GPR register to an Altivec register.
GCC Administrator [Sat, 12 Mar 2022 00:16:27 +0000 (00:16 +0000)]
Daily bump.
Iain Buclaw [Fri, 11 Mar 2022 22:19:14 +0000 (23:19 +0100)]
d: Cache generated import declarations in a hash_map
Originally, these were cached in the front-end AST node field `isym'.
However, this field is due to be removed in the future.
gcc/d/ChangeLog:
* imports.cc (imported_decls): Define.
(class ImportVisitor): Add result_ field.
(ImportVisitor::result): New method.
(ImportVisitor::visit (Module *)): Store decl to result_.
(ImportVisitor::visit (Import *)): Likewise.
(ImportVisitor::visit (AliasDeclaration *)): Don't cache decl in
front-end AST node.
(ImportVisitor::visit (OverDeclaration *)): Likewise.
(ImportVisitor::visit (FuncDeclaration *)): Likewise.
(ImportVisitor::visit (Declaration *)): Likewise.
(build_import_decl): Use imported_decls to cache and lookup built
declarations.
Iain Buclaw [Fri, 11 Mar 2022 20:59:57 +0000 (21:59 +0100)]
d: Fix mistakes in strings to be translated [PR104552]
Address comments made in PR104552 about documented D language options.
gcc/d/ChangeLog:
PR translation/104552
* lang.opt (fdump-cxx-spec=): Fix typo in argument handle.
(fpreview=fixaliasthis): Quote `alias this' as code.
Roger Sayle [Fri, 11 Mar 2022 17:57:12 +0000 (17:57 +0000)]
PR tree-optimization/98335: New peephole2 xorl;movb -> movzbl
This patch is the backend piece of my proposed fix to PR tree-opt/98335,
to allow C++ partial struct initialization to be as efficient/optimized
as full struct initialization.
With the middle-end patch just posted to gcc-patches, the test case
in the PR compiles on x86_64-pc-linux-gnu with -O2 to:
xorl %eax, %eax
movb c(%rip), %al
ret
with this additional peephole2 (actually four peephole2s):
movzbl c(%rip), %eax
ret
2022-03-11 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR tree-optimization/98335
* config/i386/i386.md (peephole2): Eliminate redundant insv.
Combine movl followed by movb. Transform xorl followed by
a suitable movb or movw into the equivalent movz[bw]l.
gcc/testsuite/ChangeLog
PR tree-optimization/98335
* g++.target/i386/pr98335.C: New test case.
* gcc.target/i386/pr98335.c: New test case.
Roger Sayle [Fri, 11 Mar 2022 17:46:50 +0000 (17:46 +0000)]
PR tree-optimization/98335: Improvements to DSE's compute_trims.
This patch is the main middle-end piece of a fix for PR tree-opt/98335,
which is a code-quality regression affecting mainline. The issue occurs
in DSE's (dead store elimination's) compute_trims function that determines
where a store to memory can be trimmed. In the testcase given in the
PR, this function notices that the first byte of a DImode store is dead,
and replaces the 8-byte store at (aligned) offset zero, with a 7-byte store
at (unaligned) offset one. Most architectures can store a power-of-two
bytes (up to a maximum) in single instruction, so writing 7 bytes requires
more instructions than writing 8 bytes. This patch follows Jakub Jelinek's
suggestion in comment 5, that compute_trims needs improved heuristics.
On x86_64-pc-linux-gnu with -O2 the new test case in the PR goes from:
movl $0, -24(%rsp)
movabsq $
72057594037927935, %rdx
movl $0, -21(%rsp)
andq -24(%rsp), %rdx
movq %rdx, %rax
salq $8, %rax
movb c(%rip), %al
ret
to
xorl %eax, %eax
movb c(%rip), %al
ret
2022-03-11 Roger Sayle <roger@nextmovesoftware.com>
Richard Biener <rguenther@suse.de>
gcc/ChangeLog
PR tree-optimization/98335
* builtins.cc (get_object_alignment_2): Export.
* builtins.h (get_object_alignment_2): Likewise.
* tree-ssa-alias.cc (ao_ref_alignment): New.
* tree-ssa-alias.h (ao_ref_alignment): Declare.
* tree-ssa-dse.cc (compute_trims): Improve logic deciding whether
to align head/tail, writing more bytes but using fewer store insns.
gcc/testsuite/ChangeLog
PR tree-optimization/98335
* g++.dg/pr98335.C: New test case.
* gcc.dg/pr86010.c: New test case.
* gcc.dg/pr86010-2.c: New test case.
Roger Sayle [Fri, 11 Mar 2022 17:35:21 +0000 (17:35 +0000)]
[Committed] Update g++.dg/other/pr84964.C for ia32 (and similar) targets.
The "sorry, unimplemented" message in the new g++.dg/other/pr84964.C is
apparently dependent upon whether the target passes multi-gigabyte
arguments on the stack. This tweaks the testcase to just confirm that
it no longer ICEs, not the specific set of warnings/errors triggered.
2022-03-11 Roger Sayle <roger@nextmovesoftware.com>
gcc/testsuite/ChangeLog
PR c++/84964
* g++.dg/other/pr84964.C: Tweak test to check for the ICE, not for
the (target-dependent) sorry.
Richard Biener [Fri, 11 Mar 2022 13:09:33 +0000 (14:09 +0100)]
tree-optimization/104880 - update-address-taken and cmpxchg
The following addresses optimistic non-addressable marking of
an argument of __atomic_compare_exchange_n which broke when
I added DECL_NOT_GIMPLE_REG_P since we cannot guarantee we can
rewrite it when TREE_ADDRESSABLE is unset. Instead we have to
restore TREE_ADDRESSABLE in that case.
2022-03-11 Richard Biener <rguenther@suse.de>
PR tree-optimization/104880
* tree-ssa.cc (execute_update_address_taken): Remember if we
optimistically made something not addressable and
prepare to undo it.
* g++.dg/opt/pr104880.cc: New testcase.
Richard Biener [Fri, 11 Mar 2022 10:51:13 +0000 (11:51 +0100)]
target/104762 - vectorization costs of CONSTRUCTORs
After accounting for GPR -> XMM move cost for vec_construct the
base cost needs adjustments to not double-cost those. This also
lowers the cost when such move is not necessary.
2022-03-11 Richard Biener <rguenther@suse.de>
PR target/104762
* config/i386/i386.cc (ix86_builtin_vectorization_cost): Do not
cost the first lane of SSE pieces as inserts for vec_construct.
Tobias Burnus [Fri, 11 Mar 2022 12:02:00 +0000 (13:02 +0100)]
lto-plugin: Honor link_output_name for -foffload-objects file name
lto-plugin/ChangeLog:
* lto-plugin.c (all_symbols_read_handler): With -save-temps, use
link_output_name for -foffload-objects's file name, if available.
Rainer Orth [Fri, 11 Mar 2022 08:37:44 +0000 (09:37 +0100)]
libphobos: Enable on Solaris/SPARC or with /bin/as [PR 103528]
libphobos is currently only enabled on Solaris/x86 with gas. As
discovered when gdc was switched to the dmd frontend, this initially
broke bootstrap for the other Solaris configurations.
However, it's now well possible to enable it both for Solaris/x86 with
as and Solaris/SPARC (both as and gas) since the original problems (x86
as linelength limit, among others) are long gone.
The following patch does just that.
Tested on i386-pc-solaris2.11 and sparc-sun-solaris2.11 (both as and
gas) with gdc 9.3.0 (x86) resp. 9.4.0 (sparc, configured with
--enable-libphobos) as bootstrap compilers.
2021-12-01 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
libphobos:
PR d/103528
* configure.ac <x86_64-*-solaris2.* | i?86-*-solaris2.*>: Remove
gas requirement.
* configure: Regenerate.
* configure.tgt (sparc*-*-solaris2.11*): Mark supported.
Tobias Burnus [Fri, 11 Mar 2022 07:48:58 +0000 (08:48 +0100)]
Fortran: OpenMP/OpenACC avoid uninit access in size calc for mapping
gcc/fortran/ChangeLog:
* trans-openmp.cc (gfc_trans_omp_clauses, gfc_omp_finish_clause):
Obtain size for mapping only if allocatable array is allocated.
gcc/testsuite/ChangeLog:
* gfortran.dg/goacc/array-with-dt-1.f90: Update/add comments;
remove dg-warning for 'is used uninitialized'.
* gfortran.dg/goacc/pr93464.f90: Likewise.
* gfortran.dg/goacc/array-with-dt-1a.f90: New; copied from
gfortran.dg/goacc/array-with-dt-1.f90 but run with -O0. Update
dg-warning for 'may be used uninitialized'.
* gfortran.dg/goacc/pr93464-2.f90: Likewise; copied from
gfortran.dg/goacc/pr93464.f90.
GCC Administrator [Fri, 11 Mar 2022 00:16:39 +0000 (00:16 +0000)]
Daily bump.
Roger Sayle [Thu, 10 Mar 2022 23:49:15 +0000 (23:49 +0000)]
PR c++/84964: Middle-end patch to expand_call for ICE after sorry.
This patch resolves PR c++/84969 which is an ICE in the middle-end after
emitting a "sorry, unimplemented" message, and is a regression from
earlier releases of GCC. This issue is that after encountering a
function call requiring an unreasonable amount of stack space, the
code continues and falls foul of an assert checking that stack pointer
has been correctly updated. The fix is to (locally) consider aborted
function calls as "no return", which skips this downstream sanity check.
2022-03-10 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR c++/84964
* calls.cc (expand_call): Ignore stack adjustments after sorry.
gcc/testsuite/ChangeLog
PR c++/84964
* g++.dg/other/pr84964.C: New test case.
Jonathan Wakely [Thu, 10 Mar 2022 21:13:20 +0000 (21:13 +0000)]
libstdc++: Do not use fast_float for 16-bit size_t [PR104870]
The preprocessor condition for using fast_float should match the one in
the header, and require at least 32-bit size_t.
libstdc++-v3/ChangeLog:
PR libstdc++/104870
* src/c++17/floating_from_chars.cc: Check __SIZE_WIDTH__ >= 32
before using fast_float.
David Malcolm [Thu, 10 Mar 2022 21:52:01 +0000 (16:52 -0500)]
analyzer: fix ICE with -fanalyzer-transitivity [PR104863]
gcc/analyzer/ChangeLog:
PR analyzer/104863
* constraint-manager.cc (constraint_manager::add_constraint):
Refresh the EC IDs when adding constraints implied by offsets.
gcc/testsuite/ChangeLog:
PR analyzer/104863
* gcc.dg/analyzer/torture/pr104863.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Vladimir N. Makarov [Thu, 10 Mar 2022 21:16:00 +0000 (16:16 -0500)]
[PR103074] LRA: Check new conflicts when splitting hard reg live range.
Splitting hard register live range can create (artificial)
conflict of the hard register with another pseudo because of simplified
conflict calculation in LRA. We should check such conflict on the next
assignment sub-pass and spill and reassign the pseudo if necessary.
The patch implements this.
gcc/ChangeLog:
PR target/103074
* lra-constraints.cc (split_reg): Set up
check_and_force_assignment_correctness_p when splitting hard
register live range.
gcc/testsuite/ChangeLog:
PR target/103074
* gcc.target/i386/pr103074.c: New.
Detlef Vollmann [Thu, 10 Mar 2022 16:57:25 +0000 (16:57 +0000)]
libstdc++: Move closing brace outside #endif [PR104866]
libstdc++-v3/ChangeLog:
PR libstdc++/104866
* include/bits/this_thread_sleep.h: Fix order of #endif and
closing brace of namespace.
Hafiz Abid Qadeer [Mon, 31 Jan 2022 19:02:14 +0000 (19:02 +0000)]
Fix multiple issue in the testcase allocate-1.f90.
1. Thomas reported in
https://gcc.gnu.org/pipermail/gcc-patches/2022-January/589039.html
that this testcase is randomly failing. The problem was fixed pool
size which was exhausted when there were a lot of threads. Fixed it
by removing pool_size trait which causes default pool size to be used
which should be big enough.
2. Array indices have been changed to check the last element in the
array.
3. Remove a redundant assignment and move some code to better match
C testcase.
libgomp/ChangeLog:
* testsuite/libgomp.fortran/allocate-1.f90: Remove pool_size
trait. Test last index in w and v array. Remove redundant
assignment to V(1). Move alignment checks at the end of
parallel region.
Marek Polacek [Tue, 22 Feb 2022 20:03:34 +0000 (15:03 -0500)]
c++: ->template and implicit typedef [PR104608]
Here we have a forward declaration of Parameter for which we create
an implicit typedef, which is a TYPE_DECL. Then, when looking it up
at template definition time, cp_parser_template_id gets (since r12-6754)
this TYPE_DECL which it can't handle.
This patch defers lookup for TYPE_DECLs that cp_parser_template_id can't
handle, a la r12-6879.
PR c++/104608
gcc/cp/ChangeLog:
* parser.cc (cp_parser_template_name): Repeat lookup of
TYPE_DECLs.
gcc/testsuite/ChangeLog:
* g++.dg/parse/template-keyword3.C: New test.
* g++.dg/parse/template-keyword4.C: New test.
Marek Polacek [Wed, 2 Mar 2022 17:12:33 +0000 (12:12 -0500)]
c++: Don't allow type-constraint auto(x) [PR104752]
104752 points out that
template<class T>
concept C = true;
auto y = C auto(1);
is ill-formed as per [dcl.type.auto.deduct]: "For an explicit type conversion,
T is the specified type, which shall be auto." which doesn't allow
type-constraint auto.
PR c++/104752
gcc/cp/ChangeLog:
* semantics.cc (finish_compound_literal): Disallow auto{x} for
is_constrained_auto.
* typeck2.cc (build_functional_cast_1): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/auto-fncast12.C: New test.
Marek Polacek [Wed, 9 Mar 2022 16:23:15 +0000 (11:23 -0500)]
c++: ICE with operator delete [PR104846]
This is an ICE-on-invalid with "auto operator delete[] (void *)" whose
return type must be void. The return type is checked in coerce_delete_type
but we never got there in this test, because we took the wrong path in
grokdeclarator, set type to error_mark_node, ended up creating a FIELD_DECL
with build_decl, and confused grokmethod by giving it a FIELD_DECL.
Fixed by not taking the data member path for a FUNCTION_TYPE.
PR c++/104846
gcc/cp/ChangeLog:
* decl.cc (grokdeclarator): Check FUNC_OR_METHOD_TYPE_P before giving
data member errors.
gcc/testsuite/ChangeLog:
* g++.dg/init/delete5.C: New test.
Jakub Jelinek [Thu, 10 Mar 2022 14:28:20 +0000 (15:28 +0100)]
c++: allow variadic operator[] for C++23 [PR103460]
wg21.link/p2128 removed "with exactly one parameter" from over.sub
section. grok_op_properties has for that the last 2 lines in:
case OVL_OP_FLAG_BINARY:
if (arity != 2)
{
if (operator_code == ARRAY_REF && cxx_dialect >= cxx23)
break;
but unfortunately it isn't enough, we reject variadic operator[]
earlier. The following patch accepts variadic operator[] for C++23
too.
2022-03-10 Jakub Jelinek <jakub@redhat.com>
PR c++/103460
* decl.cc (grok_op_properties): Allow variadic operator[] for
C++23.
* g++.dg/cpp23/subscript7.C: New test.
Jonathan Wakely [Thu, 10 Mar 2022 14:17:03 +0000 (14:17 +0000)]
libstdc++: Fix std::strong_order to handle NaN on VAX
I mistakenly believed that VAX floats do not support NaN, but with GCC
__builtin_isnan(__builtin_nan("")) is true. That means my previous
change to <compare> is wrong, because it fails to handle NaN.
When std::numeric_limits<floating-point-type>::is_iec559 is false, as on
VAX, the standard only requires an ordering that is consistent with the
ordering observed by comparison operators. With this change the ordering
is -NaN < numbers < +NaN, and there is no support for different NaN bit
patterns (as I'm not even sure if GCC supports any for VAX).
libstdc++-v3/ChangeLog:
* libsupc++/compare (_Strong_order::_S_fp_cmp) [__vax__]:
Handle NaN.
David Malcolm [Thu, 10 Mar 2022 14:09:40 +0000 (09:09 -0500)]
analyzer: add notes to write-to-const/string from access attr [PR104793]
The previous patch extended
-Wanalyzer-write-to-const
-Wanalyzer-write-to-string-literal
to make use of __attribute__ ((access, ....), but the results could be
inscrutable.
This patch adds notes to such diagnostics to give the user a reason for
why the analyzer is complaining.
Example output:
test.c: In function 'main':
test.c:15:13: warning: write to string literal [-Wanalyzer-write-to-string-literal]
15 | if (getrandom((char *)test, sizeof(buf), GRND_RANDOM))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'main': event 1
|
| 15 | if (getrandom((char *)test, sizeof(buf), GRND_RANDOM))
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | (1) write to string literal here
|
test.c:3:5: note: parameter 1 of 'getrandom' marked with attribute 'access (write_only, 1, 2)'
3 | int getrandom (void *__buffer, size_t __length,
| ^~~~~~~~~
Unfortunately we don't have location information for the attributes
themselves, just the function declaration, and there doesn't seem to be
a good way of getting at the location of the individual parameters from
the middle end (the C and C++ FEs both have get_fndecl_argument_location,
but the implementations are different).
gcc/analyzer/ChangeLog:
PR analyzer/104793
* analyzer.h (class pending_note): New forward decl.
* diagnostic-manager.cc (saved_diagnostic::saved_diagnostic):
Initialize m_notes.
(saved_diagnostic::operator==): Compare m_notes.
(saved_diagnostic::add_note): New.
(saved_diagnostic::emit_any_notes): New.
(diagnostic_manager::add_note): New.
(diagnostic_manager::emit_saved_diagnostic): Call emit_any_notes
after emitting the warning.
* diagnostic-manager.h (saved_diagnostic::add_note): New decl.
(saved_diagnostic::emit_any_notes): New decl.
(saved_diagnostic::m_notes): New field.
(diagnostic_manager::add_note): New decl.
* engine.cc (impl_region_model_context::add_note): New.
* exploded-graph.h (impl_region_model_context::add_note): New
decl.
* pending-diagnostic.h (class pending_note): New.
(class pending_note_subclass): New template.
* region-model.cc (class reason_attr_access): New.
(check_external_function_for_access_attr): Add class
annotating_ctxt and use it when checking region.
(noop_region_model_context::add_note): New.
* region-model.h (region_model_context::add_note): New vfunc.
(noop_region_model_context::add_note): New decl.
(class region_model_context_decorator): New.
(class note_adding_context): New.
gcc/testsuite/ChangeLog:
PR analyzer/104793
* gcc.dg/analyzer/write-to-const-2.c: Add dg-message directives
for expected notes.
* gcc.dg/analyzer/write-to-function-1.c: Likewise.
* gcc.dg/analyzer/write-to-string-literal-2.c: Likewise.
* gcc.dg/analyzer/write-to-string-literal-3.c: Likewise.
* gcc.dg/analyzer/write-to-string-literal-4.c: Likewise.
* gcc.dg/analyzer/write-to-string-literal-5.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Thu, 10 Mar 2022 14:04:03 +0000 (09:04 -0500)]
analyzer: check for writes to consts via access attr [PR104793]
This patch extends:
-Wanalyzer-write-to-const
-Wanalyzer-write-to-string-literal
so that they will check for __attribute__ ((access, ....) on calls to
externally-defined functions, and complain about read-only regions
pointed to by arguments marked with a "write_only" or "read_write"
attribute.
gcc/analyzer/ChangeLog:
PR analyzer/104793
* region-model.cc
(region_model::check_external_function_for_access_attr): New.
(region_model::handle_unrecognized_call): Call it.
* region-model.h
(region_model::check_external_function_for_access_attr): New decl.
(region_model::handle_unrecognized_call): New decl.
gcc/testsuite/ChangeLog:
PR analyzer/104793
* gcc.dg/analyzer/write-to-const-2.c: New test.
* gcc.dg/analyzer/write-to-function-1.c: New test.
* gcc.dg/analyzer/write-to-string-literal-2.c: New test.
* gcc.dg/analyzer/write-to-string-literal-3.c: New test.
* gcc.dg/analyzer/write-to-string-literal-4.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Thu, 10 Mar 2022 14:02:18 +0000 (09:02 -0500)]
analyzer: fix duplicates in check_for_tainted_size_arg
gcc/analyzer/ChangeLog:
* sm-taint.cc (taint_state_machine::check_for_tainted_size_arg):
Avoid generating duplicate saved_diagnostics by only handling the
rdwr_map entry for the ptrarg, not the duplicate entry for the
sizarg.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/taint-size-access-attr-1.c: Add
-fanalyzer-show-duplicate-count to options; verify that a
duplicate was not created for the tainted size.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Martin Jambor [Thu, 10 Mar 2022 13:49:23 +0000 (14:49 +0100)]
ipa-cp: Avoid adjusting references through self-recursion (PR 104813)
When writing the patch that downgrades address-taken references to
load references when IPA-CP can prove that all uses of the taken
address ends up in loads, I unfortunately did not take into account
that find_more_scalar_values_for_callers_subset now happily adds
self-recursive edges to the set of callers which should be immediately
redirected (originally recursion was meant to be handled as edge
redirection in a second pass over the SCC).
The code as it is can now decrement the referece counters too many
times. This can remedied by removing self-recursive edges earlier, we
already do it because of thunk expansion issues, and so this patch
does exactly that.
gcc/ChangeLog:
2022-03-07 Martin Jambor <mjambor@suse.cz>
PR ipa/104813
* ipa-cp.cc (create_specialized_node): Move removal of
self-recursive calls from callers vector before refrence
adjustments.
gcc/testsuite/ChangeLog:
2022-03-07 Martin Jambor <mjambor@suse.cz>
PR ipa/104813
* gcc.dg/ipa/pr104813.c: New test.
Richard Biener [Thu, 10 Mar 2022 12:43:19 +0000 (13:43 +0100)]
tree-optimization/102943 - use tree form for sbr_sparse_bitmap
The following arranges to remove an indirection do the bitvector
in sbr_sparse_bitmap by embedding bitmap_head instead of bitmap
and using the tree form (since we only ever set/query individual
aligned bit chunks). That shaves off 6 seconds from 70 seconds
of the slowest 521.wrf_r LRANS unit build.
2022-03-10 Richard Biener <rguenther@suse.de>
PR tree-optimization/102943
* gimple-range-cache.cc (sbr_sparse_bitmap::bitvec):
Make a bitmap_head.
(sbr_sparse_bitmap::sbr_sparse_bitmap): Adjust and switch
to tree view.
(sbr_sparse_bitmap::set_bb_range): Adjust.
(sbr_sparse_bitmap::get_bb_range): Likewise.