Commit graph

195756 commits

Author SHA1 Message Date
Richard Sandiford
2a4788ac3b aarch64: Rename AARCH64_ISA architecture-level macros
All AARCH64_ISA_* architecture-level macros except AARCH64_ISA_V8_R
are for the A profile: they cause __ARM_ARCH_PROFILE to be set to
'A' and they are associated with architecture names like armv8.4-a.

It's convenient for later patches if we make this explicit
by adding an "A" to the name.  Also, rather than add an underscore
(as for V8_R) it's more convenient to add the profile directly
to the number, like we already do in the ARCH_IDENT field of the
aarch64-arches.def entries.

gcc/
	* config/aarch64/aarch64.h (AARCH64_ISA_V8_2, AARCH64_ISA_V8_3)
	(AARCH64_ISA_V8_4, AARCH64_ISA_V8_5, AARCH64_ISA_V8_6)
	(AARCH64_ISA_V9, AARCH64_ISA_V9_1, AARCH64_ISA_V9_2)
	(AARCH64_ISA_V9_3): Add "A" to the end of the name.
	(AARCH64_ISA_V8_R): Rename to AARCH64_ISA_V8R.
	(TARGET_ARMV8_3, TARGET_JSCVT, TARGET_FRINT, TARGET_MEMTAG): Update
	accordingly.
	* common/config/aarch64/aarch64-common.cc
	(aarch64_get_extension_string_for_isa_flags): Likewise.
	* config/aarch64/aarch64-c.cc
	(aarch64_define_unconditional_macros): Likewise.
2022-09-29 11:32:50 +01:00
Richard Sandiford
c1e1fa0549 Add OPTIONS_H_EXTRA to GTFILES
I have a patch that adds a typedef to aarch64's <cpu>-opts.h.
The typedef is used for a TargetVariable in the .opt file,
which means that it is covered by PCH and so needs to be
visible to gengtype.

<cpu>-opts.h is not included directly in tm.h, but indirectly
by target headers (in this case aarch64.h).  There was therefore
nothing that caused it to be added to GTFILES.

gcc/
	* Makefile.in (GTFILES): Add OPTIONS_H_EXTRA.
2022-09-29 11:32:50 +01:00
Jakub Jelinek
a5a9237e2a driver, cppdefault: Unbreak bootstrap on Debian/Ubuntu [PR107059]
My recent change to enable _Float{16,32,64,128,32x,64x,128x} for C++
apparently broke bootstrap on some Debian/Ubuntu setups.
Those multiarch targets put some headers into
/usr/include/x86_64-linux-gnu/bits/ etc. subdirectory instead of
/usr/include/bits/.
This is handled by
    /* /usr/include comes dead last.  */
    { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 2 },
    { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 0 },
in cppdefault.cc, where the 2 in the last element of the first initializer
means the entry is ignored on non-multiarch and suffixed by the multiarch
dir otherwise, so installed gcc has search path like:
 /home/jakub/gcc/obj01inst/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/13.0.0/include
 /home/jakub/gcc/obj01inst/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/13.0.0/include-fixed
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
(when installed with DESTDIR=/home/jakub/gcc/obj01inst).
Now, when fixincludes is run, it is processing the whole /usr/include dir
and all its subdirectories, so floatn{,-common.h} actually go into
.../include-fixed/x86_64-linux-gnu/bits/floatn{,-common.h}
because that is where they appear in /usr/include too.
In some setups, /usr/include also contains /usr/include/bits -> x86_64-linux-gnu/bits
symlink and after the r13-2896 tweak it works.
In other setups there is no /usr/include/bits symlink and when one
 #include <bits/floatn.h>
given the above search path, it doesn't find the fixincluded header,
as
/home/jakub/gcc/obj01inst/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/13.0.0/include-fixed/bits/floatn.h
doesn't exist and
/home/jakub/gcc/obj01inst/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/13.0.0/include-fixed/x86_64-linux-gnu/bits/floatn.h
isn't searched and so
/usr/include/x86_64-linux-gnu/bits/floatn.h
wins and we fail because of typedef whatever _Float128; and similar.
The following patch ought to fix this.  The first hunk by arranging that
the installed search path actually looks like:
 /home/jakub/gcc/obj01inst/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/13.0.0/include
 /home/jakub/gcc/obj01inst/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/13.0.0/include-fixed/x86_64-linux-gnu
 /home/jakub/gcc/obj01inst/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/13.0.0/include-fixed
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
and thus for include-fixed it treats it the same as /usr/include.
The second FIXED_INCLUDE_DIR entry there is:
     { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0,
       /* A multilib suffix needs adding if different multilibs use
          different headers.  */
 #ifdef SYSROOT_HEADERS_SUFFIX_SPEC
       1
 #else
       0
 #endif
     },
where SYSROOT_HEADERS_SUFFIX_SPEC is defined only on vxworks or mips*-mti-linux
and arranges for multilib path to be appended there.  Neither of those
systems is multiarch.
This isn't enough, because when using the -B option, the driver adds
-isystem .../include-fixed in another place, so the second hunk modifies
that spot the same.
/home/jakub/gcc/obj01/gcc/xgcc -B /home/jakub/gcc/obj01/gcc/
then has search path:
 /home/jakub/gcc/obj01/gcc/include
 /home/jakub/gcc/obj01/gcc/include-fixed/x86_64-linux-gnu
 /home/jakub/gcc/obj01/gcc/include-fixed
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
which again is what I think we want to achieve.

2022-09-29  Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/107059
	* cppdefault.cc (cpp_include_defaults): If SYSROOT_HEADERS_SUFFIX_SPEC
	isn't defined, add FIXED_INCLUDE_DIR entry with multilib flag 2
	before FIXED_INCLUDE_DIR entry with multilib flag 0.
	* gcc.cc (do_spec_1): If multiarch_dir, add
	include-fixed/multiarch_dir paths before include-fixed paths.
2022-09-29 12:04:24 +02:00
Martin Liska
b7723e1353 support -gz=zstd for both linker and assembler
PR driver/106897

gcc/ChangeLog:

	* common.opt: Add -gz=zstd value.
	* configure.ac: Detect --compress-debug-sections=zstd
	for both linker and assembler.
	* configure: Regenerate.
	* gcc.cc (LINK_COMPRESS_DEBUG_SPEC): Handle -gz=zstd.
	(ASM_COMPRESS_DEBUG_SPEC): Likewise.
2022-09-29 11:26:33 +02:00
Ronan Desplanques
9b0d780514 ada: Remove duplicated doc comment section
A documentation section was duplicated by mistake in r0-110752.
This commit removes the copy that was added by r0-110752, but
integrates the small editorial change that it brought to the
original.

gcc/ada/

	* einfo.ads: remove documentation duplicate
2022-09-29 11:08:47 +02:00
Eric Botcazou
0f8a934b44 ada: Further tweak new expansion of contracts
The original extended return statement is mandatory for functions whose
result type is limited in Ada 2005 and later.

gcc/ada/

	* contracts.adb (Build_Subprogram_Contract_Wrapper): Put back the
	extended return statement if the result type is built-in-place.
	* sem_attr.adb (Analyze_Attribute_Old_Result): Also expect an
	extended return statement.
2022-09-29 11:08:47 +02:00
Bob Duff
9ebc54a8c4 ada: Improve efficiency of slice-of-component assignment
This patch improves the efficiency of slice assignment when the left- or
right-hand side is a slice of a component or a slice of a slice.
Previously, the optimization was disabled in these cases, just in
case there might be a volatile or independent component lurking.
Now we explicitly check all the relevant subcomponents of
the prefix.

The previous version said (in exp_ch5.adb):

	--  ...We could
	--  complicate this code by actually looking for such volatile and
	--  independent components.

and that's exactly what we are doing here.

gcc/ada/

	* exp_ch5.adb
	(Expand_Assign_Array_Loop_Or_Bitfield): Make the checks for
	volatile and independent objects more precise.
2022-09-29 11:08:46 +02:00
Piotr Trojanek
01ea0437ea ada: Fix checking of Refined_State with nested package renamings
When collecting package state declared in package body, we should only
recursively examine the visible part of nested packages while ignoring other
entities related to packages (e.g. package bodies or package renamings).

