Jan Hubicka [Wed, 21 Dec 2022 11:41:25 +0000 (12:41 +0100)]
Make -fwhole-program to work with incremental LTO linking
Update documentation of -fwhole-program which was wrongly
claiming that it is useless with LTO whole it is useful for LTO without plugin
and extends -fwhole-program to also work with incremental linking.
This is useful when building kernel where the incremental link is de-facto fina
binary and only some explicitly marked symbols needs to remain.
Bootstrapped/regtested x86_64-linux, comitted.
gcc/ChangeLog:
2022-12-21 Jan Hubicka <hubicka@ucw.cz>
* doc/invoke.texi: Fix documentation of -fwhole-program with LTO
and document behaviour for incremental linking.
gcc/lto/ChangeLog:
2022-12-21 Jan Hubicka <hubicka@ucw.cz>
* lto-common.cc (lto_resolution_read): With incremental linking
and whole program ignore turn LDPR_PREVAILING_DEF_IRONLY to
LDPR_PREVAILING_DEF_IRONLY_EXP
* lto-lang.cc (lto_post_options): Do not clear flag_whole_program
for incremental link
Jakub Jelinek [Wed, 21 Dec 2022 08:10:35 +0000 (09:10 +0100)]
modula2: Fix lto profiledbootstrap on powerpc64le-linux and s390x-linux [PR108153]
Lto profiledbootstrap was failing for me on {powerpc64le,s390x}-linux with
modula 2 enabled, with:
cc1gm2: internal compiler error: the location value is corrupt
0x11a3d2d m2assert_AssertLocation(unsigned int)
../../gcc/m2/gm2-gcc/m2assert.cc:40
0x11a3d2d m2statement_BuildAssignmentTree
../../gcc/m2/gm2-gcc/m2statement.cc:177
ICE. The problem was that caller (m2assert_AssertLocation used
location_t M2Options_OverrideLocation (location_t);
prototype with the libcpp/line-map.h
typedef unsigned int location_t;
typedef, but the callee defined in Modula 2 was using:
TYPE
location_t = INTEGER ;
and
PROCEDURE OverrideLocation (location: location_t) : location_t ;
Now, on powerpc64le-linux unsigned int is returned and passed zero extended
into 64-bits, while signed int is returned and passed sign-extended into 64-bits
and Modula 2 INTEGER is signed 32-bit type, so when the caller then compared
M2Options_OverrideLocation (location) != location
and powerpc64le-linux performed the comparison as 64-bit compare, there
was a mismatch for location_t of 0x8000007 or others with the MSB set.
Fixed by making Modula 2 location_t a CARDINAL, which is 32-bit unsigned type.
2022-12-21 Jakub Jelinek <jakub@redhat.com>
PR modula2/108153
* gm2-gcc/m2linemap.def (location_t): Use CARDINAL instead of INTEGER.
Jakub Jelinek [Wed, 21 Dec 2022 08:05:27 +0000 (09:05 +0100)]
openmp: Don't try to destruct DECL_OMP_PRIVATIZED_MEMBER vars [PR108180]
DECL_OMP_PRIVATIZED_MEMBER vars are artificial vars with DECL_VALUE_EXPR
of this->field used just during gimplification and omp lowering/expansion
to privatize individual fields in methods when needed.
As the following testcase shows, when not in templates, they were handled
right, but in templates we actually called cp_finish_decl on them and
that can result in their destruction, which is obviously undesirable,
we should only destruct the privatized copies of them created in omp
lowering.
Martin Liska [Wed, 21 Dec 2022 07:52:35 +0000 (08:52 +0100)]
libgccjit: silent 2 Clang warnings
The make silent the following 2 warnings:
jit/jit-playback.h:785:16: warning: private field 'm_source_file' is not used [-Wunused-private-field]
jit/jit-playback.h:804:16: warning: private field 'm_line' is not used [-Wunused-private-field]
Jakub Jelinek [Wed, 21 Dec 2022 08:04:06 +0000 (09:04 +0100)]
libstdc++: Don't call 4-5 argument to_chars with chars_format{}
In Fedora build libstdc++.so is built with assertions enabled and
FAIL: 20_util/to_chars/float128_c++23.cc execution test
was failing on all arches. The problem is that it called 5 argument version
of to_chars with chars_format{}, which C++ says is invalid:
http://eel.is/c++draft/charconv.to.chars#12
Preconditions: fmt has the value of one of the enumerators of chars_format.
The following patch fixes it by skipping the second part of the test
which needs the 5 argument to_chars for chars_format{}, but because
it is strictly speaking invalid also for 4 argument to_chars, it uses
3 argument to_chars instead of 4 argument to_chars with last argument
chars_format{}.
2022-12-21 Jakub Jelinek <jakub@redhat.com>
* testsuite/20_util/to_chars/float16_c++23.cc (test): Use 3 argument
std::to_chars if fmt is std::chars_format{}, rather than 4 argument.
* testsuite/20_util/to_chars/float128_c++23.cc (test): Likewise, and
skip second part of testing that requires 5 argument std::to_chars.
Tobias Burnus [Wed, 21 Dec 2022 07:06:29 +0000 (08:06 +0100)]
gfortran.dg/read_dir.f90: Make PASS on Windows
On non-Cygwin Windows, use '.' and expect the documented fail when opening
a directory (EACCESS). As gfortran does not set __WIN32__ this check is
done on the C side. (On __CYGWIN__, __WIN32__ is not set - but to make it
clear, !__CYGWIN__ is used in #if.)
On non-Windows, replace the 'call system' shell call by the POSIX functions
stat/mkdir/rmdir for better compatibility, especially on embedded systems;
additionally add some more checks. In particular, confirm that 'close' with
status='delete' indeed deleted the directory.
gcc/testsuite/ChangeLog:
* gfortran.dg/read_dir-aux.c: New; provides my_mkdir, my_rmdir,
my_verify_not_exists and expect_open_to_fail.
* gfortran.dg/read_dir.f90: Call those; expect that opening a
directory fails on Windows.
Kewen Lin [Wed, 21 Dec 2022 03:06:15 +0000 (21:06 -0600)]
rs6000: Fix the wrong location of OPTION_MASK_P10_FUSION setting hunk
The hunk for setting flag OPTION_MASK_P10_FUSION locates wrongly
between the if and else if block for OPTION_MASK_MMA. This is
to fix this oversight accordingly.
gcc/ChangeLog:
* config/rs6000/rs6000.cc (rs6000_option_override_internal): Fix the
location for OPTION_MASK_P10_FUSION flag setting.
Kewen Lin [Wed, 21 Dec 2022 03:04:54 +0000 (21:04 -0600)]
fold-const: Treat fp conversion to a type with same mode as copy
In function fold_convert_const_real_from_real, when the modes of
two types involved in fp conversion are the same, we can simply
take it as copy, rebuild with the exactly same TREE_REAL_CST and
the target type. It is more efficient and helps to avoid possible
unexpected signalling bit clearing in [1].
Kewen Lin [Wed, 21 Dec 2022 03:02:08 +0000 (21:02 -0600)]
rs6000: Raise error for __vector_{quad,pair} uses without MMA enabled [PR106736]
As PR106736 shows, it's unexpected to use __vector_quad and
__vector_pair types without MMA support, it would cause ICE
when expanding the corresponding assignment. We can't guard
these built-in types registering under MMA support as Peter
pointed out in that PR, because the registering is global,
it doesn't work for target pragma/attribute support with MMA
enabled. The existing verify_type_context mentioned in [2]
can help to make the diagnostics invalid built-in type uses
better, but as Richard pointed out in [4], it can't deal with
all cases. As the discussions in [1][3], this patch is to
check the invalid use of built-in types __vector_quad and
__vector_pair in mov pattern of OOmode and XOmode, on the
currently being expanded gimple assignment statement. It
still puts an assertion in else arm rather than just makes
it go through, it's to ensure we can catch any other possible
unexpected cases in time if there are.
* config/rs6000/mma.md (define_expand movoo): Call function
rs6000_opaque_type_invalid_use_p to check and emit error message for
the invalid use of opaque type.
(define_expand movxo): Likewise.
* config/rs6000/rs6000-protos.h
(rs6000_opaque_type_invalid_use_p): New function declaration.
(currently_expanding_gimple_stmt): New extern declaration.
* config/rs6000/rs6000.cc (rs6000_opaque_type_invalid_use_p): New
function.
Jason Merrill [Fri, 2 Dec 2022 03:58:28 +0000 (22:58 -0500)]
c++: source position of lambda captures [PR84471]
If the DECL_VALUE_EXPR of a VAR_DECL has EXPR_LOCATION set, then any use of
that variable looks like it has that location, which leads to the debugger
jumping back and forth for both lambdas and structured bindings.
Rather than fix all the uses, it seems simplest to remove any EXPR_LOCATION
when setting DECL_VALUE_EXPR. So the cp/ hunks aren't necessary, but they
avoid the need to unshare to remove the location.
PR c++/84471
PR c++/107504
gcc/cp/ChangeLog:
* coroutines.cc (transform_local_var_uses): Don't
specify a location for DECL_VALUE_EXPR.
* decl.cc (cp_finish_decomp): Likewise.
gcc/ChangeLog:
* fold-const.cc (protected_set_expr_location_unshare): Not static.
* tree.h: Declare it.
* tree.cc (decl_value_expr_insert): Use it.
Patrick Palka [Tue, 20 Dec 2022 22:02:37 +0000 (17:02 -0500)]
c++, tree: walk TREE_VEC (and VECTOR_CST) in natural order [PR101886]
Unfortunately the extract_autos_r fix in r13-4799-ga7c8036b26082d is
derailed by the fact that walk_tree_1 currently walks the elements of a
TREE_VEC in reverse, which means for A<auto, auto> in the below testcase
extract_autos_r ends up adjusting the TEMPLATE_TYPE_IDX of the first
auto instead of the second one, and the first auto is the canonical auto
of level 2 (and index 0), so we rightfully trigger the sanity check
added in that commit.
It seems TREE_VEC and VECTOR_CST are the only trees we walk in reverse,
and this has been the case since r21884 whence the original version of
walk_tree_1 was introduced. But that's arguably unnatural and not
consistent with how we walk all other compound trees such as CONSTRUCTORs
and EXPR_P trees in forward order.
So this patch makes walk_tree_1 walk TREE_VEC (and VECTOR_CST) in
forward order as well, which fixes the testcase. Doing so revealed that
keep_template_parm grows the list of found template parameters from the
front, which previously compensated for the TREE_VEC behavior, so now we
should grow it from the back.
PR c++/101886
gcc/cp/ChangeLog:
* pt.cc (find_template_parameter_info::parm_list_tail):
New data member.
(keep_template_parm): Use parm_list_tail to append rather
than prepend to parm_list.
gcc/ChangeLog:
* tree.cc (walk_tree_1) <case TREE_VEC>: Walk the elements
in forward instead of reverse order.
<case VECTOR_CST>: Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/concepts/diagnostic12.C: Adjust expected order of
template parameters within pretty printed parameter mapping.
* g++.dg/concepts/auto6.C: New test.
Iain Sandoe [Sat, 10 Dec 2022 11:31:26 +0000 (11:31 +0000)]
coroutines: Accept 'extern "C"' coroutines.
'extern "C"' coroutines are permitted by the standard and expected to work
(although constructing useful cases could be challenging). In order to
permit this we need to arrange for the outlined helper functions to be
named properly, even when no mangling is required. To do this, we append
the actor and destroy suffixes in all cases.
This patch fixes some issues with substitution into a C++20 template
parameter object wrapper:
* The first testcase demonstrates a situation where the same_type_p
assert in relevant case of tsubst_copy doesn't hold, because (partial)
substitution of {int,} into the wrapper's TREE_TYPE yields A<int> but
substitution into the underlying TEMPLATE_PARM_INDEX is a nop due to
tsubst's level==1/tf_partial early exit tests, hence TREE_TYPE in the
latter case remains A<T>. So this patch just gets rid of the assert;
the type mismatch doesn't seem to be a problem in practice.
* In the second testcase, dependent substitution into the underlying
TEMPLATE_PARM_INDEX yields a CALL_EXPR with empty TREE_TYPE, which
tsubst_copy doesn't expect. This patch fixes this by handling empty
TREE_TYPE the same way as a non-const TREE_TYPE. Moreover, after
this substitution we're left with a VIEW_CONVERT_EXPR wrapping a
CALL_EXPR instead of a TEMPLATE_PARM_INDEX, which during the subsequent
non-dependent substitution tsubst_copy doesn't expect either. So
this patch also relaxes tsubst_copy to accept such VIEW_CONVERT_EXPR
too.
* In the third testcase, we end up never resolving the call to
f.modify() because tsubst_copy doesn't do overload resolution.
This patch fixes this by moving the handling of these
VIEW_CONVERT_EXPR wrappers from tsubst_copy to tsubst_copy_and_build.
For good measure tsubst_copy_and_build should also handle
REF_PARENTHESIZED_P wrappers instead of delegating to tsubst_copy.
PR c++/103346
PR c++/104278
PR c++/102553
gcc/cp/ChangeLog:
* pt.cc (tsubst_copy) <case VIEW_CONVERT_EXPR>: Move the
handling of C++20 template parameter object wrappers to ...
(tsubst_copy_and_build) <case VIEW_CONVERT_EXPR>: ... here.
Accept non-TEMPLATE_PARM_INDEX inner operand. Handle empty
TREE_TYPE on substituted inner operand. Remove same_type_p
assert. Also handle REF_PARENTHESIZED_P VIEW_CONVERT_EXPRs.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/nontype-class52a.C: New test.
* g++.dg/cpp2a/nontype-class53.C: New test.
* g++.dg/cpp2a/nontype-class54.C: New test.
* g++.dg/cpp2a/nontype-class55.C: New test.
Andrew MacLeod [Fri, 16 Dec 2022 21:53:31 +0000 (16:53 -0500)]
Don't use PHI equivalences in range-on-entry.
If there is only one argument to a PHI which is defined, an equivalency is
created between the def and the argument. It is safe to consider the def
equal to the argument, but it is dangerous to assume the argument is also
equivalent to the def as there may be branches which change the range on the
path to the PHI on that argument
This patch avoid using that relation in range-on-entry calculations.
PR tree-optimization/108139
gcc/
* gimple-range-cache.cc (ranger_cache::fill_block_cache): Do not
use equivalences originating from PHIS.
Jiufu Guo [Tue, 20 Dec 2022 03:43:57 +0000 (11:43 +0800)]
rs6000: Optimize cmp on rotated 16bits constant
Hi,
When checking eq/ne with a constant which has only 16bits, it can be
optimized to check the rotated data. By this, the constant building
is optimized.
As the example in PR103743:
For "in == 0x8000000000000000LL", this patch generates:
rotldi 3,3,1 ; cmpldi 0,3,1
instead of:
li 9,-1 ; rldicr 9,9,0,0 ; cmpd 0,3,9
Compare with previous version:
https://gcc.gnu.org/pipermail/gcc-patches/2022-August/600475.html.
This patch refactor the code according to review comments.
e.g. updating function names/comments/code.
This patch pass bootstrap and regtest on ppc64 and ppc64le.
Is it ok for trunk? Thanks for comments!
BR,
Jeff(Jiufu)
PR target/103743
gcc/ChangeLog:
* config/rs6000/rs6000-protos.h (can_be_rotated_to_lowbits): New.
(can_be_rotated_to_positive_16bits): New.
(can_be_rotated_to_negative_15bits): New.
* config/rs6000/rs6000.cc (can_be_rotated_to_lowbits): New definition.
(can_be_rotated_to_positive_16bits): New definition.
(can_be_rotated_to_negative_15bits): New definition.
* config/rs6000/rs6000.md (*rotate_on_cmpdi): New define_insn_and_split.
(eqne): Move earlier.
gcc/testsuite/ChangeLog:
* gcc.target/powerpc/pr103743.c: New test.
* gcc.target/powerpc/pr103743_1.c: New test.
Patrick Palka [Mon, 19 Dec 2022 20:35:51 +0000 (15:35 -0500)]
c++: modules and std::source_location::current() def arg [PR100881]
We currently declare __builtin_source_location with a const void* return
type instead of the actual type const std::source_location::__impl*, and
later when folding this builtin we obtain the actual type via name lookup.
But the below testcase demonstrates this approach seems to interact
poorly with modules, since we may import an entity that uses
std::source_location::current() in its default argument (or DMI) without
necessarily importing <source_location>, and thus the name lookup for
std::source_location will fail at the call site (when using the default
argument) unless we also import <source_location>.
This patch fixes this by instead initially declaring the builtin with an
auto return type and updating it appropriately upon its first use (in
standard code the first/only use would be in the definition of
std::source_location). Thus when folding calls to this builtin we can
get at its return type through the type of the CALL_EXPR and avoid
needing to do a name lookup.
PR c++/100881
gcc/cp/ChangeLog:
* constexpr.cc (cxx_eval_builtin_function_call): Adjust calls
to fold_builtin_source_location.
* cp-gimplify.cc (cp_gimplify_expr): Likewise.
(cp_fold): Likewise.
(get_source_location_impl_type): Remove location_t parameter and
adjust accordingly. No longer static.
(fold_builtin_source_location): Take a CALL_EXPR tree instead of a
location and obtain the impl type from its return type.
* cp-tree.h (enum cp_tree_index): Remove CPTI_SOURCE_LOCATION_IMPL
enumerator.
(source_location_impl): Remove.
(fold_builtin_source_location): Adjust parameter type.
(get_source_location_impl_type): Declare.
* decl.cc (cxx_init_decl_processing): Declare
__builtin_source_location with auto return type instead of
const void*.
(require_deduced_type): Update the return type of
__builtin_source_location.
Patrick Palka [Mon, 19 Dec 2022 19:59:43 +0000 (14:59 -0500)]
c++: ICE with concepts TS multiple auto deduction [PR101886]
In extract_autos_r, we need to recompute TYPE_CANONICAL for the template
type parameter after adjusting its index, otherwise we end up with a
comptypes ICE for the below testcase. Note that such in-place type
adjustment isn't generally safe to do since the type could be the
TYPE_CANONICAL of another (unadjusted) type, but in this case the
canonical auto (of some level and 0 index) is the first auto (of that
level) that's created, and so any auto that we do end up adjusting can't
be the canonical one.
PR c++/101886
gcc/cp/ChangeLog:
* pt.cc (extract_autos_r): Recompute TYPE_CANONICAL after
adjusting the template type parameter's index. Simplify
by using TEMPLATE_TYPE_IDX. Add some sanity checks.
Jakub Jelinek [Mon, 19 Dec 2022 19:55:56 +0000 (20:55 +0100)]
c: Diagnose compound literals with function type [PR108043]
Both C99 and latest C2X say that compound literal shall have an object type
(complete object type in the latter case) or array of unknown bound,
so complit with function type is invalid. When the initializer had to be
non-empty for such case, we used to diagnose it as incorrect initializer,
but with (fntype){} now allowed we just ICE on it.
The following patch diagnoses that.
2022-12-19 Jakub Jelinek <jakub@redhat.com>
PR c/108043
* c-parser.cc (c_parser_postfix_expression_after_paren_type): Diagnose
compound literals with function type.
* gcc.dg/pr108043.c: New test.
* gcc.dg/c99-complit-2.c (foo): Adjust expected diagnostics for
complit with function type.
Jason Merrill [Mon, 5 Dec 2022 15:00:31 +0000 (10:00 -0500)]
build: add -Wconditionally-supported to strict_warn [PR64867]
The PR (which isn't resolved by this commit) pointed out to me that GCC
should build with -Wconditionally-supported to support bootstrapping with a
C++11 compiler that makes different choices.
Richard Biener [Mon, 19 Dec 2022 13:55:45 +0000 (14:55 +0100)]
tree-optimization/108164 - undefined overflow with IV vectorization
vect_update_ivs_after_vectorizer can end up emitting a signed
IV update when the loop body performed an unsigned computation.
The following makes sure to perform that update in the type
of the loop update type to avoid undefined behavior on overflow.
PR tree-optimization/108164
* tree-vect-loop-manip.cc (vect_update_ivs_after_vectorizer):
Perform vect_step_op_add update in the appropriate type.
Richard Earnshaw [Mon, 19 Dec 2022 15:01:49 +0000 (15:01 +0000)]
arm: correctly define __ARM_FEATURE_CLZ
The ACLE requires that __ARM_FEATURE_CLZ be defined if the hardware
supports it; it's also clear that this doesn't mean the current ISA,
so we must define this even when compiling for Thumb1 if the target
supports CLZ in A32.
This brings GCC into alignment with Clang.
gcc/ChangeLog:
* config/arm/arm-c.cc (__ARM_FEATURE_CLZ): Fix definition of
preprocessor macro when target has CLZ in another ISA.
Ju-Zhe Zhong [Wed, 14 Dec 2022 11:36:41 +0000 (19:36 +0800)]
RISC-V: Remove unit-stride store from ta attribute
Since store instructions doesn't care about tail policy, we remove
vste from "ta" attribute. Hence, we could have more fusion chances
and better optimization.
Ju-Zhe Zhong [Wed, 14 Dec 2022 08:25:58 +0000 (16:25 +0800)]
RISC-V: Add testcases for VSETVL PASS 5
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-10.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-11.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-12.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-13.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-14.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-15.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-16.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-17.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-18.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-19.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-20.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-21.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-22.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-23.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-24.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-25.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-26.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-27.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-28.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-29.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-30.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-31.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-32.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-33.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-34.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-35.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-36.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-37.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-38.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-39.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-40.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-41.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-42.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-43.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-44.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-45.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-46.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-5.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-6.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-7.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-8.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-9.c: New test.
Ju-Zhe Zhong [Wed, 14 Dec 2022 08:19:35 +0000 (16:19 +0800)]
RISC-V: Add testcases for VSETVL PASS 4
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-10.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-11.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-12.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-13.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-14.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-15.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-16.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-17.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-18.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-19.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-20.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-21.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-22.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-23.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-24.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-25.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-26.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-27.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-28.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-5.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-6.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-7.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-8.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_bb_prop-9.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_call-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_call-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_call-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_call-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_complex_loop-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_complex_loop-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-10.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-11.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-12.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-5.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-6.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-7.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-8.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_conflict-9.c: New test.
Ju-Zhe Zhong [Wed, 14 Dec 2022 08:15:48 +0000 (16:15 +0800)]
RISC-V: Add testcases for VSETVL PASS 3
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-10.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-11.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-12.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-13.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-14.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-15.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-16.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-17.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-18.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-19.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-20.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-21.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-22.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-23.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-24.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-25.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-26.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-27.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-28.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-5.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-6.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-7.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-8.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_miss_default-9.c: New test.
Ju-Zhe Zhong [Wed, 14 Dec 2022 08:13:01 +0000 (16:13 +0800)]
RISC-V: Add testcases for VSETVL PASS 2
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-10.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-11.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-12.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-13.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-14.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-15.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-16.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-17.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-18.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-19.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-20.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-21.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-22.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-23.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-24.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-25.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-26.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-27.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-28.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-5.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-6.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-7.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-8.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_phi-9.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-10.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-11.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-12.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-13.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-14.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-15.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-16.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-5.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-6.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-7.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-8.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-9.c: New test.
Ju-Zhe Zhong [Wed, 14 Dec 2022 08:09:31 +0000 (16:09 +0800)]
RISC-V: Add testcases for VSETVL PASS
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/rvv.exp: Adjust to enable tests for VSETVL PASS.
* gcc.target/riscv/rvv/vsetvl/dump-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-10.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-11.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-12.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-13.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-14.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-15.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-16.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-17.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-18.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-19.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-5.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-6.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-7.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-8.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_block-9.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-1.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-2.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-3.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-4.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-5.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-6.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-7.c: New test.
* gcc.target/riscv/rvv/vsetvl/vlmax_single_vtype-8.c: New test.
Ju-Zhe Zhong [Wed, 14 Dec 2022 07:31:11 +0000 (15:31 +0800)]
RISC-V: Support VSETVL PASS for RVV support
This patch is to support VSETVL PASS for RVV support.
1.The optimization and performance is guaranteed LCM (Lazy code motion).
2.Base on RTL_SSA framework to gain better optimization chances.
3.Also we do VL/VTYPE, demand information backward propagation across
blocks by RTL_SSA reverse order in CFG.
4.It has been well and fully tested by about 200+ testcases for VLMAX
AVL situation (Only for VLMAX since we don't have an intrinsics to
test non-VLMAX).
5.Will support AVL model in the next patch.
gcc/ChangeLog:
* config.gcc: Add riscv-vsetvl.o.
* config/riscv/riscv-passes.def (INSERT_PASS_BEFORE): Add VSETVL PASS
location.
* config/riscv/riscv-protos.h (make_pass_vsetvl): New function.
(enum avl_type): New enum.
(get_ta): New function.
(get_ma): Ditto.
(get_avl_type): Ditto.
(calculate_ratio): Ditto.
(enum tail_policy): New enum.
(enum mask_policy): Ditto.
* config/riscv/riscv-v.cc (calculate_ratio): New function.
(emit_pred_op): change the VLMAX mov codgen.
(get_ta): New function.
(get_ma): Ditto.
(enum tail_policy): Change enum.
(get_prefer_tail_policy): New function.
(enum mask_policy): Change enum.
(get_prefer_mask_policy): New function.
* config/riscv/t-riscv: Add riscv-vsetvl.o
* config/riscv/vector.md: Adjust attribute and pattern for VSETVL
PASS.
(@vlmax_avl<mode>): Ditto.
(@vsetvl<mode>_no_side_effects): Delete.
(vsetvl_vtype_change_only): New MD pattern.
(@vsetvl_discard_result<mode>): Ditto.
* config/riscv/riscv-vsetvl.cc: New file.
* config/riscv/riscv-vsetvl.h: New file.
The attribute configuration of each machine mode are support in the previous patch.
I noticed some of them are not correct during VSETVL PASS testsing.
Correct them in the single patch now.
Jakub Jelinek [Mon, 19 Dec 2022 14:00:47 +0000 (15:00 +0100)]
modula2: Don't treat % in Modula 2 messages specially
On top of the just posted patch, this patch makes sure that
any % chars in message strings aren't treated as format chars.
None of these functions take variable number of arguments, so for
most of format specifiers there is nowhere to take arguments from,
it is true that a couple of format specifiers don't take any
arguments - %%, %m, %<, %>, %' - so it is actually possible
to use them, but one needs to verify that no other are emitted and
that what should be printed as % is really emitted as %%.
If the FE does that, then please ignore this patch, otherwise I think
it is safer to do this.
2022-12-19 Jakub Jelinek <jakub@redhat.com>
* gm2-gcc/m2linemap.cc (m2linemap_ErrorAt, m2linemap_ErrorAtf,
m2linemap_WarningAtf, m2linemap_NoteAtf, m2linemap_internal_error):
Call functions with "%s", message rather than just message, so that
% chars in message aren't treated as format specifiers.
Jakub Jelinek [Mon, 19 Dec 2022 13:20:36 +0000 (14:20 +0100)]
modula2: Fix up bootstrap on powerpc64le-linux [PR108147]
As mentioned in the PR, bootstrap with m2 enabled currently fails
on powerpc64le-linux, we get weird ICE after printing some diagnostics.
The problem is that mc creates from *.def prototypes like
extern void m2linemap_WarningAtf (m2linemap_location_t location, void * message);
but the actual function definitions use
void m2linemap_WarningAtf (m2linemap_location_t location, void * message,
...) { code }
and on powerpc64le-linux such lying about the prototype results in
wrong-code, on the caller side we assume the function isn't varargs
and so don't reserve 64 bytes in the frame for it, while the callee
relies on the area being reserved and stores into it.
Fixed by adding non-stdarg wrappers around stdarg functions (because
we want va_list and pass it to diagnostics functions).
2022-12-19 Jakub Jelinek <jakub@redhat.com>
PR modula2/108147
* gm2-gcc/m2linemap.def (ErrorAtf, WarningAtf, NoteAtf):
Comment out prototypes with varargs.
* gm2-gcc/m2linemap.h (m2linemap_ErrorAtf, m2linemap_WarningAtf,
m2linemap_NoteAtf): No longer varargs.
* gm2-gcc/m2linemap.cc (m2linemap_ErrorAtf): Turned into a
non-varargs wrapper around ...
(m2linemap_ErrorAtf_1): ... this. New static function.
(m2linemap_WarningAtf): Turned into a non-varargs wrapper around ...
(m2linemap_WarningAtf_1): ... this. New static function.
(m2linemap_NoteAtf): Turned into a non-varargs wrapper around ...
(m2linemap_NoteAtf_1): ... this. New static function.
Jakub Jelinek [Mon, 19 Dec 2022 12:49:52 +0000 (13:49 +0100)]
testsuite: Fix up pr64536.c for LLP64 targets [PR108151]
The test casts a pointer to long, which is ok for ilp32 and lp64
targets but not for llp64 targets. Nothing reads the values later,
it is a link test, so all we care about is that it is the same
cast on s390x-linux where it used to fail before the PR64536 fix,
and that we don't warn about it.
2022-12-19 Jakub Jelinek <jakub@redhat.com>
PR testsuite/108151
* gcc.dg/pr64536.c (bar): Use casts to __INTPTR_TYPE__ rather than
long when casting pointer to integral type.
Kyrylo Tkachov [Mon, 19 Dec 2022 11:16:47 +0000 (11:16 +0000)]
aarch64: PR target/108140 Handle NULL target in data intrinsic expansion
In this PR we ICE when expanding the __rbit builtin with a NULL target rtx.
I *think* that only happens when the result is unused and hence maybe we shouldn't be expanding
any RTL at all, but the ICE here is easily fixed by deriving the mode from the type of the expression
rather than the target.
This patch does that.
Bootstrapped and tested on aarch64-none-linux-gnu.
Tobias Burnus [Mon, 19 Dec 2022 11:12:16 +0000 (12:12 +0100)]
gcc-changelog: Add warning for auto-added files
git_email.py prints now a warning for files added automatically.
git_check_commit.py does likewise but only with --verbose.
It prints one line per ChangeLog file, either stating the file
or if more than one the number of files.
contrib/ChangeLog:
* gcc-changelog/git_check_commit.py (__main__): With -v print a
warning for the auto-added files.
* gcc-changelog/git_commit.py (GitCommit.__init__): Add self.warnings.
(GitCommit.check_mentioned_files): Add warning for auto-added files.
(GitCommit.print_warnings): New function.
* gcc-changelog/git_email.py (__main__): Remove bogus argument to
GitEmail constructor; print auto-added-files warning.
* gcc-changelog/test_email.py (test_auto_add_file_1,
test_auto_add_file_2): New tests.
* gcc-changelog/test_patches.txt: Add two test cases.
Jakub Jelinek [Mon, 19 Dec 2022 10:24:55 +0000 (11:24 +0100)]
testsuite: Fix up pr107397.f90 test [PR107397]
The pr107397.f90 test FAILs for me, one problem was that the
added diagnostics has an indefinite article before BOZ, but
the test dg-error didn't. The other problem was that on the
other dg-error there was no space between the string and closing
}, so it was completely ignored and the error was an excess
error.
2022-12-19 Jakub Jelinek <jakub@redhat.com>
PR fortran/107397
* gfortran.dg/pr107397.f90: Adjust expected diagnostic wording and
add space between dg-error string and closing }.
Jakub Jelinek [Mon, 19 Dec 2022 10:14:55 +0000 (11:14 +0100)]
hwasan: Add libhwasan_preinit.o
I've noticed an inconsistency with the other sanitizers.
For -fsanitize={address,thread,leak} we link into binaries
lib*san_preinit.o such that the -lasan, -ltsan or -llsan libraries
are initialized as early as possible through .preinit_array.
The hwasan library has the same thing, but we strangely compiled
it into the library (where it apparently didn't do anything,
.preinit_array doesn't seem to be created for shared libraries),
rather than installing it like in the other 3 cases.
The following patch handles it for hwasan similarly to asan, tsan and lsan.
I don't have any hw with hwasan support, so I've just checked it
builds and installs as expected and that
gcc -fsanitize=hwaddress -o a a.c -mlam=u57
on trivial main results in .preinit_array section in the binary.
2022-12-19 Jakub Jelinek <jakub@redhat.com>
* config/gnu-user.h (LIBHWASAN_EARLY_SPEC): Add libhwasan_preinit.o
to link spec if not -shared.
* hwasan/Makefile.am (nodist_toolexeclib_HEADERS): Set to
libhwasan_preinit.o.
(hwasan_files): Remove hwasan_preinit.cpp.
(libhwasan_preinit.o): Copy from hwasan_preinit.o.
* hwasan/Makefile.in: Regenerated.
Ju-Zhe Zhong [Wed, 14 Dec 2022 06:57:44 +0000 (14:57 +0800)]
RISC-V: Change vlmul printing rule
This patch is preparing patch for the following patch (VSETVL PASS)
support since the current vlmul printing rule is not appropriate
information for VSETVL PASS. I split this fix in a single patch.
gcc/ChangeLog:
* config/riscv/riscv-v.cc (emit_vlmax_vsetvl): Pass through VLMUL enum
instead of machine mode.
* config/riscv/riscv-vector-builtins-bases.cc: Ditto.
* config/riscv/riscv.cc (riscv_print_operand): Print LMUL by enum vlmul
instead of machine mode.
liuhongt [Thu, 15 Dec 2022 01:38:08 +0000 (09:38 +0800)]
x86: Don't add crtfastmath.o for -shared
Don't add crtfastmath.o for -shared to avoid changing the MXCSR register
when loading a shared library. crtfastmath.o will be used only when
building executables.
PR target/55522
* config/i386/gnu-user-common.h (GNU_USER_TARGET_MATHFILE_SPEC):
Don't add crtfastmath.o for -shared.
* doc/invoke.texi (-shared): Add related documentation.
Use 0 for the "lang" identifier for Rust, just like we do for all other
source languages without assigned language code (0 means "C").
Tested on powerpc64-linux. Without this patch there are ICEs galore in
the gm2 testsuite for 64-bit Linux targets, and with the ptch there are
just a few FAILs.
Patrick Palka [Sat, 17 Dec 2022 16:24:44 +0000 (11:24 -0500)]
c++: constantness of non-dependent NTTP argument [PR107437]
Here we're rejecting the use of the lambda capture of 't' (of empty
type) as a template argument ultimately because convert_nontype_argument
checks constantness using is_constant_expression, which returns false
for lambda captures since want_rval=false. But in this case I believe
an lvalue-to-rvalue conversion of the argument is implied, so we should
be using is_rvalue_constant_expression instead (which would return true
here).
However, it doesn't seem necessary to consider constantness at all
when deciding whether to instantiate a non-dependent argument in
convert_nontype_argument. So this patch gets rid of the problematic
constantness test altogether, which incidentally also fixes the similar
dg-ice'd testcase from PR87765. This is in line with a similar
change we made to finish_decltype_type in r12-7564-gec0f53a3a542e7.
PR c++/107437
PR c++/87765
gcc/cp/ChangeLog:
* pt.cc (convert_nontype_argument): Relax is_nondep_const_expr
test to !inst_dep_expr_p.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/lambda-generic-107437.C: New test.
* g++.dg/cpp1z/constexpr-lambda26.C: Remove dg-ice.
Thomas Neumann [Fri, 9 Dec 2022 17:23:44 +0000 (18:23 +0100)]
initialize fde objects lazily
When registering an unwind frame with __register_frame_info_bases
we currently initialize that fde object eagerly. This has the
advantage that it is immutable afterwards and we can safely
access it from multiple threads, but it has the disadvantage
that we pay the initialization cost even if the application
never throws an exception.
This commit changes the logic to initialize the objects lazily.
The objects themselves are inserted into the b-tree when
registering the frame, but the sorted fde_vector is
not constructed yet. Only on the first time that an
exception tries to pass through the registered code the
object is initialized. We notice that with a double checking,
first doing a relaxed load of the sorted bit and then re-checking
under a mutex when the object was not initialized yet.
Note that the check must implicitly be safe concering a concurrent
frame deregistration, as trying the deregister a frame that is
on the unwinding path of a concurrent exception is inherently racy.
libgcc/ChangeLog:
* unwind-dw2-fde.c: Initialize fde object lazily when
the first exception tries to pass through.
Thomas Neumann [Tue, 22 Nov 2022 07:41:54 +0000 (08:41 +0100)]
speed up end_fde_sort using radix sort
When registering a dynamic unwinding frame the fde list is sorted.
Previously, we split the list into a sorted and an unsorted part,
sorted the later using heap sort, and merged both. That can be
quite slow due to the large number of (expensive) comparisons.
This patch replaces that logic with a radix sort instead. The
radix sort uses the same amount of memory as the old logic,
using the second list as auxiliary space, and it includes two
techniques to speed up sorting: First, it computes the pointer
addresses for blocks of values, reducing the decoding overhead.
And it recognizes when the data has reached a sorted state,
allowing for early termination. When running out of memory
we fall back to pure heap sort, as before.
Some package builds enable -fstack-protector and -Werror. Since
-fstack-protector is not supported on hppa because the stack grows
up, these packages must check for the warning generated by
-fstack-protector and suppress it on hppa. This is problematic
since hppa is the only significant architecture where the stack
grows up.
2022-12-16 John David Anglin <danglin@gcc.gnu.org>
Jonathan Wakely [Fri, 16 Dec 2022 16:07:29 +0000 (16:07 +0000)]
libstdc++: Fixes for std::expected
This fixes some bugs in the swap functions for std::expected.
It also disables the noexcept-specifiers for equality operators, because
those are problematic when querying whether a std::expected is equality
comparable. The operator==(const expected<T,E>&, const U&) function is
not constrained, so is viable for comparing expected<T,E> with
expected<void,G>, but then we get an error from the noexcept-specifier.
libstdc++-v3/ChangeLog:
* include/std/expected (expected::_M_swap_val_unex): Guard the
correct object.
(expected::swap): Move is_swappable
requirement from static_assert to constraint.
(swap): Likewise.
(operator==): Remove noexcept-specifier.
* testsuite/20_util/expected/swap.cc: Check swapping of
types without non-throwing move constructor. Check constraints
on swap.
* testsuite/20_util/expected/unexpected.cc: Check constraints on
swap.
* testsuite/20_util/expected/equality.cc: New test.
Jonathan Wakely [Wed, 14 Dec 2022 15:21:32 +0000 (15:21 +0000)]
libstdc++: Diagnose broken allocator rebind members
This adds a static assertion to std::allocator_traits::rebind_alloc to
diagnose violations of the rule that rebinding an allocator to its own
value type yields the same allocator type.
This helps to catch the easy mistake of deriving from std::allocator but
forgetting to override the rebind behaviour (no longer an issue in C++20
as std::allocator doesn't have a rebind member that can be inherited).
It also catches bugs like in 23_containers/vector/52591.cc where a typo
means the rebound allocator is a completely different type.
I initially wanted to put this static assert into the body of
allocator_traits:
static_assert(is_same<rebind_alloc<value_type>, _Alloc>::value,
"rebind_alloc<value_type> must be Alloc");
However, this causes a regression in the test for PR libstdc++/72792.
It seems that instantiating std::allocator_traits should be allowed for
invalid allocator types as long as you don't try to rebind them. To
support that, only assert in the __allocator_traits_base::__rebind class
template (in both the primary template and the partial specialization).
As a result, the bug in 20_util/scoped_allocator/outermost.cc is not
diagnosed, because nothing in that test rebinds the allocator.
libstdc++-v3/ChangeLog:
* include/bits/alloc_traits.h (__allocator_traits_base::__rebind):
Add static assert for rebind requirement.
* testsuite/20_util/allocator_traits/members/rebind_alloc.cc:
Fix invalid rebind member in test allocator.
* testsuite/20_util/allocator_traits/requirements/rebind_neg.cc:
New test.
* testsuite/20_util/scoped_allocator/outermost.cc: Add rebind to
test allocator.
* testsuite/23_containers/forward_list/48101_neg.cc: Prune new
static assert error.
* testsuite/23_containers/unordered_multiset/48101_neg.cc:
Likewise.
* testsuite/23_containers/unordered_set/48101_neg.cc:
Likewise.
* testsuite/23_containers/vector/52591.cc: Fix typo in rebind.
Andrew Pinski [Thu, 8 Dec 2022 22:34:16 +0000 (22:34 +0000)]
coroutines: Build pointer initializers with nullptr_node [PR107768]
The PR reports that using integer_zero_node triggers a warning for
-Wzero-as-null-pointer-constant which comes from compiler-generated code so
makes no sense to the end user.
David Malcolm [Fri, 16 Dec 2022 19:50:07 +0000 (14:50 -0500)]
analyzer: add src_region param to region_model::check_for_poison [PR106479]
PR analyzer/106479 notes that we don't always show the region-creation
event for a memmove from an uninitialized stack region. This occurs
when using kf_memcpy_memmove. Fix by passing a src_region hint to
region_model::check_for_poison.
gcc/analyzer/ChangeLog:
PR analyzer/106479
* kf.cc (kf_memcpy_memmove::impl_call_pre): Pass in source region
to region_model::check_for_poison.
* region-model-asm.cc (region_model::on_asm_stmt): Pass NULL
region to region_model::check_for_poison.
* region-model.cc (region_model::check_for_poison): Add
"src_region" param, and pass it to poisoned_value_diagnostic.
(region_model::on_assignment): Pass NULL region to
region_model::check_for_poison.
(region_model::get_rvalue): Likewise.
* region-model.h (region_model::check_for_poison): Add
"src_region" param.
* sm-fd.cc (fd_state_machine::on_accept): Pass in source region
to region_model::check_for_poison.
* varargs.cc (kf_va_copy::impl_call_pre): Pass NULL region to
region_model::check_for_poison.
(kf_va_arg::impl_call_pre): Pass in source region to
region_model::check_for_poison.
gcc/testsuite/ChangeLog:
PR analyzer/106479
* gcc.dg/analyzer/pr104308.c (test_memmove_within_uninit): Remove
xfail on region creation event.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Qing Zhao [Fri, 16 Dec 2022 17:25:42 +0000 (17:25 +0000)]
Add a new warning option -Wstrict-flex-arrays.
'-Wstrict-flex-arrays'
Warn about inproper usages of flexible array members according to
the LEVEL of the 'strict_flex_array (LEVEL)' attribute attached to
the trailing array field of a structure if it's available,
otherwise according to the LEVEL of the option
'-fstrict-flex-arrays=LEVEL'.
This option is effective only when LEVEL is bigger than 0.
Otherwise, it will be ignored with a warning.
when LEVEL=1, warnings will be issued for a trailing array
reference of a structure that have 2 or more elements if the
trailing array is referenced as a flexible array member.
when LEVEL=2, in addition to LEVEL=1, additional warnings will be
issued for a trailing one-element array reference of a structure if
the array is referenced as a flexible array member.
when LEVEL=3, in addition to LEVEL=2, additional warnings will be
issued for a trailing zero-length array reference of a structure if
the array is referenced as a flexible array member.
gcc/ChangeLog:
* doc/invoke.texi: Document -Wstrict-flex-arrays option.
* gimple-array-bounds.cc (check_out_of_bounds_and_warn): Add two more
arguments.
(array_bounds_checker::check_array_ref): Issue warnings for
-Wstrict-flex-arrays.
* opts.cc (finish_options): Issue warning for unsupported combination
of -Wstrict_flex_arrays and -fstrict-flex-array.
* tree-vrp.cc (execute_ranger_vrp): Enable the pass when
warn_strict_flex_array is true.
gcc/c-family/ChangeLog:
* c.opt (Wstrict-flex-arrays): New option.
gcc/testsuite/ChangeLog:
* gcc.dg/Warray-bounds-flex-arrays-1.c: Update testing case with
-Wstrict-flex-arrays.
* gcc.dg/Warray-bounds-flex-arrays-2.c: Likewise.
* gcc.dg/Warray-bounds-flex-arrays-3.c: Likewise.
* gcc.dg/Warray-bounds-flex-arrays-4.c: Likewise.
* gcc.dg/Warray-bounds-flex-arrays-5.c: Likewise.
* gcc.dg/Warray-bounds-flex-arrays-6.c: Likewise.
* c-c++-common/Wstrict-flex-arrays.c: New test.
* gcc.dg/Wstrict-flex-arrays-2.c: New test.
* gcc.dg/Wstrict-flex-arrays-3.c: New test.
* gcc.dg/Wstrict-flex-arrays.c: New test.
The standard's move-and-swap implementation generates smaller code at
all levels except -O0 and -Og, so it seems simplest to just do what the
standard says.
libstdc++-v3/ChangeLog:
PR libstdc++/108118
* include/bits/shared_ptr_base.h (weak_ptr::operator=):
Implement as move-and-swap exactly as specified in the standard.
* testsuite/20_util/weak_ptr/cons/self_move.cc: New test.
Richard Biener [Fri, 16 Dec 2022 12:01:40 +0000 (13:01 +0100)]
middle-end/108086 - avoid unshare_expr when remapping SSA names
r0-89280-g129a37fc319db8 added unsharing to remap_ssa_name but
that wasn't in the version of the patch posted. That has some
non-trivial cost through mostly_copy_tree_r and copy_tree_r but
more importantly it doesn't seem to be necessary. I've successfully
bootstrapped and tested with an assert we only get
tree_node_can_be_shared trees here.
Bootstrapped and tested on x86_64-unknown-linux-gnu with all
languages.
PR middle-end/108086
* tree-inline.cc (remap_ssa_name): Do not unshare the
result from the decl_map.
This patch uses a fallback for git_email.py (drop argument) if not
available (TypeError exception) but keeps using it in test_email.py
unconditionally.
contrib/ChangeLog:
* gcc-changelog/git_email.py (GitEmail:__init__): Support older
unidiff.PatchSet that do not have a newline= argument
of from_filename.
Richard Biener [Fri, 16 Dec 2022 08:46:25 +0000 (09:46 +0100)]
middle-end/108086 - remove PR28238 fix superseeded by PR34018 fix
There's quite special code in copy_bb that handles inline substitution
of a non-invariant address in place of an invariant one that's
now handled by more generic handling of this case in remap_gimple_op_r
so this removes the special casing that happens in a hot path, providing
a small speedup.
PR middle-end/108086
* tree-inline.cc (copy_bb): Remove handling of (foo *)&this->m
substitution which is done in remap_gimple_op_r via
re-gimplifying.
Jakub Jelinek [Fri, 16 Dec 2022 09:19:22 +0000 (10:19 +0100)]
loop-invariant: Split preheader edge if the preheader bb ends with jump [PR106751]
The RTL loop passes only request simple preheaders, but don't require
fallthru preheaders, while move_invariant_reg apparently assumes the
latter, that it can just append instruction(s) to the end of the preheader
basic block.
The following patch fixes that by splitting the preheader edge if
the preheader bb ends with a JUMP_INSN (asm goto in this case).
Without that we get control flow in the middle of a bb.
2022-12-16 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/106751
* loop-invariant.cc (move_invariant_reg): If preheader bb ends
with a JUMP_INSN, split the preheader edge and emit invariants
into the new preheader basic block.
Richard Biener [Fri, 16 Dec 2022 08:25:40 +0000 (09:25 +0100)]
middle-end/108086 - more operand scanner reduction in inlining
There's another round of redundant operand scanning in
remap_gimple_stmt. The following removes this and also improves
one special-case to call a cheaper inline function.
PR middle-end/108086
* tree-inline.cc (remap_gimple_stmt): Add stmts to the
sequence without updating them. Simplify x == x detection.
Patrick Palka [Thu, 15 Dec 2022 23:50:16 +0000 (18:50 -0500)]
c++: variadic using-decl with parm pack in terminal name [PR102104]
There's a curious corner case with variadic member using-decls: the
terminal name can also contain a parameter pack, and only through naming
a conversion function, e.g.
using A<Ts>::operator Ts...;
We currently only handle parameter packs appearing in the qualifying
scope of a variadic using-decl; this patch adds support for the above
case as well, representing such a using-decl via two pack expansions,
one for the qualifying scope and one for the terminal name (despite
logically there being just one). Then at instantiation time we manually
merge them.
PR c++/102104
PR c++/108090
gcc/cp/ChangeLog:
* error.cc (dump_decl) <case USING_DECL>: Look through a
pack expansion in the name as well.
* parser.cc (cp_parser_using_declaration): Handle a parameter
pack appearing in the terminal name of a variadic using-decl.
* pt.cc (tsubst_decl) <case USING_DECL>: Likewise. Combine the
handling of variadic and non-variadic using-decls.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1z/using-variadic1.C: New test.
* g++.dg/cpp1z/using-variadic1a.C: New test.
* g++.dg/cpp1z/using-variadic1b.C: New test.
* g++.dg/cpp1z/using-variadic1c.C: New test.
* g++.dg/cpp1z/using-variadic2.C: New test.
* g++.dg/cpp1z/using-variadic3.C: New test.
Patrick Palka [Thu, 15 Dec 2022 21:07:09 +0000 (16:07 -0500)]
c++: class-scope qualified constrained auto [PR107188]
Here when parsing the class-scope auto constrained by a qualified
concept-id, we first tentatively parse the overall member-declaration as
a deprecated access-declaration, during which we parse C<int> as a
standalone TEMPLATE_ID_EXPR (separate from the auto) and end up emitting
the stray error
concepts-placeholder11.C:9:6: error: wrong number of template arguments (1, should be 2)
9 | N::C<int> auto f() { return 0; }
| ^~~~~~
concepts-placeholder11.C:5:34: note: provided for ‘template<class, class> concept N::C’
5 | template<class, class> concept C = true;
| ^
from build_concept_id called from cp_parser_template_id_expr.
We could fix this by adding a complain parameter to build_concept_id and
passing tf_none when parsing tentatively. However, it seems this can
also be fixed in a more general way that might benefit non-concepts
code: when tentatively parsing an access-declaration, abort the parse
early if the qualifying scope isn't possibly a class or enumeration
type, so that we avoid parsing C<int> as a TEMPLATE_ID_EXPR here in the
first place. This patch takes this latter approach.
PR c++/107188
gcc/cp/ChangeLog:
* parser.cc (cp_parser_using_declaration): Give up early if the
scope of an access-declaration isn't possibly a class type.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-placeholder11.C: New test.
Patrick Palka [Thu, 15 Dec 2022 21:02:05 +0000 (16:02 -0500)]
c++: extract_local_specs and unevaluated contexts [PR100295]
Here during partial instantiation of the constexpr if, extra_local_specs
walks the statement looking for local specializations within to capture.
However, we're thwarted by the fact that 'ts' first appears inside an
unevaluated context, and so the calls to process_outer_var_ref for its
local specializations are a no-op. And since we walk each tree exactly
once, we end up not capturing the local specializations despite 'ts'
later occurring in an evaluated context.
This patch fixes this by making extract_local_specs walk evaluated
contexts first before walking unevaluated contexts. We could probably
get away with not walking unevaluated contexts at all, but this approach
seems more clearly safe.
PR c++/100295
PR c++/107579
gcc/cp/ChangeLog:
* pt.cc (el_data::skip_unevaluated_operands): New data member.
(extract_locals_r): If skip_unevaluated_operands is true,
don't walk into unevaluated contexts.
(extract_local_specs): Walk the pattern twice, first with
skip_unevaluated_operands true followed by it set to false.
Patrick Palka [Thu, 15 Dec 2022 20:54:31 +0000 (15:54 -0500)]
c++: local alias in typename in lambda [PR105518]
We substitute the qualifying scope of a TYPENAME_TYPE directly using
tsubst_aggr_type (so that we can pass entering_scope=true) instead of
going through tsubst, which means we don't properly reuse typedefs
during this substitution. This ends up causing us to reject the below
testcase because we substitute the TYPENAME_TYPE alias::type as if it
were written without the A<t> alias, and thus we expect the non-capturing
lambda to capture t.
This patch fixes this by making tsubst_aggr_type delegate typedefs
to tsubst so that get consistently reused, and then adjusting the result
appropriately if entering_scope is true. In passing, this refactors
tsubst_aggr_type into two functions, one that's intended to be called
directly and a more minimal one that's intended to be called only from
the RECORD/UNION/ENUMERAL_TYPE cases of tsubst (and contains only the
necessary bits for that call site).
PR c++/105518
gcc/cp/ChangeLog:
* pt.cc (tsubst_aggr_type): Handle typedefs by delegating to
tsubst and adjusting the result if entering_scope. Split out
the main part of the function into ...
(tsubst_aggr_type_1) ... here.
(tsubst): Use tsubst_aggr_type_1 instead of tsubst_aggr_type.
Handle TYPE_PTRMEMFUNC_P RECORD_TYPEs here instead of in
tsubst_aggr_type_1.
Patrick Palka [Thu, 15 Dec 2022 20:38:47 +0000 (15:38 -0500)]
c++: partial ordering with memfn ptr cst [PR108104]
Here we're triggering an overzealous assert in unify during partial
ordering since the member function pointer constants are represented as
ordinary CONSTRUCTORs (with TYPE_PTRMEMFUNC_P TREE_TYPE) but the assert
expects COMPOUND_LITERAL_P constructors.
PR c++/108104
gcc/cp/ChangeLog:
* pt.cc (unify) <default>: Relax assert to accept any
CONSTRUCTOR parm, not just COMPOUND_LITERAL_P one.