libstdc++-v3/ChangeLog:
PR libstdc++/104032
* include/std/spanstream (basic_spanbuf(basic_spanbuf&&)): Use
mem-initializer for _M_buf.
(basic_spanbuf::Operator=(basic_spanbuf&&)): Fix ill-formed
member access.
* testsuite/27_io/spanstream/2.cc: New test.
We can use the new from_chars implementation when long double and double
have the same representation.
libstdc++-v3/ChangeLog:
* src/c++17/floating_from_chars.cc (USE_STRTOD_FOR_FROM_CHARS):
Define macro for case where std::from_chars is implemented in
terms of strtod, strtof or strtold.
(buffer_resource, valid_fmt, find_end_of_float, pattern)
(from_chars_impl, make_result, reserve_string): Do not define
unless USE_STRTOD_FOR_FROM_CHARS is defined.
(from_chars): Define when at least one of USE_LIB_FAST_FLOAT and
USE_STRTOD_FOR_FROM_CHARS is defined, instead of
_GLIBCXX_HAVE_USELOCALE. Use fast_float for long double when it
is binary64.
I broke this unintentionally in r12-4259.
libstdc++-v3/ChangeLog:
PR libstdc++/104174
* include/bits/hashtable_policy.h (_Map_base): Add partial
specialization for maps with const key types.
* testsuite/23_containers/unordered_map/104174.cc: New test.
The non-atomic store that sets both reference counts to zero uses a
type-punned pointer, which has undefined behaviour. We could use memset
to write 8 bytes, but we don't actually need it to be a single store
anyway. No other thread can observe the values, that's why it's safe to
use non-atomic stores in the first place. So we can just set each count
to zero.
With -fstore-merging (which is enabled by default at -O2) GCC produces
the same code for this as for memset or the type punned store. Clang
does that store merging even at -O1.
libstdc++-v3/ChangeLog:
PR libstdc++/104019
* include/bits/shared_ptr_base.h (_Sp_counted_base<>::_M_release):
Set members to zero without type punning.
There are two underlying bugs in the designated initialization of char array
fields by string literals that cause:
(1) Rejection of valid cases with:
(a) brace-enclosed string literal initializer (of any valid size), or
(b) unbraced string literal shorter than the target char array field.
(2) Acceptance of invalid cases with designators appearing within the braces
of a braced string literal, in which case the bogus 'designator' was
being entirely ignored and the string literal treated as a positional
initializer.
The fixes above allow to address a FIXME in cp_complete_array_type:
/* FIXME: this code is duplicated from reshape_init.
Probably we should just call reshape_init here? */
I believe that this was obstructed by the designator bugs (see comment here
https://patchwork.ozlabs.org/project/gcc/list/?series=199783)
PR c++/55227
gcc/cp/ChangeLog:
* decl.cc (reshape_init_r): Only call has_designator_check when
first_initializer_p or for the inner constructor element.
(cp_complete_array_type): Call reshape_init on braced-init-list.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/desig21.C: New test.
This is a simple patch which simplifies the __builtin_aarch64_sqrt* builtins
into the internal function SQRT which allows for constant folding and other
optimizations at the gimple level. It was originally suggested we do to
__builtin_sqrt just for __builtin_aarch64_sqrtdf when -fno-math-errno
but since r6-4969-g686ee9719a4 we have the internal function SQRT which does
the same so it makes we don't need to check -fno-math-errno either now.
Applied as approved after bootstrapped and tested on aarch64-linux-gnu with no regressions.
PR target/64821
gcc/ChangeLog:
* config/aarch64/aarch64-builtins.cc
(aarch64_general_gimple_fold_builtin): Handle
__builtin_aarch64_sqrt* and simplify into SQRT internal
function.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/vsqrt-1.c: New test.
* gcc.target/aarch64/vsqrt-2.c: New test.
This is the same issue as PR104031, but that patch doesn't fix this
testcase because in this case, current_function_decl isn't set when we get
to cp_genericize_target_expr. But there seems to be no need for
is_local_temp to check for function scope; !TREE_STATIC should be enough.
PR c++/104182
gcc/cp/ChangeLog:
* cp-gimplify.cc (cp_genericize_target_expr): Make sure nothing
has set DECL_INITIAL on a TARGET_EXPR slot.
* tree.cc (is_local_temp): Don't check DECL_CONTEXT.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist127.C: New test.
We've been trying for a while to avoid TARGET_EXPRs in template code, but
there were still a few that snuck through, and the one in this case broke
the code that tried to handle it. Fixed by using IMPLICIT_CONV_EXPR, as we
have done elsewhere.
I also noticed that finish_compound_literal was assuming that all T{init}
were for aggregate T, and we got a few more TARGET_EXPRs from that. Fixed
by only messing with TARGET_EXPR if we actually have an aggregate init.
PR c++/101072
gcc/cp/ChangeLog:
* cp-tree.h (build_implicit_conv_flags): Declare.
* call.cc (build_implicit_conv_flags): Split out from...
(perform_implicit_conversion_flags): ...here.
* decl.cc (check_initializer): Use it.
* pt.cc (tsubst_copy_and_build): Remove TARGET_EXPR handling.
* semantics.cc (finish_compound_literal): Don't treat
scalar values like CONSTRUCTORs.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/constexpr-empty14a.C: New test.
With --disable-plugin, bootstrap fails on x86_64-linux or probably
all other targets with:
../../gcc/opts-global.cc: In function ‘void handle_common_deferred_options()’:
../../gcc/opts-global.cc:420:62: error: unquoted option name ‘--enable-plugin’ in format [-Werror=format-diag]
420 | error ("plugin support is disabled; configure with --enable-plugin");
| ^~~~~~~~~~~~~~~
../../gcc/opts-global.cc:428:62: error: unquoted option name ‘--enable-plugin’ in format [-Werror=format-diag]
428 | error ("plugin support is disabled; configure with --enable-plugin");
| ^~~~~~~~~~~~~~~
The following patch fixes that.
2022-01-22 Jakub Jelinek <jakub@redhat.com>
PR other/104176
* opts-global.cc (handle_common_deferred_options): Quote
--enable-plugin in diagnostics to avoid -Werror=format-diag.
PR analyzer/104159 describes an ICE attempting to convert a vector_cst,
which occurs when symbolically executing within a recursive call on:
_4 = BIT_FIELD_REF <w_3(D), 32, 0>;
_1 = VIEW_CONVERT_EXPR<T>(_4);
where the BIT_FIELD_REF leads to a get_or_create_cast from
VEC<long, 8> to VEC<unsigned 4>
which get_code_for_cast erroneously picks NOP_EXPR for the cast, leading
to a bogus input to the VIEW_CONVERT_EXPR.
This patch fixes the issue by giving up on attempts to cast symbolic
values of vector types, treating the result of such casts as unknowable.
gcc/analyzer/ChangeLog:
PR analyzer/104159
* region-model-manager.cc
(region_model_manager::get_or_create_cast): Bail out if the types
are the same. Don't attempt to handle casts involving vector
types.
gcc/testsuite/ChangeLog:
PR analyzer/104159
* gcc.dg/analyzer/torture/pr104159.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/fortran/ChangeLog:
PR fortran/104127
* simplify.cc (gfc_simplify_transfer): Ensure that the result
typespec is set up for TRANSFER with MOLD of type CHARACTER
including character length even if the result is a zero-sized
array.
gcc/testsuite/ChangeLog:
PR fortran/104127
* gfortran.dg/transfer_simplify_11.f90: Fix logic.
* gfortran.dg/transfer_simplify_13.f90: New test.
This has been added in r12-6342-ge7a7dbb5ca5dd69689f1a probably
by accident.
2022-01-22 Jakub Jelinek <jakub@redhat.com>
PR other/104181
* build.log: Remove.
When I added support for generating XXSPLTIDP on December 15th, 2021, I
missed updating the fold-vec-splat-floatdouble.c test to add to the regex
for the instructions generated. This patch fixes that.
2022-01-20 Michael Meissner <meissner@the-meissners.org>
gcc/testsuite/
PR testsuite/103763
* gcc.target/powerpc/fold-vec-splat-floatdouble.c: Fix insn regex
on power10.
If you compile module_advect_em.F90 with -Ofast -mcpu=power10, one module
is large enough that we can't use a single conditional jump to span the
function. Instead, GCC has to reverse the condition, and do a conditional
jump around an unconditional branch. It turns out when xxspltiw and
xxspltdp instructions were generated, they were not marked as being
prefixed (i.e. length of 12 bytes instead of 4 bytes). This meant the
calculations for the branch length were off, which in turn meant the
assembler raised an error because it couldn't do the conditional jump.
The fix is to explicitly set the prefixed attribute when we are loading up
vector constants with the xxspltiw or xxspltidp instructions.
I have removed the code that sets the prefixed attribute for xxspltiw,
xxspltidp, and xxsplti32dx instructions, since it no longer will be invoked.
I have also explicitly set the prefixed attribute for load SF and DF mode
constants with xxsplitw and xxspltidp. Previously, it was not set on these
insns, but when the insn was split to get the XXSPLTIW/XXSPLTIDP forms, those
forms already had the prefixed attribute set.
2022-01-21 Michael Meissner <meissner@the-meissners.org>
gcc/
PR target/104136
* config/rs6000/rs6000-protos.h (prefixed_xxsplti_p): Delete.
* config/rs6000/rs6000.cc (prefixed_xxsplti_p): Delete.
* config/rs6000/rs6000.md (prefixed attribute): Delete section
that sets the prefixed attribute for xxspltiw, xxspltidp, and
xxsplti32dx instructions.
(movsf_hardfloat): Explicitly set the prefixed attribute
when xxspltiw and xxspltidp instructions are generated.
(mov<mode>_hardfloat32): Likewise.
(mov<mode>_hardfloat64): Likewise.
* config/rs6000/vsx.md (vsx_mov<mode>_64bit): Explicitly set the
prefixed attribute for xxspltiw and xxspltidp instructions.
(vsx_mov<mode>_32bit): Likewise.
Revert x86 changes in
commit c163647ffb
Author: Soren Tempel <soeren@soeren-tempel.net>
Date: Fri Jan 21 19:22:46 2022 +0000
Disable -fsplit-stack support on non-glibc targets
and change ix86_supports_split_stack to return true only on glibc.
PR bootstrap/104170
* common/config/i386/i386-common.cc (ix86_supports_split_stack):
Return true only on glibc.
* config/i386/gnu-user-common.h (STACK_CHECK_STATIC_BUILTIN):
Revert commit c163647ffb.
* config/i386/gnu.h (TARGET_LIBC_PROVIDES_SSP): Likewise.
As can be seen on the testcase, GCC 11 no longer warns if the format
string is wrapped inside of ()s.
This regressed with r11-2457-gdf5cf47a978, which added
if (TREE_NO_WARNING (param)) return;
to check_function_arguments_recurse. That function is used with a callback
for two cases, for -Wformat and for -Wnonnull. For the latter it is
desirable to not warn in parameters or their subexpressions where that
warning is suppressed, but for -Wformat the function is used solely
to discover the string literals if any so that the c-format.cc code can
diagnose them. I believe no warning suppression should stand in the
way of that, -Wformat* warnings should be decided from warning suppression
on the CALL_EXPR only.
In the PR Martin argued that now that we have specialized
warning_suppressed_p we should use it, so instead of adding a bool
arg to check_function_arguments_recurse I've added opt_code to the
function, but will defer the warning_suppressed_p change to him.
For OPT_Wformat_ we don't want to call it anyway at all (as I said,
I think there should be no suppression for it during the string discovery,
there isn't just one -Wformat= option, there are many and
warning_suppression_p even with no_warnings actually tests the
TREE_NO_WARNING bit).
Initially, I thought I'd restrict also call to fn with format_arg attribute
handling in check_function_arguments_recurse to OPT_Wformat_ only, but
after looking around, it perhaps is intentional that way, most functions
with format_arg attribute don't have nonnull attribute for that arg too,
various gettext implementations handle NULL argument by passing it through,
but when result of gettext (NULL) etc. is passed to non-NULL argument, it
makes sense to warn.
2022-01-21 Jakub Jelinek <jakub@redhat.com>
PR c++/104148
* c-common.h (check_function_arguments_recurse): Add for_format
arg.
* c-common.cc (check_function_nonnull): Pass false to
check_function_arguments_recurse's last argument.
(check_function_arguments_recurse): Add for_format argument,
if true, don't stop on warning_suppressed_p.
* c-format.cc (check_format_info): Pass true to
check_function_arguments_recurse's last argument.
* c-c++-common/Wformat-pr104148.c: New test.
While looking at another bug I wanted the compiler to tell me what the two
unequal values were.
gcc/cp/ChangeLog:
* semantics.cc (find_failing_clause): Return expr if not
decomposable.
(finish_static_assert): Show constant values in failing
comparison.
gcc/testsuite/ChangeLog:
* g++.dg/template/explicit-args6.C: Add expected message.
My patch for PR20040 made us stop exiting early from build_new_1 in
cases of trivial initialization if there's a class operator delete; as a
result, code later in the function needs to handle this case properly.
PR c++/104084
PR c++/20040
gcc/cp/ChangeLog:
* init.cc (build_new_1): Only pull out TARGET_EXPR_INITIAL if
alloc_expr is a TARGET_EXPR.
gcc/testsuite/ChangeLog:
* g++.dg/init/new50.C: New test.
The -fsplit-stack option requires the pthread_t TCB definition in the
libc to provide certain struct fields at specific hardcoded offsets. As
far as I know, only glibc provides these fields at the required offsets.
Most notably, musl libc does not have these fields. However, since gcc
accesses the fields using a fixed offset, this does not cause a
compile-time error, but instead results in a silent memory corruption at
run-time with musl libc. For example, on s390x libgcc's
__stack_split_initialize CTOR will overwrite the cancel field in the
pthread_t TCB on musl.
The -fsplit-stack option is used within the gcc code base itself by
gcc-go (if available). On musl-based systems with split-stack support
(i.e. s390x or x86) this causes Go programs compiled with gcc-go to
misbehave at run-time.
This patch fixes gcc-go on musl by disabling -fsplit-stack in gcc itself
since it is not supported on non-glibc targets anyhow. This is achieved
by checking if gcc targets a glibc-based system. This check has been
added for x86 and s390x, the rs6000 config already checks for
TARGET_GLIBC_MAJOR. Other architectures do not have split-stack
support. With this patch applied, the gcc-go configure script will
detect that -fsplit-stack support is not available and will not use it.
See https://www.openwall.com/lists/musl/2012/10/16/12
This patch was written under the assumption that glibc is the only libc
implementation which supports the required fields at the required
offsets in the pthread_t TCB. The patch has been tested on Alpine Linux
Edge on the s390x and x86 architectures by bootstrapping Google's Go
implementation with gcc-go.
Signed-off-by: Sören Tempel <soeren@soeren-tempel.net>
gcc/ChangeLog:
* common/config/s390/s390-common.cc (s390_supports_split_stack):
Only support split-stack on glibc targets.
* config/i386/gnu-user-common.h (STACK_CHECK_STATIC_BUILTIN): Ditto.
* config/i386/gnu.h (defined): Ditto.
Fix a compilation issue in stage2 bootstrap. Fixed as obvious (re:
discussion with Bill Schmidt).
2022-01-21 Bill Seurer <seurer@gcc.gnu.org>
gcc/
* config/rs6000/rs6000.cc (rs6000_get_function_versions_dispatcher):
Fix mention of ifunc in string.
This patch resolves the P1 "ice-on-valid-code" regression boostrapping
GCC on risv-unknown-linux-gnu caused by my recent MULT_HIGHPART_EXPR
functionality. RISC-V differs from x86_64 and many targets by
supporting a usmusidi3 instruction, basically a widening multiply
where one operand is signed and the other is unsigned. Alas the
final version of my patch to recognize MULT_HIGHPART_EXPR didn't
sufficiently defend against the operands of WIDEN_MULT_EXPR having
different signedness. This is fixed by the two-line change to
tree-ssa-math-opts.cc's convert_mult_to_highpart in the patch below.
The majority of the rest of the patch is to the documentation
(in tree.def and generic.texi). It turns out that WIDEN_MULT_EXPR
wasn't previously documented in generic.texi, let alone the slightly
unusual semantics of allowing mismatched (signed vs unsigned) operands.
This also clarifies that MULT_HIGHPART_EXPR currently requires the
signedness of operands to match [but this might change in a future
release of GCC to support targets with usmul<mode>3_highpart].
The one final chunk of this patch (that is hopefully sufficiently
close to obvious for stage 4) is a similar (NULL pointer) sanity
check in riscv_cpu_cpp_builtins. Currently running cc1 from the
command line (or from gdb) without specifying -march results in a
segmentation fault (ICE). This is a minor annoyance tracking down
issues (in cross compilers) for riscv, and trivially fixed as below.
2022-01-22 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
PR middle-end/104140
* tree-ssa-math-opts.cc (convert_mult_to_highpart): Check that the
operands of the widening multiplication are either both signed or
both unsigned, and abort the conversion if mismatched.
* doc/generic.texi (WIDEN_MULT_EXPR): Describe expression node.
(MULT_HIGHPART_EXPR): Clarify that operands must have the same
signedness.
* tree.def (MULT_HIGHPART_EXPR): Document both operands must have
integer types with the same precision and signedness.
(WIDEN_MULT_EXPR): Document that operands must have integer types
with the same precision, but possibly differing signedness.
* config/riscv/riscv-c.cc (riscv_cpu_cpp_builtins): Defend against
riscv_current_subset_list returning a NULL pointer (empty list).
gcc/testsuite/ChangeLog
PR middle-end/104140
* gcc.target/riscv/pr104140.c: New test case.
LRA and old reload pass uses only one register class for reload pseudos even if
operand constraints contain more one register class. Let us consider
constraint 'lh' for thumb arm which means low and high thumb registers.
Reload pseudo for such constraint will have general reg class (union of
low and high reg classes). Assigning the last low register to the reload
pseudo is wrong if the pseudo is of DImode as it requires two hard regs.
But it is considered OK if we use general reg class. The following patch
solves this problem for LRA.
gcc/ChangeLog:
PR target/103676
* ira.h (struct target_ira): Add member
x_ira_exclude_class_mode_regs.
(ira_exclude_class_mode_regs): New macro.
* lra.h (lra_create_new_reg): Add arg exclude_start_hard_regs and
move from here ...
* lra-int.h: ... to here.
(lra_create_new_reg_with_unique_value): Add arg
exclude_start_hard_regs.
(class lra_reg): Add member exclude_start_hard_regs.
* lra-assigns.cc (find_hard_regno_for_1): Setup
impossible_start_hard_regs from exclude_start_hard_regs.
* lra-constraints.cc (get_reload_reg): Add arg exclude_start_hard_regs and pass
it lra_create_new_reg[_with_unique_value].
(match_reload): Ditto.
(check_and_process_move): Pass NULL
exclude_start_hard_regs to lra_create_new_reg_with_unique_value.
(goal_alt_exclude_start_hard_regs): New static variable.
(process_addr_reg, simplify_operand_subreg): Pass NULL
exclude_start_hard_regs to lra_create_new_reg_with_unique_value
and get_reload_reg.
(process_alt_operands): Setup goal_alt_exclude_start_hard_regs.
Use this_alternative_exclude_start_hard_regs additionally to find
winning operand alternative.
(base_to_reg, base_plus_disp_to_reg, index_part_to_reg): Pass NULL
exclude_start_hard_regs to lra_create_new_reg.
(process_address_1, emit_inc): Ditto.
(curr_insn_transform): Pass exclude_start_hard_regs value to
lra_create_new_reg, get_reload_reg, match_reload.
(inherit_reload_reg, split_reg): Pass NULL exclude_start_hard_regs
to lra_create_new_reg.
(process_invariant_for_inheritance): Ditto.
* lra-remat.cc (update_scratch_ops): Ditto.
* lra.cc (lra_create_new_reg_with_unique_value): Add arg
exclude_start_hard_regs. Setup the corresponding member of
lra reg info.
(lra_create_new_reg): Add arg exclude_start_hard_regs and pass it
to lra_create_new_reg_with_unique_value.
(initialize_lra_reg_info_element): Initialize member
exclude_start_hard_regs.
(get_scratch_reg): Pass NULL to lra_create_new_reg.
* ira.cc (setup_prohibited_class_mode_regs): Rename to
setup_prohibited_and_exclude_class_mode_regs and calculate
ira_exclude_class_mode_regs.
gcc/testsuite/ChangeLog:
PR target/103676
* g++.target/arm/pr103676.C: New.
This is a "canonical types differ for identical types" ICE, which started
with r11-4682. It's a bit tricky to explain. Consider:
template <typename T> struct S {
S<T> bar() noexcept(T::value); // #1
S<T> foo() noexcept(T::value); // #2
};
template <typename T> S<T> S<T>::foo() noexcept(T::value) {} // #3
We ICE because #3 and #2 have the same type, but their canonical types
differ: TYPE_CANONICAL (#3) == #2 but TYPE_CANONICAL (#2) == #1.
The member functions #1 and #2 have the same type. However, since their
noexcept-specifier is deferred, when parsing them, we create a variant for
both of them, because DEFERRED_PARSE cannot be compared. In other words,
build_cp_fntype_variant's
tree v = TYPE_MAIN_VARIANT (type);
for (; v; v = TYPE_NEXT_VARIANT (v))
if (cp_check_qualified_type (v, type, type_quals, rqual, raises, late))
return v;
will *not* find an existing variant when creating a method_type for #2, so we
have to create a new one.
But then we perform delayed parsing and call fixup_deferred_exception_variants
for #1 and #2. f_d_e_v will replace TYPE_RAISES_EXCEPTIONS with the newly
parsed noexcept-specifier. It also sets TYPE_CANONICAL (#2) to #1. Both
noexcepts turned out to be the same, so now we have two equivalent variants in
the list! I.e.,
+-----------------+ +-----------------+ +-----------------+
| main | | #2 | | #1 |
| S S::<T379>(S*) |----->| S S::<T37c>(S*) |----->| S S::<T37a>(S*) |----->NULL
| - | | noex(T::value) | | noex(T::value) |
+-----------------+ +-----------------+ +-----------------+
Then we get to #3. As for #1 and #2, grokdeclarator calls build_memfn_type,
which ends up calling build_cp_fntype_variant, which will use the loop
above to look for an existing variant. The first one that matches
cp_check_qualified_type will be used, so we use #2 rather than #1, and the
TYPE_CANONICAL mismatch follows. Hopefully that makes sense.
As for the fix, I didn't think I could rewrite the method_type #2 with #1
because the type may have escaped via decltype. So my approach is to
elide #2 from the list, so when looking for a matching variant, we always
find #1 (#2 remains live though, which admittedly sounds sort of dodgy).
PR c++/101715
gcc/cp/ChangeLog:
* tree.cc (fixup_deferred_exception_variants): Remove duplicate
variants after parsing the exception specifications.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/noexcept72.C: New test.
* g++.dg/cpp0x/noexcept73.C: New test.
Rather than rubber-stamp whatever requested vs. actual device kernel launch
configuration happens, actually (again) verify the requested values (modulo
expected variations).
This better highlights that "AMD GCN has an upper limit of 'num_workers(16)'",
and the deficiency that "AMD GCN uses the autovectorizer for the vector
dimension: the use of a function call in vector-partitioned code [...] is not
currently supported".
And, this removes several instances of race conditions, where variables are
concurrently written to in OpenACC gang-redundant mode.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/loop-gwv-1.c: Strengthen.
* testsuite/libgomp.oacc-c-c++-common/loop-gwv-2.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-red-gwv-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-red-v-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-red-v-2.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-red-wv-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-v-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-w-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-wv-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/routine-gwv-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/routine-v-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/routine-w-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/routine-wv-1.c: Likewise.
Fixing a thinko in my patch for 103681: when computing the size of a virtual
base, it would help to use its binfo instead of the one for the derived
class.
PR c++/104139
PR c++/103681
gcc/cp/ChangeLog:
* class.cc (end_of_class): Use base_binfo.
gcc/testsuite/ChangeLog:
* g++.dg/abi/no_unique_address2.C: Adjust to detect this on x86-64.
I changed the preprocessor condition from <= to < in r12-6574 which
meant the macro was not defined by <version> for C++17.
libstdc++-v3/ChangeLog:
* include/std/version (__cpp_lib_shared_ptr_arrays): Fix
condition for C++17 definition.
The PR complains that when we only partially BB vectorize an
if-converted loop body that this can leave unvectorized code
unconditionally executed and thus effectively slow down code.
For -O2 we already mitigated the issue by not doing BB vectorization
when not all if-converted stmts were covered but the issue is
present with -O3 as well. Thus the following simply extends the
fix to cover all but the unlimited cost models. It is after all
very likely that we vectorize some stmts, if only a single
paired store.
2022-01-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/100089
* tree-vect-slp.cc (vect_slp_region): Reject BB vectorization
of if-converted loops with unvectorized COND_EXPRs for
all but the unlimited cost models.
The testcase got fixed by lowering of &MEM[ptr + CST] to ptr + CST.
2022-01-21 Richard Biener <rguenther@suse.de>
PR sanitizer/99673
* gcc.dg/asan/pr99673.c: New testcase.
Add support for accessing the stack canary value via the TLS register,
so that multiple threads running in the same address space can use
distinct canary values. This is intended for the Linux kernel running in
SMP mode, where processes entering the kernel are essentially threads
running the same program concurrently: using a global variable for the
canary in that context is problematic because it can never be rotated,
and so the OS is forced to use the same value as long as it remains up.
Using the TLS register to index the stack canary helps with this, as it
allows each CPU to context switch the TLS register along with the rest
of the process, permitting each process to use its own value for the
stack canary.
gcc/ChangeLog:
* config/arm/arm-opts.h (enum stack_protector_guard): New.
* config/arm/arm-protos.h (arm_stack_protect_tls_canary_mem):
New.
* config/arm/arm.cc (TARGET_STACK_PROTECT_GUARD): Define.
(arm_option_override_internal): Handle and put in error checks.
for stack protector guard options.
(arm_option_reconfigure_globals): Likewise.
(arm_stack_protect_tls_canary_mem): New.
(arm_stack_protect_guard): New.
* config/arm/arm.md (stack_protect_set): New.
(stack_protect_set_tls): Likewise.
(stack_protect_test): Likewise.
(stack_protect_test_tls): Likewise.
(reload_tp_hard): Likewise.
* config/arm/arm.opt (-mstack-protector-guard): New
(-mstack-protector-guard-offset): New.
* doc/invoke.texi: Document new options.
gcc/testsuite/ChangeLog:
* gcc.target/arm/stack-protector-7.c: New test.
* gcc.target/arm/stack-protector-8.c: New test.
When hoisting guards the unswitching pass does not properly ignore
debug stmts when looking for uses outside of the loop of defs
produced in the skipped region. The following rectifies this
by instead collecting them and resetting them after the transform.
2022-01-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/104156
* tree-ssa-loop-unswitch.cc (tree_unswitch_outer_loop):
Collect and reset debug stmts with out-of-loop uses when
hoisting guards.
(find_loop_guard): Adjust.
(empty_bb_without_guard_p): Likewise. Ignore debug stmts.
(used_outside_loop_p): Push debug uses to a vector of
debug stmts to reset.
(hoist_guard): Adjust -fopt-info category.
* gcc.dg/loop-unswitch-6.c: New testcase.
This adds a missing check to verify we can actually build an
invariant vector from components when SLP vectorizing an associatable
chain.
2022-01-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/104152
* tree-vect-slp.cc (vect_build_slp_tree_2): Add missing
can_duplicate_and_interleave_p check.
* gcc.dg/vect/pr104152.c: New testcase.
A warning regression fix I'm about to post warns (and breaks bootstrap due
to that) on the following spot. Seems it is a copy and paste from
earlier code that mentions the %qD variable instead of talking about
unnamed temporary.
2022-01-21 Jakub Jelinek <jakub@redhat.com>
* gimple-ssa-warn-access.cc (pass_waccess::warn_invalid_pointer):
Avoid passing var to warning_at when the format string doesn't
refer to it.
As discussed in PR103721, the problem here is that we are crossing a
backedge and causing us to use relations from a previous iteration of a
loop.
This handles the testcases in both PR103721 and PR104067 which are variants
of the same thing.
Tested on x86-64 Linux with the usual regstrap as well as verifying the
thread count before and after the patch. The number of threads is
reduced by a miniscule amount.
gcc/ChangeLog:
PR tree-optimization/103721
* gimple-range-path.cc
(path_range_query::relations_may_be_invalidated): New.
(path_range_query::compute_ranges_in_block): Reset relations if
they may be invalidated.
(path_range_query::maybe_register_phi_relation): Exit if relations
may be invalidated on incoming edge.
(path_range_query::compute_phi_relations): Pass incoming PHI edge
to maybe_register_phi_relation.
* gimple-range-path.h (relations_may_be_invalidated): New.
(maybe_register_phi_relation): Pass edge instead of tree.
* tree-ssa-threadbackward.cc (back_threader::back_threader):
Mark DFS edges.
* value-relation.cc (path_oracle::path_oracle): Call
mark_dfs_back_edges.
(path_oracle::register_relation): Add SSA names to m_registered
bitmap.
(path_oracle::reset_path): Clear m_registered bitmap.
* value-relation.h (path_oracle::set_root_oracle): New.
gcc/testsuite/ChangeLog:
* gcc.dg/pr103721-2.c: New test.
* gcc.dg/pr103721.c: New test.
cond traps can be created during ce3 after reload (and e.g. PR103028
recently fixed some ce3 cond trap related bug, so I think often that
works fine and we shouldn't disable cond traps after RA altogether),
but it calls prepare_cmp_insn. This function can fail, so I don't
see why we couldn't make it work after RA (in most cases it already
just works). The first hunk is just an optimization which doesn't
make sense after RA, so I've guarded it with can_create_pseudo_p.
The second hunk is just a theoretical case, I don't have a testcase for it.
prepare_cmp_insn has some other spots that can create pseudos, like when
both operands have VOIDmode, or when it is BLKmode comparison, or
not OPTAB_DIRECT, but I think none of that applies to ce3, we punt on
BLKmode earlier, use OPTAB_DIRECT and shouldn't be comparing two
VOIDmode CONST_INTs.
2022-01-21 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/102478
* optabs.cc (prepare_cmp_insn): If !can_create_pseudo_p (), don't
force_reg constants and for -fnon-call-exceptions fail if copy_to_reg
would be needed.
* gcc.dg/pr102478.c: New test.
The recent multiply-highpart work twiddled code generation on the MIPS targets
and is causing mips.exp failures.
The resultant code is actually better and matches a comment in the test files
which indicates that it would be better to generate a mult-highpart. So I'm
pretty confident in removing the undesired mflo & changing the name of the
target pattern we expect to see.
This fixes the mips64 and mips64el failures in my tester. I suspect it'll
also fix the failures on mipsisa32, but that target is bootstrapped with qemu --
which takes forever so it only runs once a week ;-)
gcc/testsuite
* gcc.target/mips/fix-r4000-2.c: Update expected output.
* gcc.target/mips/fix-r4000-3.c: Update expected output. Add
-fexpensive-optimizations for consistency in output.
* gcc.target/mips/fix-r4000-7.c: Update expected output.
* gcc.target/mips/fix-r4000-8.c: Update expected output.
PR analyzer/94362 reports a false positive from
-Wanalyzer-null-dereference seen when analyzing OpenSSL.
The root cause is that the analyzer's path feasibility checker
erroneously considers this to be feasible:
(R + 1 > 0) && (R < 0)
for int R (the return value from sk_EVP_PKEY_ASN1_METHOD_num),
whereas it's not satisfiable for any int R.
This patch makes the constraint manager try harder to reject
such combinations of conditions, fixing the false positive;
perhaps in the longer term we ought to use an SMT solver.
gcc/analyzer/ChangeLog:
PR analyzer/94362
* constraint-manager.cc (bound::ensure_closed): Convert param to
enum bound_kind.
(range::constrained_to_single_element): Likewise.
(range::add_bound): New.
(constraint_manager::add_constraint): Handle SVAL + OFFSET
compared to a constant.
(constraint_manager::get_ec_bounds): Rewrite in terms of
range::add_bound.
(constraint_manager::eval_condition): Reject if range::add_bound
fails.
(selftest::test_constant_comparisons): Add test coverage for
various impossible combinations of integer comparisons.
* constraint-manager.h (enum bound_kind): New.
(struct bound): Likewise.
(bound::ensure_closed): Convert to param to enum bound_kind.
(struct range): Convert to...
(class range): ...this, making fields private.
(range::add_bound): New decls.
* region-model.cc (region_model::add_constraint): Fail if
constraint_manager::add_constraint fails.
gcc/testsuite/ChangeLog:
PR analyzer/94362
* gcc.dg/analyzer/pr94362-1.c: New test.
* gcc.dg/analyzer/pr94362-2.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
PR analyzer/103685 reports a false positive from -Wanalyzer-null-dereference
seen at -O2 with GCC 11. I can reproduce it with GCC 11, but not with
trunk; this patch adds a reduced test case that reproduces it with
GCC 11 as a regression test for GCC 12 onwards.
gcc/testsuite/ChangeLog:
PR analyzer/103685
* gcc.dg/analyzer/torture/pr103685.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>