gcc/ada/

	* sem_util.adb (Collect_Visible_States): Ignore package renamings.
2022-09-29 11:08:46 +02:00
Richard Biener
a1cd4d52d6 tree-optimization/105646 - re-interpret always executed in uninit diag
The following fixes PR105646, not diagnosing

int f1();
int f3(){
    auto const & a = f1();
    bool v3{v3};
    return a;
}

with optimization because the early uninit diagnostic pass only
diagnoses always executed cases.  The patch does this by
re-interpreting what always executed means and choosing to
ignore exceptional and abnormal control flow for this.  At the
same time it improves things as suggested in a comment - when
the value-numbering run done without optimizing figures there's
a fallthru path, consider blocks on it as always executed.

	PR tree-optimization/105646
	* tree-ssa-uninit.cc (warn_uninitialized_vars): Pre-compute
	the set of fallthru reachable blocks from function entry
	and use that to determine wlims.always_executed.

	* g++.dg/uninit-pr105646.C: New testcase.
2022-09-29 09:34:00 +02:00
liuhongt
f758d447d7 Check nonlinear iv in vect_can_advance_ivs_p.
vectorizable_nonlinear_induction doesn't always guard
vect_peel_nonlinear_iv_init when it's called by
vect_update_ivs_after_vectorizer.
It's supposed to be guarded by vect_can_advance_ivs_p.

gcc/ChangeLog:

	PR tree-optimization/107055
	* tree-vect-loop-manip.cc (vect_can_advance_ivs_p): Check for
	nonlinear induction variables.
	* tree-vect-loop.cc (vect_can_peel_nonlinear_iv_p): New
	functions.
	(vectorizable_nonlinear_induction): Put part codes into
	vect_can_peel_nonlinear_iv_p.
	* tree-vectorizer.h (vect_can_peel_nonlinear_iv_p): Declare.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr107055.c: New test.
2022-09-29 15:22:47 +08:00
GCC Administrator
9e79a25b66 Daily bump. 2022-09-29 00:16:38 +00:00
Jonathan Wakely
d01f112de4 libstdc++: Disable volatile-qualified std::bind for C++20
LWG 2487 added a precondition to std::bind for C++17, making
volatile-qualified uses undefined. We still support it, but with a
deprecated warning.

P1065R2 made it explicitly ill-formed for C++20, so we should no longer
accept it as deprecated. This implements that change.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/evolution.xml: Document std::bind API
	changes.
	* doc/xml/manual/intro.xml: Document LWG 2487 status.
	* doc/xml/manual/using.xml: Clarify default value of
	_GLIBCXX_USE_DEPRECATED.
	* doc/html/*: Regenerate.
	* include/std/functional (_Bind::operator()(Args&&...) volatile)
	(_Bind::operator()(Args&&...) const volatile)
	(_Bind_result::operator()(Args&&...) volatile)
	(_Bind_result::operator()(Args&&...) const volatile): Replace
	with deleted overload for C++20 and later.
	* testsuite/20_util/bind/cv_quals.cc: Check for deprecated
	warnings in C++17.
	* testsuite/20_util/bind/cv_quals_2.cc: Likewise, and check for
	ill-formed in C++20.
2022-09-29 00:33:46 +01:00
Jonathan Wakely
fa9bda3ea4 libstdc++: Make INVOKE<R> refuse to create dangling references [PR70692]
This is the next part of the library changes from P2255R2. This makes
INVOKE<R> ill-formed if converting the INVOKE expression to R would bind
a reference to a temporary object.

The is_invocable_r trait is now false if the invocation would create a
dangling reference. This is done by adding the dangling check to the
__is_invocable_impl partial specialization used for INVOKE<R>
expressions. This change also slightly simplifies the nothrow checking
recently added to that partial specialization.

This change also removes the is_invocable_r checks from the pre-C++17
implementation of std::__invoke_r, because there is no need for it to be
SFINAE-friendly. None of our C++11 and C++14 uses of INVOKE<R> require
those constraints. The std::function constructor needs to check
is_invocable_r, but that's already done explicitly, so we don't need to
recheck when calling __is_invoke_r in std::function::operator(). The
other uses of std::__is_invoke_r do not need to be constrained and can
just be ill-formed if the INVOKE<R> expression is ill-formed.

libstdc++-v3/ChangeLog:

	PR libstdc++/70692
	* include/bits/invoke.h [__cplusplus < 201703] (__invoke_r):
	Remove is_invocable and is_convertible constraints.
	* include/std/type_traits (__is_invocable_impl::_S_conv): Use
	non-deduced context for parameter.
	(__is_invocable_impl::_S_test): Remove _Check_noex template
	parameter and use deduced noexcept value in its place. Add bool
	parameter to detect dangling references.
	(__is_invocable_impl::type): Adjust call to _S_test to avoid
	deducing unnecessary noexcept property..
	(__is_invocable_impl::__nothrow_type): Rename to ...
	(__is_invocable_impl::__nothrow_conv): ... this. Adjust call
	to _S_test to deduce noexcept property.
	* testsuite/20_util/bind/dangling_ref.cc: New test.
	* testsuite/20_util/function/cons/70692.cc: New test.
	* testsuite/20_util/function_objects/invoke/dangling_ref.cc:
	New test.
	* testsuite/20_util/is_invocable/dangling_ref.cc: New test.
	* testsuite/30_threads/packaged_task/cons/dangling_ref.cc:
	New test.
2022-09-29 00:33:36 +01:00
Eugene Rozenfeld
f1adf45b17 Add instruction level discriminator support.
This is the first in a series of patches to enable discriminator support
in AutoFDO.

This patch switches to tracking discriminators per statement/instruction
instead of per basic block. Tracking per basic block was problematic since
not all statements in a basic block needed a discriminator and, also, later
optimizations could move statements between basic blocks making correlation
during AutoFDO compilation unreliable. Tracking per statement also allows
us to assign different discriminators to multiple function calls in the same
basic block. A subsequent patch will add that support.

The idea of this patch is based on commit 4c311d95cf6d9519c3c20f641cc77af7df491fdf
by Dehao Chen in vendors/google/heads/gcc-4_8 but uses a slightly different
approach. In Dehao's work special (normally unused) location ids and side tables
were used to keep track of locations with discriminators. Things have changed
since then and I don't think we have unused location ids anymore. Instead,
I made discriminators a part of ad-hoc locations.

The difference from Dehao's work also includes support for discriminator
reading/writing in lto streaming and in modules.

Tested on x86_64-pc-linux-gnu.

gcc/ChangeLog:

	* basic-block.h: Remove discriminator from basic blocks.
	* cfghooks.cc (split_block_1): Remove discriminator from basic blocks.
	* final.cc (final_start_function_1): Switch from per-bb to per statement
	discriminator.
	(final_scan_insn_1): Don't keep track of basic block discriminators.
	(compute_discriminator): Switch from basic block discriminators to
	instruction discriminators.
	(insn_discriminator): New function to return instruction discriminator.
	(notice_source_line): Use insn_discriminator.
	* gimple-pretty-print.cc (dump_gimple_bb_header): Remove dumping of
	basic block discriminators.
	* gimple-streamer-in.cc (input_bb): Remove reading of basic block
	discriminators.
	* gimple-streamer-out.cc (output_bb): Remove writing of basic block
	discriminators.
	* input.cc (make_location): Pass 0 discriminator to COMBINE_LOCATION_DATA.
	(location_with_discriminator): New function to combine locus with
	a discriminator.
	(has_discriminator): New function to check if a location has a discriminator.
	(get_discriminator_from_loc): New function to get the discriminator
	from a location.
	* input.h: Declarations of new functions.
	* lto-streamer-in.cc (cmp_loc): Use discriminators in location comparison.
	(apply_location_cache): Keep track of current discriminator.
	(input_location_and_block): Read discriminator from stream.
	* lto-streamer-out.cc (clear_line_info): Set current discriminator to
	UINT_MAX.
	(lto_output_location_1): Write discriminator to stream.
	* lto-streamer.h: Add discriminator to cached_location.
	Add current_discr to lto_location_cache.
	Add current_discr to output_block.
	* print-rtl.cc (print_rtx_operand_code_i): Print discriminator.
	* rtl.h: Add extern declaration of insn_discriminator.
	* tree-cfg.cc (assign_discriminator): New function to assign a unique
	discriminator value to all statements in a basic block that have the given
	line number.
	(assign_discriminators): Assign discriminators to statement locations.
	* tree-pretty-print.cc (dump_location): Dump discriminators.
	* tree.cc (set_block): Preserve discriminator when setting block.
	(set_source_range): Preserve discriminator when setting source range.

gcc/cp/ChangeLog:
	* module.cc (write_location): Write discriminator.
	(read_location): Read discriminator.

libcpp/ChangeLog:

	* include/line-map.h: Add discriminator to location_adhoc_data.
	(get_combined_adhoc_loc): Add discriminator parameter.
	(get_discriminator_from_adhoc_loc): Add external declaration.
	(get_discriminator_from_loc): Add external declaration.
	(COMBINE_LOCATION_DATA): Add discriminator parameter.
	* lex.cc (get_location_for_byte_range_in_cur_line) Pass 0 discriminator
	in a call to COMBINE_LOCATION_DATA.
	(warn_about_normalization): Pass 0 discriminator in a call to
	COMBINE_LOCATION_DATA.
	(_cpp_lex_direct): Pass 0 discriminator in a call to
	COMBINE_LOCATION_DATA.
	* line-map.cc (location_adhoc_data_hash): Use discriminator compute
	location_adhoc_data hash.
	(location_adhoc_data_eq): Use discriminator when comparing
	location_adhoc_data.
	(can_be_stored_compactly_p): Check discriminator to determine
	compact storage.
	(get_combined_adhoc_loc): Add discriminator parameter.
	(get_discriminator_from_adhoc_loc): New function to get the discriminator
	from an ad-hoc location.
	(get_discriminator_from_loc): New function to get the discriminator
	from a location.

gcc/testsuite/ChangeLog:

	* c-c++-common/ubsan/pr85213.c: Pass -gno-statement-frontiers.
2022-09-28 14:25:18 -07:00
Nathan Sidwell
9f65eecdbe c++: Add DECL_NTTP_OBJECT_P lang flag
VAR_DECLs for NTTPs need to be handled specially by module streaming,
in the same manner to type info decls.  This reworks their handling to
allow that work to drop in.  We use DECL_LANG_FLAG_5 to indicate such
decls (I didn't notice template_parm_object_p, which looks at the
mangled name -- anyway a bit flag on the node is better, IMHO).  We
break apart the creation routine, so there's now an entry point the
module machinery can use directly.

	gcc/cp/
	* cp-tree.h (DECL_NTTP_OBJECT_P): New.
	(template_parm_object_p): Delete.
	(build_template_parm_object): Declare.
	* cxx-pretty-print.cc (pp_cx_template_argument_list): Use DECL_NTTP_OBJECT_P.
	* error.cc (dump_simple_decl): Likewise.
	* mangle.cc (write_template_arg): Likewise.
	* pt.cc (template_parm_object_p): Delete.
	(create_template_parm_object): Separated out checking from ...
	(get_template_parm_object): ... this, new external entry point.
2022-09-28 13:43:07 -07:00
H.J. Lu
db288230db i386: Mark XMM4-XMM6 as clobbered by encodekey128/encodekey256
encodekey128 and encodekey256 operations clear XMM4-XMM6.  But it is
documented that XMM4-XMM6 are reserved for future usages and software
should not rely upon them being zeroed.  Change encodekey128 and
encodekey256 to clobber XMM4-XMM6.

gcc/

	PR target/107061
	* config/i386/predicates.md (encodekey128_operation): Check
	XMM4-XMM6 as clobbered.
	(encodekey256_operation): Likewise.
	* config/i386/sse.md (encodekey128u32): Clobber XMM4-XMM6.
	(encodekey256u32): Likewise.

gcc/testsuite/

	PR target/107061
	* gcc.target/i386/keylocker-encodekey128.c: Don't check
	XMM4-XMM6.
	* gcc.target/i386/keylocker-encodekey256.c: Likewise.
2022-09-28 11:15:31 -07:00
Ju-Zhe Zhong
03f3365742 RISC-V: Add ABI-defined RVV types.
gcc/ChangeLog:

	* config.gcc: Add riscv-vector-builtins.o.
	* config/riscv/riscv-builtins.cc (riscv_init_builtins): Add RVV builtin function.
	* config/riscv/riscv-protos.h (riscv_v_ext_enabled_vector_mode_p): New function.
	* config/riscv/riscv.cc (ENTRY): New macro.
	(riscv_v_ext_enabled_vector_mode_p): New function.
	(riscv_mangle_type): Add RVV mangle.
	(riscv_vector_mode_supported_p): Adjust RVV machine mode.
	(riscv_verify_type_context): Add context check for RVV.
	(riscv_vector_alignment): Add RVV alignment target hook support.
	(TARGET_VECTOR_MODE_SUPPORTED_P): New target hook support.
	(TARGET_VERIFY_TYPE_CONTEXT): Ditto.
	(TARGET_VECTOR_ALIGNMENT): Ditto.
	* config/riscv/t-riscv: Add riscv-vector-builtins.o
	* config/riscv/riscv-vector-builtins.cc: New file.
	* config/riscv/riscv-vector-builtins.def: New file.
	* config/riscv/riscv-vector-builtins.h: New file.
	* config/riscv/riscv-vector-switch.def: New file.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/abi-1.c: New test.
	* gcc.target/riscv/rvv/base/abi-2.c: New test.
	* gcc.target/riscv/rvv/base/abi-3.c: New test.
	* gcc.target/riscv/rvv/base/abi-4.c: New test.
	* gcc.target/riscv/rvv/base/abi-5.c: New test.
	* gcc.target/riscv/rvv/base/abi-6.c: New test.
	* gcc.target/riscv/rvv/base/abi-7.c: New test.
	* gcc.target/riscv/rvv/rvv.exp: New test.
2022-09-29 01:32:14 +08:00
Stefan Schulze Frielinghaus
5d7be27bf7 var-tracking: Add entry values up to max register mode
For parameter of type integer which do not consume a whole register
(modulo sign/zero extension) this patch adds entry values up to maximal
register mode.

gcc/ChangeLog:

	* var-tracking.cc (vt_add_function_parameter): Add entry values
	up to maximal register mode.
2022-09-28 17:27:11 +02:00
Stefan Schulze Frielinghaus
d0b00b63a3 cselib: Keep track of further subvalue relations
Whenever a new cselib value is created check whether a smaller value
exists which is contained in the bigger one.  If so add a subreg
relation to locs of the smaller one.

gcc/ChangeLog:

	* cselib.cc (new_cselib_val): Keep track of further subvalue
	relations.
2022-09-28 17:27:11 +02:00
Andrea Corallo
5e9c4ed903 arm: Define __ARM_FEATURE_AES and __ARM_FEATURE_SHA2 when march +crypto is selected
Hi all,

this patch fixes the missing definition of __ARM_FEATURE_AES and
__ARM_FEATURE_SHA2 when AES SHA1 & SHA2 crypto instructions are
available [1] (read when march +crypto is selected).

Okay for master?

Thanks

  Andrea

[1] <https://raw.githubusercontent.com/ARM-software/acle/main/main/acle.md>

gcc/ChangeLog

2022-09-14  Andrea Corallo  <andrea.corallo@arm.com>

	* config/arm/arm-c.cc (arm_cpu_builtins): Define
	__ARM_FEATURE_AES and __ARM_FEATURE_SHA2.

gcc/testsuite/ChangeLog

2022-09-14  Andrea Corallo  <andrea.corallo@arm.com>

	* gcc.target/arm/attr-crypto.c: Update test.
2022-09-28 15:10:17 +02:00
Xi Ruoyao
b48d7ff357
LoongArch: Use UNSPEC for fmin/fmax RTL pattern [PR105414]
I made a mistake defining fmin/fmax RTL patterns in r13-2085: I used
smin and smax in the definition mistakenly.  This causes the optimizer
to perform constant folding as if fmin/fmax was "really" smin/smax
operations even with -fsignaling-nans.  Then pr105414.c fails.

We don't have fmin/fmax RTL codes for now (PR107013) so we can only use
an UNSPEC for fmin and fmax patterns.

gcc/ChangeLog:

	PR tree-optimization/105414
	* config/loongarch/loongarch.md (UNSPEC_FMAX): New unspec.
	(UNSPEC_FMIN): Likewise.
	(fmax<mode>3): Use UNSPEC_FMAX instead of smax.
	(fmin<mode>3): Use UNSPEC_FMIN instead of smin.
2022-09-28 17:55:01 +08:00
Torbjörn SVENSSON
9a8212db2d testsuite: Skip intrinsics test if arm
In the test cases, it's clearly written that intrinsics are not
implemented on arm*. A simple xfail does not help since there are
link error and that would cause an UNRESOLVED testcase rather than
XFAIL.
By changing to dg-skip-if, the entire test case is omitted.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/advsimd-intrinsics/vld1x2.c: Rephrase
	to unimplemented.
	* gcc.target/aarch64/advsimd-intrinsics/vld1x3.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vld1x4.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vst1x2.c: Replace
	dg-xfail-if with dg-skip-if.
	* gcc.target/aarch64/advsimd-intrinsics/vst1x3.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vst1x4.c: Likewise.

Co-Authored-By: Yvan ROUX  <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
2022-09-28 11:03:03 +02:00
Lulu Cheng
646ce0056e LoongArch: Fixed a typo in the comment information of the function loongarch_asan_shadow_offset.
gcc/ChangeLog:

	* config/loongarch/loongarch.cc (loongarch_asan_shadow_offset):
	Fixed typo in "asan_mapping.h".
2022-09-28 16:44:27 +08:00
Tobias Burnus
175a89d123 libgomp.texi: Status 'P' for 'assume', remove duplicated line
libgomp/
	* libgomp.texi (OpenMP 5.1): Mark 'assume' as implemented
	for C/C++. Remove duplicated 'begin declare target' entry.
2022-09-28 10:24:58 +02:00
Lulu Cheng
fa4bc21bac LoongArch: Libitm add LoongArch support.
Co-Authored-By: Yang Yujie <yangyujie@loongson.cn>

libitm/ChangeLog:

	* configure.tgt: Add loongarch support.
	* config/loongarch/asm.h: New file.
	* config/loongarch/sjlj.S: New file.
	* config/loongarch/target.h: New file.
2022-09-28 15:02:14 +08:00
H.J. Lu
a25982ada5 stack-protector: Check stack canary before throwing exception
Check stack canary before throwing exception to avoid stack corruption.

gcc/

	PR middle-end/58245
	* calls.cc: Include "tree-eh.h".
	(expand_call): Check stack canary before throwing exception.

gcc/testsuite/

	PR middle-end/58245
	* g++.dg/fstack-protector-strong.C: Adjusted.
	* g++.dg/pr58245-1.C: New test.
2022-09-27 18:29:20 -07:00
Eugene Rozenfeld
28390443ff Fix AutoFDO tests to not look for hot/cold splitting.
AutoFDO counts are not reliable and we are currently not
performing hot/cold splitting based on them. This change adjusts
several tree-prof tests not to check for hot/cold splitting
when run with AutoFDO.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-prof/cold_partition_label.c: Don't check for hot/cold splitting with AutoFDO.
	* gcc.dg/tree-prof/section-attr-1.c: Don't check for hot/cold splitting with AutoFDO.
	* gcc.dg/tree-prof/section-attr-2.c: Don't check for hot/cold splitting with AutoFDO.
	* gcc.dg/tree-prof/section-attr-3.c: Don't check for hot/cold splitting with AutoFDO.
2022-09-27 17:36:19 -07:00
GCC Administrator
1f16a020ac Daily bump. 2022-09-28 00:17:27 +00:00
Eugene Rozenfeld
6bf473089f Fix profile count comparison.
The comparison was incorrect when the counts weren't PRECISE.
For example, crossmodule-indir-call-topn-1.c was failing
with AutoFDO: when count_sum is 0 with quality AFDO,
count_sum > profile_count::zero() evaluates to true. Taking that
branch then leads to an assert in the call to to_sreal().

Tested on x86_64-pc-linux-gnu.

gcc/ChangeLog:

	* ipa-cp.cc (good_cloning_opportunity_p): Fix profile count comparison.
2022-09-27 16:46:42 -07:00
Marek Polacek
772d532e0b c++: Implement C++23 P2266R1, Simpler implicit move [PR101165]
This patch implements https://wg21.link/p2266, which, once again,
changes the implicit move rules.  Here's a brief summary of various
changes in this area:

r125211: Introduced moving from certain lvalues when returning them
r171071: CWG 1148, enable move from value parameter on return
r212099: CWG 1579, it's OK to call a converting ctor taking an rvalue
r251035: CWG 1579, do maybe-rvalue overload resolution twice
r11-2411: Avoid calling const copy ctor on implicit move
r11-2412: C++20 implicit move changes, remove the fallback overload
          resolution, allow move on throw of parameters and implicit
	  move of rvalue references

P2266 enables the implicit move even for functions that return references.
That is, we will now perform a move in

  X&& foo (X&& x) {
    return x;
  }

P2266 also removes the fallback overload resolution, but this was
resolved by r11-2412: we only do convert_for_initialization with
LOOKUP_PREFER_RVALUE in C++17 and older.
P2266 also says that a returned move-eligible id-expression is always an
xvalue.  This required some further short, but nontrivial changes,
especially when it comes to deduction, because we have to pay attention
to whether we have auto, auto&& (which is like T&&), or decltype(auto)
with (un)parenthesized argument.  In C++23,

  decltype(auto) f(int&& x) { return (x); }
  auto&& f(int x) { return x; }

both should deduce to 'int&&' but

  decltype(auto) f(int x) { return x; }

should deduce to 'int'.  A cornucopia of tests attached.  I've also
verified that we behave like clang++.

xvalue_p seemed to be broken: since the introduction of clk_implicit_rval,
it cannot use '==' when checking for clk_rvalueref.

Since this change breaks code, it's only enabled in C++23.  In
particular, this code will not compile in C++23:

  int& g(int&& x) { return x; }

because x is now treated as an rvalue, and you can't bind a non-const lvalue
reference to an rvalue.

This patch also fixes PR106882 (the check_return_expr changes).

	PR c++/101165
	PR c++/106882

gcc/c-family/ChangeLog:

	* c-cppbuiltin.cc (c_cpp_builtins): Define __cpp_implicit_move.

gcc/cp/ChangeLog:

	* call.cc (reference_binding): Check clk_implicit_rval in C++20 only.
	* cp-tree.h (unparenthesized_id_or_class_member_access_p): Declare.
	* pt.cc (unparenthesized_id_or_class_member_access_p): New function,
	broken out of...
	(do_auto_deduction): ...here.  Use it.  In C++23, maybe call
	treat_lvalue_as_rvalue_p.
	* tree.cc (xvalue_p): Check & clk_rvalueref, not == clk_rvalueref.
	* typeck.cc (check_return_expr): Allow implicit move for functions
	returning a reference as well, or when the return value type is not
	a scalar type.

gcc/testsuite/ChangeLog:

	* g++.dg/conversion/pr41426.C: Add dg-error for C++23.
	* g++.dg/cpp0x/elision_weak.C: Likewise.
	* g++.dg/cpp0x/move-return3.C: Only link in c++20_down.
	* g++.dg/cpp1y/decltype-auto2.C: Add dg-error for C++23.
	* g++.dg/cpp1y/lambda-generic-89419.C: Likewise.
	* g++.dg/cpp23/feat-cxx2b.C: Test __cpp_implicit_move.
	* g++.dg/gomp/pr56217.C: Only compile in c++20_down.
	* g++.dg/warn/Wno-return-local-addr.C: Add dg-error for C++23.
	* g++.dg/warn/Wreturn-local-addr.C: Adjust dg-error.
	* g++.old-deja/g++.brendan/crash55.C: Add dg-error for C++23.
	* g++.old-deja/g++.jason/temporary2.C: Likewise.
	* g++.old-deja/g++.mike/p2846b.C: Adjust.
	* g++.dg/cpp1y/decltype-auto6.C: New test.
	* g++.dg/cpp23/decltype1.C: New test.
	* g++.dg/cpp23/decltype2.C: New test.
	* g++.dg/cpp23/elision1.C: New test.
	* g++.dg/cpp23/elision2.C: New test.
	* g++.dg/cpp23/elision3.C: New test.
	* g++.dg/cpp23/elision4.C: New test.
	* g++.dg/cpp23/elision5.C: New test.
	* g++.dg/cpp23/elision6.C: New test.
	* g++.dg/cpp23/elision7.C: New test.
2022-09-27 18:49:25 -04:00
Harald Anlauf
78bc6497fc Fortran: error recovery while simplifying intrinsic UNPACK [PR107054]
gcc/fortran/ChangeLog:

	PR fortran/107054
	* simplify.cc (gfc_simplify_unpack): Replace assert by condition
	that terminates simplification when there are not enough elements
	in the constructor of argument VECTOR.

gcc/testsuite/ChangeLog:

	PR fortran/107054
	* gfortran.dg/pr107054.f90: New test.
2022-09-27 21:39:40 +02:00
Ian Lance Taylor
e73d9fcafb runtime: portable access to sigev_notify_thread_id
Previously, libgo relied on the _sigev_un implementation-specific
field in struct sigevent, which is only available on glibc.
This patch uses the sigev_notify_thread_id macro instead which is
mandated by timer_create(2). In theory, this should work with any libc
implementation for Linux. Unfortunately, there is an open glibc bug
as glibc does not define this macro. For this reason, a glibc-specific
workaround is required. Other libcs (such as musl) define the macro
and don't require the workaround.

See https://sourceware.org/bugzilla/show_bug.cgi?id=27417

This makes libgo compatible with musl libc.

Based on patch by Sören Tempel.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/434755
2022-09-27 09:30:23 -07:00
melonedo
f38162977e runtime: synchronize empty struct field handling
In GCCGO and gollvm, the logic for allocating one byte for the last field is:
1. the last field has zero size
2. the struct itself does not have zero size
3. the last field is not blank
this commit adds the last two conditions to runtime.structToFFI.

For golang/go#55146

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/431735
2022-09-27 09:28:39 -07:00
Kim Kuparinen
0b2706ac0e docs: update abi version info
gcc/
	* doc/invoke.texi: Update ABI version info.
2022-09-27 11:04:25 -04:00
Aldy Hernandez
001c60ccfe range-ops: Calculate the popcount of a singleton.
The legacy popcount folding didn't actually fold singleton ranges.
I don't think anyone noticed because there are match.pd patterns that
fold __builtin_popcount using the global nonzero bits set by CCP.

It's good form to handle this, even without CCP's help.

Tested on x86-64 Linux.

gcc/ChangeLog:

	* gimple-range-op.cc (cfn_popcount): Calculate the popcount of a
	singleton.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/popcount6b.c: New test.
2022-09-27 17:02:11 +02:00
Marek Polacek
971bc0aae9 c++: Don't quote nothrow in diagnostic
In <https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602057.html>
Jason noticed that we quote "nothrow" in diagnostics even though it's
not a keyword in C++.  This patch removes the quotes and also drops
"nothrow" from c_keywords.

gcc/c-family/ChangeLog:

	* c-format.cc (c_keywords): Drop nothrow.

gcc/cp/ChangeLog:

	* constraint.cc (diagnose_trait_expr): Say "nothrow" without quotes
	rather than in quotes.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-traits3.C: Adjust expected diagnostics.
2022-09-27 09:23:43 -04:00
Jonathan Wakely
3f7eea4411 c++: Make __is_{,nothrow_}convertible SFINAE on access [PR107049]
The is_convertible built-ins should return false if the conversion fails
an access check, not report an error.

	PR c++/107049

gcc/cp/ChangeLog:

	* method.cc (is_convertible_helper): Use access check sentinel.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/is_convertible4.C: New test.
	* g++.dg/ext/is_nothrow_convertible4.C: New test.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/is_convertible/requirements/access.cc: New
	test.
2022-09-27 11:59:53 +01:00
Jonathan Wakely
614e5696d7 libstdc++: Adjust deduction guides for static operator() [PR106651]
Adjust the deduction guides for std::function and std::packaged_task to
work with static call operators. This finishes the implementation of
P1169R4 for C++23.

libstdc++-v3/ChangeLog:

	PR c++/106651
	* include/bits/std_function.h (__function_guide_t): New alias
	template.
	[__cpp_static_call_operator] (__function_guide_static_helper):
	New class template.
	(function): Use __function_guide_t in deduction guide.
	* include/std/future (packaged_task): Use __function_guide_t in
	deduction guide.
	* testsuite/20_util/function/cons/deduction_c++23.cc: New test.
	* testsuite/30_threads/packaged_task/cons/deduction_c++23.cc:
	New test.
2022-09-27 11:59:53 +01:00
Jakub Jelinek
b939a5cc41 fixincludes: FIx up for Debian/Ubuntu includes
As reported by Tobias, my C++ _Float{16,32,64,128,32x,64x,128x} support
patch broke Debian/Ubuntu bootstraps.  The problem is that there
glibc bits/floatn.h and bits/floatn-common.h isn't in /usr/include/
directly, but in a subdirectory like /usr/include/x86_64-linux-gnu/
Seems other fixinclude rules for bits/* headers use
files = bits/whatever.h, "*/bits/whatever.h";
so this patch just follows the suit.

2022-06-27  Jakub Jelinek  <jakub@redhat.com>

	* inclhack.def (glibc_cxx_floatn_1, glibc_cxx_floatn_2,
	glibc_cxx_floatn_3): Add to files also "*/bits/floatn.h"
	and "*/bits/floatn-common.h".
	* fixincl.x: Regenerated.
2022-09-27 12:33:23 +02:00
Iain Buclaw
c8dfa79c99 d: Merge upstream dmd d579c467c1, phobos 88aa69b14.
D front-end changes:

    - Throwing from contracts of `nothrow' functions has been
      deprecated, as this breaks the guarantees of `nothrow'.
    - Added language support for initializing the interior pointer of
      associative arrays using `new' keyword.

Phobos changes:

    - The std.digest.digest module has been removed.
    - The std.xml module has been removed.

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd d579c467c1.
	* decl.cc (layout_struct_initializer): Update for new front-end
	interface.
	* expr.cc (ExprVisitor::visit (AssignExp *)): Remove lowering of array
	assignments.
	(ExprVisitor::visit (NewExp *)): Add new lowering of new'ing
	associative arrays to an _aaNew() library call.
	* runtime.def (ARRAYSETASSIGN): Remove.
	(AANEW): Define.

libphobos/ChangeLog:

	* libdruntime/MERGE: Merge upstream druntime d579c467c1.
	* libdruntime/Makefile.am (DRUNTIME_DSOURCES): Remove
	rt/arrayassign.d.
	* libdruntime/Makefile.in: Regenerate.
	* src/MERGE: Merge upstream phobos 88aa69b14.
	* src/Makefile.am (PHOBOS_DSOURCES): Remove std/digest/digest.d,
	std/xml.d.
	* src/Makefile.in: Regenerate.
2022-09-27 10:50:18 +02:00
Aldy Hernandez
be4a6551ed irange: keep better track of powers of 2.
When setting the nonzero bits to a mask containing only one bit, set
the range immediately, as it can be devined from the mask.  This helps
us keep better track of powers of two.

For example, with this patch a nonzero mask of 0x8000 is set to a
range of [0,0][0x8000,0x8000] with a nonzero mask of 0x8000.

gcc/ChangeLog:

	* value-range.cc (irange::set_nonzero_bits): Set range when known.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/popcount6.c: New test.
2022-09-27 10:43:11 +02:00
Aldy Hernandez
1db05e1a1c Add an irange setter for wide_ints.
Just the same way as we have real_value setters for franges, we should
have a wide_int version for irange.  This matches the irange
constructor for wide_ints, and paves the way for the eventual
conversion of irange to wide ints.

gcc/ChangeLog:

	* value-range.h (irange::set): New version taking wide_int_ref.
2022-09-27 10:43:11 +02:00
Jakub Jelinek
303976a607 c++: Implement C++23 P1169R4 - static operator() [PR106651]
The following patch attempts to implement C++23 P1169R4 - static operator()
paper's compiler side (there is some small library side too not implemented
yet).  This allows static members as user operator() declarations and
static specifier on lambdas without lambda capture.
The synthetized conversion operator changes for static lambdas as it can just
return the operator() static method address, doesn't need to create a thunk
for it.
The change in call.cc (joust) is to avoid ICEs because we assumed that len
could be different only if both candidates are direct calls but it can be
one direct and one indirect call, and to implement the
[over.match.best.general]/1 and [over.best.ics.general] changes from
the paper (implemented always as Jason is sure it doesn't make a difference
in C++20 and earlier unless static member function operator() or
static lambda which we accept with pedwarn in earlier standards too appears
and my testing confirmed that).

2022-09-27  Jakub Jelinek  <jakub@redhat.com>

	PR c++/106651
gcc/c-family/
	* c-cppbuiltin.cc (c_cpp_builtins): Predefine
	__cpp_static_call_operator=202207L for C++23.
gcc/cp/
	* cp-tree.h (LAMBDA_EXPR_STATIC_P): Implement C++23
	P1169R4 - static operator().  Define.
	* parser.cc (CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR): Document
	that it also allows static.
	(cp_parser_lambda_declarator_opt): Handle static lambda specifier.
	(cp_parser_decl_specifier_seq): Allow RID_STATIC for
	CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR.
	* decl.cc (grok_op_properties): If operator() isn't a method,
	use a different error wording, if it is static member function,
	allow it (for C++20 and older with a pedwarn unless it is
	a lambda function or template instantiation).
	* call.cc (joust): Don't ICE if one candidate is static member
	function and the other is an indirect call.  If the parameter
	conversion on the other candidate is user defined conversion,
	ellipsis or bad conversion, make static member function candidate
	a winner for that parameter.
	* lambda.cc (maybe_add_lambda_conv_op): Handle static lambdas.
	* error.cc (dump_lambda_function): Print static for static lambdas.
gcc/testsuite/
	* g++.dg/template/error30.C: Adjust expected diagnostics.
	* g++.dg/cpp1z/constexpr-lambda13.C: Likewise.
	* g++.dg/cpp23/feat-cxx2b.C: Test __cpp_static_call_operator.
	* g++.dg/cpp23/static-operator-call1.C: New test.
	* g++.dg/cpp23/static-operator-call2.C: New test.
	* g++.old-deja/g++.jason/operator.C: Adjust expected diagnostics.
2022-09-27 08:36:28 +02:00
Jakub Jelinek
cb8f25c5dc reassoc: Handle OFFSET_TYPE like POINTER_TYPE in optimize_range_tests_cmp_bitwise [PR107029[
As the testcase shows, OFFSET_TYPE needs the same treatment as
POINTER_TYPE/REFERENCE_TYPE, otherwise we fail the same during the
newly added verification.  OFFSET_TYPE is signed though, so unlike
POINTER_TYPE/REFERENCE_TYPE it can also trigger with the
x < 0 && y < 0 && z < 0 to (x | y | z) < 0
optimization.

2022-09-27  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/107029
	* tree-ssa-reassoc.cc (optimize_range_tests_cmp_bitwise): Treat
	OFFSET_TYPE like POINTER_TYPE, except that OFFSET_TYPE may be
	signed and so can trigger even the (b % 4) == 3 case.

	* g++.dg/torture/pr107029.C: New test.
2022-09-27 08:26:18 +02:00
Jakub Jelinek
4790fe99f2 openmp: Add OpenMP assume, assumes and begin/end assumes support
The following patch implements OpenMP 5.1
 #pragma omp assume
 #pragma omp assumes
and
 #pragma omp begin assumes
 #pragma omp end assumes
directive support for C and C++.  Currently it doesn't remember
anything from the assumption clauses for later, so is mainly
to support the directives and diagnose errors in their use.
If the recently posted C++23 [[assume (cond)]]; support makes it
in, the intent is that this can be easily adjusted at least for
the #pragma omp assume directive with holds clause(s) to use
the same infrastructure.  Now, C++23 portable assumptions are slightly
different from OpenMP 5.1 assumptions' holds clause in that C++23
assumption holds just where it appears, while OpenMP 5.1 assumptions
hold everywhere in the scope of the directive.  For assumes
directive which can appear at file or namespace scope it is the whole
TU and everything that functions from there call at runtime, for
begin assumes/end assumes pair all the functions in between those
directives and everything they call and for assume directive the
associated (currently structured) block.  I have no idea how to
represents such holds to be usable for optimizers, except to
make
 #pragma omp assume holds (cond)
block;
expand essentially to
[[assume (cond)]];
block;
or
[[assume (cond)]];
block;
[[assume (cond)]];
for now.  Except for holds clause, the other assumptions are
OpenMP related, I'd say we should brainstorm where it would be
useful to optimize based on such information (I guess e.g. in target
regions it easily could) and only when we come up with something
like that think about how to propagate the assumptions to the optimizers.

2022-09-27  Jakub Jelinek  <jakub@redhat.com>

gcc/c-family/
	* c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_ASSUME,
	PRAGMA_OMP_ASSUMES and PRAGMA_OMP_BEGIN.  Rename
	PRAGMA_OMP_END_DECLARE_TARGET to PRAGMA_OMP_END.
	* c-pragma.cc (omp_pragmas): Add assumes and begin.
	For end rename PRAGMA_OMP_END_DECLARE_TARGET to PRAGMA_OMP_END.
	(omp_pragmas_simd): Add assume.
	* c-common.h (c_omp_directives): Declare.
	* c-omp.cc (omp_directives): Rename to ...
	(c_omp_directives): ... this.  No longer static.  Uncomment
	assume, assumes, begin assumes and end assumes entries.
	In end declare target entry rename PRAGMA_OMP_END_DECLARE_TARGET
	to PRAGMA_OMP_END.
	(c_omp_categorize_directive): Adjust for omp_directives to
	c_omp_directives renaming.
gcc/c/
	* c-lang.h (current_omp_begin_assumes): Declare.
	* c-parser.cc: Include bitmap.h.
	(c_parser_omp_end_declare_target): Rename to ...
	(c_parser_omp_end): ... this.  Handle also end assumes.
	(c_parser_omp_begin, c_parser_omp_assumption_clauses,
	c_parser_omp_assumes, c_parser_omp_assume): New functions.
	(c_parser_translation_unit): Also diagnose #pragma omp begin assumes
	without corresponding #pragma omp end assumes.
	(c_parser_pragma): Use %s in may only be used at file scope
	diagnostics to decrease number of translatable messages.  Handle
	PRAGMA_OMP_BEGIN and PRAGMA_OMP_ASSUMES.  Handle PRAGMA_OMP_END
	rather than PRAGMA_OMP_END_DECLARE_TARGET and call c_parser_omp_end
	for it rather than c_parser_omp_end_declare_target.
	(c_parser_omp_construct): Handle PRAGMA_OMP_ASSUME.
	* c-decl.cc (current_omp_begin_assumes): Define.
gcc/cp/
	* cp-tree.h (struct omp_begin_assumes_data): New type.
	(struct saved_scope): Add omp_begin_assumes member.
	* parser.cc: Include bitmap.h.
	(cp_parser_omp_assumption_clauses, cp_parser_omp_assume,
	cp_parser_omp_assumes, cp_parser_omp_begin): New functions.
	(cp_parser_omp_end_declare_target): Rename to ...
	(cp_parser_omp_end): ... this.  Handle also end assumes.
	(cp_parser_omp_construct): Handle PRAGMA_OMP_ASSUME.
	(cp_parser_pragma): Handle PRAGMA_OMP_ASSUME, PRAGMA_OMP_ASSUMES
	and PRAGMA_OMP_BEGIN.  Handle PRAGMA_OMP_END rather than
	PRAGMA_OMP_END_DECLARE_TARGET and call cp_parser_omp_end
	for it rather than cp_parser_omp_end_declare_target.
	* pt.cc (apply_late_template_attributes): Also temporarily clear
	omp_begin_assumes.
	* semantics.cc (finish_translation_unit): Also diagnose
	#pragma omp begin assumes without corresponding
	#pragma omp end assumes.
gcc/testsuite/
	* c-c++-common/gomp/assume-1.c: New test.
	* c-c++-common/gomp/assume-2.c: New test.
	* c-c++-common/gomp/assume-3.c: New test.
	* c-c++-common/gomp/assumes-1.c: New test.
	* c-c++-common/gomp/assumes-2.c: New test.
	* c-c++-common/gomp/assumes-3.c: New test.
	* c-c++-common/gomp/assumes-4.c: New test.
	* c-c++-common/gomp/begin-assumes-1.c: New test.
	* c-c++-common/gomp/begin-assumes-2.c: New test.
	* c-c++-common/gomp/begin-assumes-3.c: New test.
	* c-c++-common/gomp/begin-assumes-4.c: New test.
	* c-c++-common/gomp/declare-target-6.c: New test.
	* g++.dg/gomp/attrs-1.C (bar): Add n1 and n2 arguments, add
	tests for assume directive.
	* g++.dg/gomp/attrs-2.C (bar): Likewise.
	* g++.dg/gomp/attrs-9.C: Add n1 and n2 variables, add tests for
	begin assumes directive.
	* g++.dg/gomp/attrs-15.C: New test.
	* g++.dg/gomp/attrs-16.C: New test.
	* g++.dg/gomp/attrs-17.C: New test.
2022-09-27 08:23:08 +02:00
Jakub Jelinek
5b86d5dbe4 c++: Improve diagnostics about conflicting specifiers
On Sat, Sep 17, 2022 at 01:23:59AM +0200, Jason Merrill wrote:
> I wonder why we don't give an error when setting the
> conflicting_specifiers_p flag in cp_parser_set_storage_class?  We should be
> able to give a better diagnostic at that point.

I didn't have time to update the whole patch last night, but this part
seems to be independent and I've managed to test it.

The diagnostics then looks like:
a.C:1:9: error: ‘static’ specifier conflicts with ‘typedef’
    1 | typedef static int a;
      | ~~~~~~~ ^~~~~~
a.C:2:8: error: ‘typedef’ specifier conflicts with ‘static’
    2 | static typedef int b;
      | ~~~~~~ ^~~~~~~
a.C:3:8: error: duplicate ‘static’ specifier
    3 | static static int c;
      | ~~~~~~ ^~~~~~
a.C:4:8: error: ‘extern’ specifier conflicts with ‘static’
    4 | static extern int d;
      | ~~~~~~ ^~~~~~

2022-09-27  Jakub Jelinek  <jakub@redhat.com>

gcc/cp/
	* parser.cc (cp_parser_lambda_declarator_opt): Don't diagnose
	conflicting specifiers here.
	(cp_storage_class_name): New variable.
	(cp_parser_decl_specifier_seq): When setting conflicting_specifiers_p
	for the first time, diagnose which exact specifiers conflict.
	(cp_parser_set_storage_class): Likewise.  Move storage_class
	computation earlier.
	* decl.cc (grokdeclarator): Don't diagnose conflicting specifiers
	here, just return error_mark_node.
gcc/testsuite/
	* g++.dg/diagnostic/conflicting-specifiers-1.C: Adjust expected
	diagnostics.
	* g++.dg/parse/typedef8.C: Likewise.
	* g++.dg/parse/crash39.C: Likewise.
	* g++.dg/other/mult-stor1.C: Likewise.
	* g++.dg/cpp2a/constinit3.C: Likewise.
2022-09-27 08:21:41 +02:00
Jeff Law
5da546d7e0 Fix ICEs due to recent jump-to-return optimization
gcc/
	* cfgrtl.cc (fixup_reorder_chain): Verify that simple_return
	and return are available before trying to use them.
2022-09-27 02:19:57 -04:00
Jakub Jelinek
b04208895f c++: Implement P1467R9 - Extended floating-point types and standard names compiler part except for bfloat16 [PR106652]
The following patch implements the compiler part of C++23
P1467R9 - Extended floating-point types and standard names compiler part
by introducing _Float{16,32,64,128} as keywords and builtin types
like they are implemented for C already since GCC 7, with DF{16,32,64,128}_
mangling.
It also introduces _Float{32,64,128}x for C++ with the
https://github.com/itanium-cxx-abi/cxx-abi/pull/147
proposed mangling of DF{32,64,128}x.
The patch doesn't add anything for bfloat16_t support, as right now
__bf16 type refuses all conversions and arithmetic operations.
The patch wants to keep backwards compatibility with how __float128 has
been handled in C++ before, both for mangling and behavior in binary
operations, overload resolution etc.  So, there are some backend changes
where for C __float128 and _Float128 are the same type (float128_type_node
and float128t_type_node are the same pointer), but for C++ they are distinct
types which mangle differently and _Float128 is treated as extended
floating-point type while __float128 is treated as non-standard floating
point type.  The various C++23 changes about how floating-point types
are changed are actually implemented as written in the spec only if at least
one of the types involved is _Float{16,32,64,128,32x,64x,128x} (_FloatNx are
also treated as extended floating-point types) and kept previous behavior
otherwise.  For float/double/long double the rules are actually written that
they behave the same as before.
There is some backwards incompatibility at least on x86 regarding _Float16,
because that type was already used by that name and with the DF16_ mangling
(but only since GCC 12 and I think it isn't that widely used in the wild
yet).  E.g. config/i386/avx512fp16intrin.h shows the issues, where
in C or in GCC 12 in C++ one could pass 0.0f to a builtin taking _Float16
argument, but with the changes that is not possible anymore, one needs
to either use 0.0f16 or (_Float16) 0.0f.
We have also a problem with glibc headers, where since glibc 2.27
math.h and complex.h aren't compilable with these changes.  One gets
errors like:
In file included from /usr/include/math.h:43,
                 from abc.c:1:
/usr/include/bits/floatn.h:86:9: error: multiple types in one declaration
   86 | typedef __float128 _Float128;
      |         ^~~~~~~~~~
/usr/include/bits/floatn.h:86:20: error: declaration does not declare anything [-fpermissive]
   86 | typedef __float128 _Float128;
      |                    ^~~~~~~~~
In file included from /usr/include/bits/floatn.h:119:
/usr/include/bits/floatn-common.h:214:9: error: multiple types in one declaration
  214 | typedef float _Float32;
      |         ^~~~~
/usr/include/bits/floatn-common.h:214:15: error: declaration does not declare anything [-fpermissive]
  214 | typedef float _Float32;
      |               ^~~~~~~~
/usr/include/bits/floatn-common.h:251:9: error: multiple types in one declaration
  251 | typedef double _Float64;
      |         ^~~~~~
/usr/include/bits/floatn-common.h:251:16: error: declaration does not declare anything [-fpermissive]
  251 | typedef double _Float64;
      |                ^~~~~~~~
This is from snippets like:
 /* The remaining of this file provides support for older compilers.  */
 # if __HAVE_FLOAT128

 /* The type _Float128 exists only since GCC 7.0.  */
 #  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
 typedef __float128 _Float128;
 #  endif
where it hardcodes that C++ doesn't have _Float{16,32,64,128,32x,64x,128x} support nor
{f,F}{16,32,64,128}{,x} literal suffixes nor _Complex _Float{16,32,64,128,32x,64x,128x}.
The patch fixincludes this for now and hopefully if this is committed, then
glibc can change those.  The patch changes those
 #  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
conditions to
 #  if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13, 0))
Another thing is mangling, as said above, Itanium C++ ABI specifies
DF <number> _ as _Float{16,32,64,128} mangling, but GCC was implementing
a mangling incompatible with that starting with DF for fixed point types.
Fixed point was never supported in C++ though, I believe the reason why
the mangling has been added was that due to a bug it would leak into the
C++ FE through decltype (0.0r) etc.  But that has been shortly after the
mangling was added fixed (I think in the same GCC release cycle), so we
now reject 0.0r etc. in C++.  If we ever need the fixed point mangling,
I think it can be readded but better with a different prefix so that it
doesn't conflict with the published standard manglings.  So, this patch
also kills the fixed point mangling and implements the DF <number> _
demangling.
The patch predefines __STDCPP_FLOAT{16,32,64,128}_T__ macros when
those types are available, but only for C++23, while the underlying types
are available in C++98 and later including the {f,F}{16,32,64,128} literal
suffixes (but those with a pedwarn for C++20 and earlier).  My understanding
is that it needs to be predefined by the compiler, on the other side
predefining even for older modes when <stdfloat> is a new C++23 header
would be weird.  One can find out if _Float{16,32,64,128,32x,64x,128x} is
supported in C++ by
__GNUC__ >= 13 && defined(__FLT{16,32,64,128,32X,64X,128X}_MANT_DIG__)
(but that doesn't work well with older G++ 13 snapshots).

As for std::bfloat16_t, three targets (aarch64, arm and x86) apparently
"support" __bf16 type which has the bfloat16 format, but isn't really
usable, e.g. {aarch64,arm,ix86}_invalid_conversion disallow any conversions
from or to type with BFmode, {aarch64,arm,ix86}_invalid_unary_op disallows
any unary operations on those except for ADDR_EXPR and
{aarch64,arm,ix86}_invalid_binary_op disallows any binary operation on
those.  So, I think we satisfy:
"If the implementation supports an extended floating-point type with the
properties, as specified by ISO/IEC/IEEE 60559, of radix (b) of 2, storage
width in bits (k) of 16, precision in bits (p) of 8, maximum exponent (emax)
of 127, and exponent field width in bits (w) of 8, then the typedef-name
std::bfloat16_t is defined in the header <stdfloat> and names such a type,
the macro __STDCPP_BFLOAT16_T__ is defined, and the floating-point literal
suffixes bf16 and BF16 are supported."
because we don't really support those right now.

2022-09-27  Jakub Jelinek  <jakub@redhat.com>

	PR c++/106652
	PR c++/85518
gcc/
	* tree-core.h (enum tree_index): Add TI_FLOAT128T_TYPE
	enumerator.
	* tree.h (float128t_type_node): Define.
	* tree.cc (build_common_tree_nodes): Initialize float128t_type_node.
	* builtins.def (DEF_FLOATN_BUILTIN): Adjust comment now that
	_Float<N> is supported in C++ too.
	* config/i386/i386.cc (ix86_mangle_type): Only mangle as "g"
	float128t_type_node.
	* config/i386/i386-builtins.cc (ix86_init_builtin_types): Use
	float128t_type_node for __float128 instead of float128_type_node
	and create it if NULL.
	* config/i386/avx512fp16intrin.h (_mm_setzero_ph, _mm256_setzero_ph,
	_mm512_setzero_ph, _mm_set_sh, _mm_load_sh): Use 0.0f16 instead of
	0.0f.
	* config/ia64/ia64.cc (ia64_init_builtins): Use
	float128t_type_node for __float128 instead of float128_type_node
	and create it if NULL.
	* config/rs6000/rs6000-c.cc (is_float128_p): Also return true
	for float128t_type_node if non-NULL.
	* config/rs6000/rs6000.cc (rs6000_mangle_type): Don't mangle
	float128_type_node as "u9__ieee128".
	* config/rs6000/rs6000-builtin.cc (rs6000_init_builtins): Use
	float128t_type_node for __float128 instead of float128_type_node
	and create it if NULL.
gcc/c-family/
	* c-common.cc (c_common_reswords): Change _Float{16,32,64,128} and
	_Float{32,64,128}x flags from D_CONLY to 0.
	(shorten_binary_op): Punt if common_type returns error_mark_node.
	(shorten_compare): Likewise.
	(c_common_nodes_and_builtins): For C++ record _Float{16,32,64,128}
	and _Float{32,64,128}x builtin types if available.  For C++
	clear float128t_type_node.
	* c-cppbuiltin.cc (c_cpp_builtins): Predefine
	__STDCPP_FLOAT{16,32,64,128}_T__ for C++23 if supported.
	* c-lex.cc (interpret_float): For q/Q suffixes prefer
	float128t_type_node over float128_type_node.  Allow
	{f,F}{16,32,64,128} suffixes for C++ if supported with pedwarn
	for C++20 and older.  Allow {f,F}{32,64,128}x suffixes for C++
	with pedwarn.  Don't call excess_precision_type for C++.
gcc/cp/
	* cp-tree.h (cp_compare_floating_point_conversion_ranks): Implement
	P1467R9 - Extended floating-point types and standard names except
	for std::bfloat16_t for now.  Declare.
	(extended_float_type_p): New inline function.
	* mangle.cc (write_builtin_type): Mangle float{16,32,64,128}_type_node
	as DF{16,32,64,128}_.  Mangle float{32,64,128}x_type_node as
	DF{32,64,128}x.  Remove FIXED_POINT_TYPE mangling that conflicts
	with that.
	* typeck2.cc (check_narrowing): If one of ftype or type is extended
	floating-point type, compare floating-point conversion ranks.
	* parser.cc (cp_keyword_starts_decl_specifier_p): Handle
	CASE_RID_FLOATN_NX.
	(cp_parser_simple_type_specifier): Likewise and diagnose missing
	_Float<N> or _Float<N>x support if not supported by target.
	* typeck.cc (cp_compare_floating_point_conversion_ranks): New function.
	(cp_common_type): If both types are REAL_TYPE and one or both are
	extended floating-point types, select common type based on comparison
	of floating-point conversion ranks and subranks.
	(cp_build_binary_op): Diagnose operation with floating point arguments
	with unordered conversion ranks.
	* call.cc (standard_conversion): For floating-point conversion, if
	either from or to are extended floating-point types, set conv->bad_p
	for implicit conversion from larger to smaller conversion rank or
	with unordered conversion ranks.
	(convert_like_internal): Emit a pedwarn on such conversions.
	(build_conditional_expr): Diagnose operation with floating point
	arguments with unordered conversion ranks.
	(convert_arg_to_ellipsis): Don't promote extended floating-point types
	narrower than double to double.
	(compare_ics): Implement P1467R9 [over.ics.rank]/4 changes.
gcc/testsuite/
	* g++.dg/cpp23/ext-floating1.C: New test.
	* g++.dg/cpp23/ext-floating2.C: New test.
	* g++.dg/cpp23/ext-floating3.C: New test.
	* g++.dg/cpp23/ext-floating4.C: New test.
	* g++.dg/cpp23/ext-floating5.C: New test.
	* g++.dg/cpp23/ext-floating6.C: New test.
	* g++.dg/cpp23/ext-floating7.C: New test.
	* g++.dg/cpp23/ext-floating8.C: New test.
	* g++.dg/cpp23/ext-floating9.C: New test.
	* g++.dg/cpp23/ext-floating10.C: New test.
	* g++.dg/cpp23/ext-floating.h: New file.
	* g++.target/i386/float16-1.C: Adjust expected diagnostics.
libcpp/
	* expr.cc (interpret_float_suffix): Allow {f,F}{16,32,64,128} and
	{f,F}{32,64,128}x suffixes for C++.
include/
	* demangle.h (enum demangle_component_type): Add
	DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE.
	(struct demangle_component): Add u.s_extended_builtin member.
libiberty/
	* cp-demangle.c (d_dump): Handle
	DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE.  Don't handle
	DEMANGLE_COMPONENT_FIXED_TYPE.
	(d_make_extended_builtin_type): New function.
	(cplus_demangle_builtin_types): Add _Float entry.
	(cplus_demangle_type): For DF demangle it as _Float<N> or
	_Float<N>x rather than fixed point which conflicts with it.
	(d_count_templates_scopes): Handle
	DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE.  Just break; for
	DEMANGLE_COMPONENT_FIXED_TYPE.
	(d_find_pack): Handle DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE.
	Don't handle DEMANGLE_COMPONENT_FIXED_TYPE.
	(d_print_comp_inner): Likewise.
	* cp-demangle.h (D_BUILTIN_TYPE_COUNT): Bump.
	* testsuite/demangle-expected: Replace _Z3xxxDFyuVb test
	with _Z3xxxDF16_DF32_DF64_DF128_CDF16_Vb.  Add
	_Z3xxxDF32xDF64xDF128xCDF32xVb test.
fixincludes/
	* inclhack.def (glibc_cxx_floatn_1, glibc_cxx_floatn_2,
	glibc_cxx_floatn_3): New fixes.
	* tests/base/bits/floatn.h: New file.
	* fixincl.x: Regenerated.
2022-09-27 08:18:00 +02:00
Meghan Denny
8be65640e1 Updated constants from <https://dwarfstd.org/Languages.php>
include
	* dwarf2.h: Update with additional languages from dwarf
	standard.
2022-09-26 23:51:52 -04:00
GCC Administrator
220c4d8e44 Daily bump. 2022-09-27 00:17:52 +00:00