aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-06-16uiltins: Add support for clang compatible __builtin_{add,sub}c{,l,ll} [PR79173]Jakub Jelinek6-0/+250
While the design of these builtins in clang is questionable, rather than being say unsigned __builtin_addc (unsigned, unsigned, bool, bool *) so that it is clear they add two [0, 0xffffffff] range numbers plus one [0, 1] range carry in and give [0, 0xffffffff] range return plus [0, 1] range carry out, they actually instead add 3 [0, 0xffffffff] values together but the carry out isn't then the expected [0, 2] value because 0xffffffffULL + 0xffffffff + 0xffffffff is 0x2fffffffd, but just [0, 1] whether there was any overflow at all. It is something used in the wild and shorter to write than the corresponding #define __builtin_addc(a,b,carry_in,carry_out) \ ({ unsigned _s; \ unsigned _c1 = __builtin_uadd_overflow (a, b, &_s); \ unsigned _c2 = __builtin_uadd_overflow (_s, carry_in, &_s); \ *(carry_out) = (_c1 | _c2); \ _s; }) and so a canned builtin for something people could often use. It isn't that hard to maintain on the GCC side, as we just lower it to two .ADD_OVERFLOW calls early, and the already committed pottern recognization code can then make .UADDC/.USUBC calls out of that if the carry in is in [0, 1] range and the corresponding optab is supported by the target. 2023-06-16 Jakub Jelinek <jakub@redhat.com> PR middle-end/79173 * builtin-types.def (BT_FN_UINT_UINT_UINT_UINT_UINTPTR, BT_FN_ULONG_ULONG_ULONG_ULONG_ULONGPTR, BT_FN_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONG_ULONGLONGPTR): New types. * builtins.def (BUILT_IN_ADDC, BUILT_IN_ADDCL, BUILT_IN_ADDCLL, BUILT_IN_SUBC, BUILT_IN_SUBCL, BUILT_IN_SUBCLL): New builtins. * builtins.cc (fold_builtin_addc_subc): New function. (fold_builtin_varargs): Handle BUILT_IN_{ADD,SUB}C{,L,LL}. * doc/extend.texi (__builtin_addc, __builtin_subc): Document. * gcc.target/i386/pr79173-11.c: New test. * gcc.dg/builtin-addc-1.c: New test.
2023-06-16tree-ssa-math-opts: Fix up uaddc/usubc pattern matching [PR110271]Jakub Jelinek2-3/+30
The following testcase ICEs, because I misremembered what the return value from match_arith_overflow is. It isn't true if __builtin_*_overflow was matched, but it is true only in the BIT_NOT_EXPR case if stmt was removed. So, if match_arith_overflow matches something, gsi_stmt (gsi) will not be stmt and match_uaddc_usubc will be confused and can ICE. The following patch fixes it by checking if gsi_stmt (gsi) == stmt, in that case we know it is still a PLUS_EXPR/MINUS_EXPR and we can try to pattern match it further as UADDC/USUBC. 2023-06-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/110271 * tree-ssa-math-opts.cc (math_opts_dom_walker::after_dom_children) <case PLUS_EXPR>: Ignore return value from match_arith_overflow, instead call match_uaddc_usubc only if gsi_stmt (gsi) is still stmt. * gcc.c-torture/compile/pr110271.c: New test.
2023-06-16Regenerate some autotools generated filesMartin Jambor3-4/+6
As discussed in https://gcc.gnu.org/pipermail/gcc-patches/2023-June/621976.html this should put the autotools generated files in sync to what they were generated from (and make an automated checker happy). Tested by bootstrapping on top of only a few revisions ago. zlib/ChangeLog: 2023-06-16 Martin Jambor <mjambor@suse.cz> * Makefile.in: Regenerate. * configure: Likewise. gcc/ChangeLog: 2023-06-16 Martin Jambor <mjambor@suse.cz> * configure: Regenerate.
2023-06-16libgomp: Fix OMP_TARGET_OFFLOAD=mandatoryTobias Burnus3-3/+50
It turned out that gomp_init_targets_once() was not run when directly calling 'omp target' or 'omp target (enter/exit) data' causing an abort with OMP_TARGET_OFFLOAD=mandatory wrongly claiming that no device is available. It was called a tiny bit later but few lines too late for updating the default-device-var. libgomp/ChangeLog: * target.c (resolve_device): Call gomp_get_num_devices early to ensure gomp_init_targets_once was called before using default-device-var. * testsuite/libgomp.c/target-55.c: New test. * testsuite/libgomp.c/target-55a.c: New test.
2023-06-16PR target/31985: Improve memory operand use with doubleword add.Roger Sayle2-0/+44
This patch addresses the last remaining issue with PR target/31985, that GCC could make better use of memory addressing modes when implementing double word addition. This is achieved by adding a define_insn_and_split that combines an *add<dwi>3_doubleword with a *concat<mode><dwi>3, so that the components of the concat can be used directly, without first being loaded into a double word register. For test_c in the bugzilla PR: Before: pushl %ebx subl $16, %esp movl 28(%esp), %eax movl 36(%esp), %ecx movl 32(%esp), %ebx movl 24(%esp), %edx addl %ecx, %eax adcl %ebx, %edx movl %eax, 8(%esp) movl %edx, 12(%esp) addl $16, %esp popl %ebx ret After: test_c: subl $20, %esp movl 36(%esp), %eax movl 32(%esp), %edx addl 28(%esp), %eax adcl 24(%esp), %edx movl %eax, 8(%esp) movl %edx, 12(%esp) addl $20, %esp ret 2023-06-16 Roger Sayle <roger@nextmovesoftware.com> Uros Bizjak <ubizjak@gmail.com> gcc/ChangeLog PR target/31985 * config/i386/i386.md (*add<dwi>3_doubleword_concat): New define_insn_and_split combine *add<dwi>3_doubleword with a *concat<mode><dwi>3 for more efficient lowering after reload. gcc/testsuite/ChangeLog PR target/31985 * gcc.target/i386/pr31985.c: New test case.
2023-06-16RA: Ignore conflicts for some pseudos from insns throwing a final exceptionVladimir N. Makarov1-6/+17
IRA adds conflicts to the pseudos from insns can throw exceptions internally even if the exception code is final for the function and the pseudo value is not used in the exception code. This results in spilling a pseudo in a loop (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110215). The following patch fixes the problem. PR rtl-optimization/110215 gcc/ChangeLog: * ira-lives.cc: Include except.h. (process_bb_node_lives): Ignore conflicts from cleanup exceptions when the pseudo does not live at the exception landing pad.
2023-06-16c++: Accept elaborated-enum-base with pedwarnAlex Coplan6-10/+39
macOS SDK headers using the CF_ENUM macro can expand to invalid C++ code of the form: typedef enum T : BaseType T; i.e. an elaborated-type-specifier with an additional enum-base. Upstream LLVM can be made to accept the above construct with -Wno-error=elaborated-enum-base. This patch adds the -Welaborated-enum-base warning to GCC and adjusts the C++ parser to emit this warning instead of rejecting this code outright. The macro expansion in the macOS headers occurs in the case that the compiler declares support for enums with underlying type using __has_feature, see https://gcc.gnu.org/pipermail/gcc-patches/2023-May/618450.html GCC rejecting this construct outright means that GCC fails to bootstrap on Darwin in the case that it (correctly) implements __has_feature and declares support for C++ enums with underlying type. With this patch, GCC can bootstrap on Darwin in combination with the (WIP) __has_feature patch posted at: https://gcc.gnu.org/pipermail/gcc-patches/2023-May/617878.html gcc/c-family/ChangeLog: * c.opt (Welaborated-enum-base): New. gcc/ChangeLog: * doc/invoke.texi: Document -Welaborated-enum-base. gcc/cp/ChangeLog: * parser.cc (cp_parser_enum_specifier): Don't reject elaborated-type-specifier with enum-base, instead emit new Welaborated-enum-base warning. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/enum40.C: Adjust expected diagnostics. * g++.dg/cpp0x/forw_enum6.C: Likewise. * g++.dg/cpp0x/elab-enum-base.C: New test.
2023-06-16aarch64: Handle ASHIFTRT in patterns for shrn2Kyrylo Tkachov3-29/+31
Similar to the low-half patterns, we want to match both ashiftrt and lshiftrt with the truncate for SHRN2. We reuse the SHIFTRT iterator and the AARCH64_VALID_SHRN_OP check to help, but because we expand the high-half patterns by their gen_* names we need to disambiguate all the different trunc+shift combinations in the pattern name, which leads to a slight renaming of the builtins. The AARCH64_VALID_SHRN_OP check on the expander and the define_insns ensures that no invalid combination ends up getting matched. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. gcc/ChangeLog: * config/aarch64/aarch64-simd-builtins.def (shrn2_n): Rename builtins to... (ushrn2_n): ... This. (sqshrn2_n): Rename builtins to... (ssqshrn2_n): ... This. (uqshrn2_n): Rename builtins to... (uqushrn2_n): ... This. * config/aarch64/arm_neon.h (vqshrn_high_n_s16): Adjust for the above. (vqshrn_high_n_s32): Likewise. (vqshrn_high_n_s64): Likewise. (vqshrn_high_n_u16): Likewise. (vqshrn_high_n_u32): Likewise. (vqshrn_high_n_u64): Likewise. (vshrn_high_n_s16): Likewise. (vshrn_high_n_s32): Likewise. (vshrn_high_n_s64): Likewise. (vshrn_high_n_u16): Likewise. (vshrn_high_n_u32): Likewise. (vshrn_high_n_u64): Likewise. * config/aarch64/aarch64-simd.md (aarch64_<shrn_op>shrn2_n<mode>_insn_le): Rename to... (aarch64_<shrn_op><sra_op>shrn2_n<mode>_insn_le): ... This. Use SHIFTRT iterator and AARCH64_VALID_SHRN_OP check. (aarch64_<shrn_op>shrn2_n<mode>_insn_be): Rename to... (aarch64_<shrn_op><sra_op>shrn2_n<mode>_insn_be): ... This. Use SHIFTRT iterator and AARCH64_VALID_SHRN_OP check. (aarch64_<shrn_op>shrn2_n<mode>): Rename to... (aarch64_<shrn_op><sra_op>shrn2_n<mode>): ... This. Update expander for the above.
2023-06-16aarch64: [US]Q(R)SHR(U)N2 refactoringKyrylo Tkachov4-198/+237
This patch is large in lines of code, but it is a fairly regular extension of the first patch as it converts the high-half patterns to standard RTL codes in the same fashion as the first patch did for the low-half ones. This now allows us to remove the unspec codes for these instructions as there are no more uses of them left. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. gcc/ChangeLog: * config/aarch64/aarch64-simd-builtins.def (shrn2): Rename builtins to... (shrn2_n): ... This. (rshrn2): Rename builtins to... (rshrn2_n): ... This. * config/aarch64/arm_neon.h (vrshrn_high_n_s16): Adjust for the above. (vrshrn_high_n_s32): Likewise. (vrshrn_high_n_s64): Likewise. (vrshrn_high_n_u16): Likewise. (vrshrn_high_n_u32): Likewise. (vrshrn_high_n_u64): Likewise. (vshrn_high_n_s16): Likewise. (vshrn_high_n_s32): Likewise. (vshrn_high_n_s64): Likewise. (vshrn_high_n_u16): Likewise. (vshrn_high_n_u32): Likewise. (vshrn_high_n_u64): Likewise. * config/aarch64/aarch64-simd.md (*aarch64_<srn_op>shrn<mode>2_vect_le): Delete. (*aarch64_<srn_op>shrn<mode>2_vect_be): Likewise. (aarch64_shrn2<mode>_insn_le): Likewise. (aarch64_shrn2<mode>_insn_be): Likewise. (aarch64_shrn2<mode>): Likewise. (aarch64_rshrn2<mode>_insn_le): Likewise. (aarch64_rshrn2<mode>_insn_be): Likewise. (aarch64_rshrn2<mode>): Likewise. (aarch64_<sur>q<r>shr<u>n2_n<mode>_insn_le): Likewise. (aarch64_<shrn_op>shrn2_n<mode>_insn_le): New define_insn. (aarch64_<sur>q<r>shr<u>n2_n<mode>_insn_be): Delete. (aarch64_<shrn_op>shrn2_n<mode>_insn_be): New define_insn. (aarch64_<sur>q<r>shr<u>n2_n<mode>): Delete. (aarch64_<shrn_op>shrn2_n<mode>): New define_expand. (aarch64_<shrn_op>rshrn2_n<mode>_insn_le): New define_insn. (aarch64_<shrn_op>rshrn2_n<mode>_insn_be): New define_insn. (aarch64_<shrn_op>rshrn2_n<mode>): New define_expand. (aarch64_sqshrun2_n<mode>_insn_le): New define_insn. (aarch64_sqshrun2_n<mode>_insn_be): New define_insn. (aarch64_sqshrun2_n<mode>): New define_expand. (aarch64_sqrshrun2_n<mode>_insn_le): New define_insn. (aarch64_sqrshrun2_n<mode>_insn_be): New define_insn. (aarch64_sqrshrun2_n<mode>): New define_expand. * config/aarch64/iterators.md (UNSPEC_SQSHRUN, UNSPEC_SQRSHRUN, UNSPEC_SQSHRN, UNSPEC_UQSHRN, UNSPEC_SQRSHRN, UNSPEC_UQRSHRN): Delete unspec values. (VQSHRN_N): Delete int iterator.
2023-06-16aarch64: Add ASHIFTRT handling for shrn patternKyrylo Tkachov3-3/+10
The first patch in the series has some fallout in the testsuite, particularly gcc.target/aarch64/shrn-combine-2.c. Our previous patterns for SHRN matched both (truncate (ashiftrt (x) (N))) and (truncate (lshiftrt (x) (N)) as these are equivalent for the shift amounts involved. In our refactoring, however, we mapped shrn to truncate+lshiftrt. The fix here is to iterate over ashiftrt,lshiftrt in the pattern for it. However, we don't want to allow ashiftrt for us_truncate or lshiftrt for ss_truncate from the ALL_TRUNC iterator. This patch addds a AARCH64_VALID_SHRN_OP helper to gate the valid combinations of truncations and shifts. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. gcc/ChangeLog: * config/aarch64/aarch64.h (AARCH64_VALID_SHRN_OP): Define. * config/aarch64/aarch64-simd.md (*aarch64_<shrn_op>shrn_n<mode>_insn<vczle><vczbe>): Rename to... (*aarch64_<shrn_op><shrn_s>shrn_n<mode>_insn<vczle><vczbe>): ... This. Use SHIFTRT iterator and add AARCH64_VALID_SHRN_OP to condition. * config/aarch64/iterators.md (shrn_s): New code attribute.
2023-06-16aarch64: [US]Q(R)SHR(U)N scalar forms refactoringKyrylo Tkachov2-8/+106
Some instructions from the previous patch have scalar forms: SQSHRN,SQRSHRN,UQSHRN,UQRSHRN,SQSHRUN,SQRSHRUN. This patch converts the patterns for these to use standard RTL codes. Their MD patterns deviate slightly from the vector forms mostly due to things like operands being scalar rather than vectors. One nuance is in the SQSHRUN,SQRSHRUN patterns. These end in a truncate to the scalar narrow mode e.g. SI -> QI. This gets simplified by the RTL passes to a subreg rather than keeping it as a truncate. So we end up representing these without the truncate and in the expander read the narrow subreg in order to comply with the expected width of the intrinsic. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. gcc/ChangeLog: * config/aarch64/aarch64-simd.md (aarch64_<sur>q<r>shr<u>n_n<mode>): Rename to... (aarch64_<shrn_op>shrn_n<mode>): ... This. Reimplement with RTL codes. (*aarch64_<shrn_op>rshrn_n<mode>_insn): New define_insn. (aarch64_sqrshrun_n<mode>_insn): Likewise. (aarch64_sqshrun_n<mode>_insn): Likewise. (aarch64_<shrn_op>rshrn_n<mode>): New define_expand. (aarch64_sqshrun_n<mode>): Likewise. (aarch64_sqrshrun_n<mode>): Likewise. * config/aarch64/iterators.md (V2XWIDE): Add HI and SI modes.
2023-06-16aarch64: Reimplement [US]Q(R)SHR(U)N patterns with RTL codesKyrylo Tkachov5-98/+174
This patch reimplements the MD patterns for the instructions that perform narrowing right shifts with optional rounding and saturation using standard RTL codes rather than unspecs. There are four groups of patterns involved: * Simple narrowing shifts with optional signed or unsigned truncation: SHRN, SQSHRN, UQSHRN. These are expressed as a truncation operation of a right shift. The matrix of valid combinations looks like this: | ashiftrt | lshiftrt | ------------------------------------------ ss_truncate | SQSHRN | X | us_truncate | X | UQSHRN | truncate | X | SHRN | ------------------------------------------ * Narrowing shifts with rounding with optional signed or unsigned truncation: RSHRN, SQRSHRN, UQRSHRN. These follow the same combinations of truncation and shift codes as above, but also perform intermediate widening of the results in order to represent the addition of the rounding constant. This group also corrects an existing inaccuracy for RSHRN where we don't currently model the intermediate widening for rounding. * The somewhat special "Signed saturating Shift Right Unsigned Narrow": SQSHRUN. Similar to the SQXTUN instructions, these perform a saturating truncation that isn't represented by US_TRUNCATE or SS_TRUNCATE but needs to use a clamping operation followed by a TRUNCATE. * The rounding version of the above: SQRSHRUN. It needs the special clamping truncate representation but with an intermediate widening and rounding addition. Besides using standard RTL codes for all of the above instructions, this patch allows us to get rid of the explicit define_insns and define_expands for SHRN and RSHRN. Bootstrapped and tested on aarch64-none-linux-gnu and aarch64_be-none-elf. We've got pretty thorough execute tests in advsimd-intrinsics.exp that exercise these and many instances of these instructions get constant-folded away during optimisation and the validation still passes (during development where I was figuring out the details of the semantics they were discovering failures), so I'm fairly confident in the representation. gcc/ChangeLog: * config/aarch64/aarch64-simd-builtins.def (shrn): Rename builtins to... (shrn_n): ... This. (rshrn): Rename builtins to... (rshrn_n): ... This. * config/aarch64/arm_neon.h (vshrn_n_s16): Adjust for the above. (vshrn_n_s32): Likewise. (vshrn_n_s64): Likewise. (vshrn_n_u16): Likewise. (vshrn_n_u32): Likewise. (vshrn_n_u64): Likewise. (vrshrn_n_s16): Likewise. (vrshrn_n_s32): Likewise. (vrshrn_n_s64): Likewise. (vrshrn_n_u16): Likewise. (vrshrn_n_u32): Likewise. (vrshrn_n_u64): Likewise. * config/aarch64/aarch64-simd.md (*aarch64_<srn_op>shrn<mode><vczle><vczbe>): Delete. (aarch64_shrn<mode>): Likewise. (aarch64_rshrn<mode><vczle><vczbe>_insn): Likewise. (aarch64_rshrn<mode>): Likewise. (aarch64_<sur>q<r>shr<u>n_n<mode>_insn<vczle><vczbe>): Likewise. (aarch64_<sur>q<r>shr<u>n_n<mode>): Likewise. (*aarch64_<shrn_op>shrn_n<mode>_insn<vczle><vczbe>): New define_insn. (*aarch64_<shrn_op>rshrn_n<mode>_insn<vczle><vczbe>): Likewise. (*aarch64_sqshrun_n<mode>_insn<vczle><vczbe>): Likewise. (*aarch64_sqrshrun_n<mode>_insn<vczle><vczbe>): Likewise. (aarch64_<shrn_op>shrn_n<mode>): New define_expand. (aarch64_<shrn_op>rshrn_n<mode>): Likewise. (aarch64_sqshrun_n<mode>): Likewise. (aarch64_sqrshrun_n<mode>): Likewise. * config/aarch64/iterators.md (ALL_TRUNC): New code iterator. (TRUNCEXTEND): New code attribute. (TRUNC_SHIFT): Likewise. (shrn_op): Likewise. * config/aarch64/predicates.md (aarch64_simd_umax_quarter_mode): New predicate.
2023-06-16RISC-V: Fix one warning of maybe-uninitialized in riscv-vsetvl.ccPan Li1-1/+1
This patch would like to fix one maybe-uninitialized warning. Aka: riscv-vsetvl.cc:4354:3: error: 'vsetvl_rinsn' may be used uninitialized [-Werror=maybe-uninitialized] Signed-off-by: Pan Li <pan2.li@intel.com> gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (pass_vsetvl::global_eliminate_vsetvl_insn): Initialize var by NULL.
2023-06-16tree-optimization/110278 - uns < (typeof uns)(uns != 0) is always falseRichard Biener1-0/+11
The following adds two patterns simplifying comparisons, uns < (typeof uns)(uns != 0) is always false and x != (typeof x)(x == 0) is always true. PR tree-optimization/110278 * match.pd (uns < (typeof uns)(uns != 0) -> false): New. (x != (typeof x)(x == 0) -> true): Likewise.
2023-06-16Add MinGW option -mcrtdll= for choosing C RunTime DLL libraryPali Rohár4-6/+72
It adjust preprocess, compile and link flags, which allows to change default -lmsvcrt library by another provided by MinGW runtime. gcc/ChangeLog: * config/i386/mingw-w64.h (CPP_SPEC): Adjust for -mcrtdll=. (REAL_LIBGCC_SPEC): New define. * config/i386/mingw.opt: Add mcrtdll= * config/i386/mingw32.h (CPP_SPEC): Adjust for -mcrtdll=. (REAL_LIBGCC_SPEC): Adjust for -mcrtdll=. (STARTFILE_SPEC): Adjust for -mcrtdll=. * doc/invoke.texi: Add mcrtdll= documentation. Signed-off-by: Jonathan Yong <10walls@gmail.com>
2023-06-16MIPS16: Implement `code_readable` function attribute.Simon Dardis7-1/+319
Support for __attribute__ ((code_readable)). Takes up to one argument of "yes", "no", "pcrel". This will change the code readability setting for just that function. If no argument is supplied, then the setting is 'yes'. gcc/ChangeLog: * config/mips/mips.cc (enum mips_code_readable_setting):New enmu. (mips_handle_code_readable_attr):New static function. (mips_get_code_readable_attr):New static enum function. (mips_set_current_function):Set the code_readable mode. (mips_option_override):Same as above. * doc/extend.texi:Document code_readable. gcc/testsuite/ChangeLog: * gcc.target/mips/code-readable-attr-1.c: New test. * gcc.target/mips/code-readable-attr-2.c: New test. * gcc.target/mips/code-readable-attr-3.c: New test. * gcc.target/mips/code-readable-attr-4.c: New test. * gcc.target/mips/code-readable-attr-5.c: New test.
2023-06-16tree-optimization/110269 - restore missed condition foldingRichard Biener3-9/+36
The following makes sure we optimize x != 0 using range info via tree_expr_nonzero_p via match.pd. PR tree-optimization/110269 * fold-const.cc (fold_binary_loc): Merge x != 0 folding with tree_expr_nonzero_p ... * match.pd (cmp (convert? addr@0) integer_zerop): With this pattern. * gcc.dg/tree-ssa/pr110269.c: New testcase.
2023-06-16MAINTAINERS: move Matthew Fortune to Write After ApprovalYunQiang Su1-0/+1
In 4fe6e12204535545edf7f035d4dc79c1404058cf, I should have added Matthew Fortune to the Write After Approval section, while replacing the MIPS Maintainer position. ChangeLog: * MAINTAINERS (Write After Approval): move Matthew Fortune to Write After Approval.
2023-06-16[libstdc++] [testsuite] xfail dbl from_chars for aarch64 rtems ldblAlexandre Oliva1-1/+1
rtems, like vxworks, uses fast-float doubles for from_chars even for long double, so it loses precision, so expect the long double bits to fail on aarch64. for libstdc++-v3/ChangeLog * testsuite/20_util/from_chars/4.cc: Skip long double on aarch64-rtems.
2023-06-16libstdc++-v3: do not duplicate some math functions when using newlibJoel Brobecker2-0/+1188
When running the libstdc++ testsuite on AArch64 RTEMS, we noticed that about 25 tests are failing during the link, due to the "sqrtl" function being defined twice: - once inside RTEMS' libm; - once inside our libstdc++. One test that fails, for instance, would be 26_numerics/complex/13450.cc. In comparing libm and libstdc++, we found that libstc++ also duplicates "hypotf", and "hypotl". For "sqrtl" and "hypotl", the symbosl come a unit called from math_stubs_long_double.cc, while "hypotf" comes from the equivalent unit for the float version, called math_stubs_float.cc. Those units are always compiled in libstdc++ and provide our own version of various math routines when those are missing from the target system. The definition of those symbols is predicated on the existance of various macros provided by c++config.h, which themselves are predicated by the corresponding HAVE_xxx macros in config.h. One key element behind what's happening, here, is that the target uses newlib, and therefore GCC was configured --with-newlib. The section of libstdc++v3's configure script that handles which math functions are available has a newlib-specific section, and that section provides a hardcoded list of symbols. For "hypotf", this commit fixes the issue by doing the same as for the other routines already declared in that section. I verified by inspection in the newlib code that this function should always be present, so hardcoding it in our configure script should not be an issue. For the math routines handling doubles ("sqrtl" and "hypotl"), however, I do not believe we can assume that newlib's libm will always provide them. Therefore, this commit fixes that part of the issue by ading a compile-check for "sqrtl" and "hypotl". And while at it, we also include checks for all the other math functions that math_stubs_long_double.cc re-implements, allowing us to be resilient to future newlib enhancements adding support for more functions. libstdc++-v3/ChangeLog: * configure.ac ["x${with_newlib}" = "xyes"]: Define HAVE_HYPOTF. Add compile-checks for various long double math functions as well. * configure: Regenerate.
2023-06-15c: add name hints to c_parser_declspecs [PR107583]David Malcolm2-1/+23
PR c/107583 notes that we weren't issuing a hint for struct foo { time_t mytime; /* missing <time.h> include should trigger fixit */ }; in the C frontend. The root cause is that one of the "unknown type name" diagnostics was missing logic to emit hints, which this patch fixes. gcc/c/ChangeLog: PR c/107583 * c-parser.cc (c_parser_declspecs): Add hints to "unknown type name" error. gcc/testsuite/ChangeLog: PR c/107583 * c-c++-common/spellcheck-pr107583.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-06-16Daily bump.GCC Administrator16-1/+486
2023-06-15configure: Implement --enable-host-pieMarek Polacek30-112/+494
[ This is my third attempt to add this configure option. The first version was approved but it came too late in the development cycle. The second version was also approved, but I had to revert it: <https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607082.html>. I've fixed the problem (by moving $(PICFLAG) from INTERNAL_CFLAGS to ALL_COMPILERFLAGS). Another change is that since r13-4536 I no longer need to touch Makefile.def, so this patch is simplified. ] This patch implements the --enable-host-pie configure option which makes the compiler executables PIE. This can be used to enhance protection against ROP attacks, and can be viewed as part of a wider trend to harden binaries. It is similar to the option --enable-host-shared, except that --e-h-s won't add -shared to the linker flags whereas --e-h-p will add -pie. It is different from --enable-default-pie because that option just adds an implicit -fPIE/-pie when the compiler is invoked, but the compiler itself isn't PIE. Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH regressions. When building the compiler, the build process may use various in-tree libraries; these need to be built with -fPIE so that it's possible to use them when building a PIE. For instance, when --with-included-gettext is in effect, intl object files must be compiled with -fPIE. Similarly, when building in-tree gmp, isl, mpfr and mpc, they must be compiled with -fPIE. With this patch and --enable-host-pie used to configure gcc: $ file gcc/cc1{,plus,obj,gm2} gcc/f951 gcc/lto1 gcc/cpp gcc/go1 gcc/rust1 gcc/gnat1 gcc/cc1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=98e22cde129d304aa6f33e61b1c39e144aeb135e, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cc1plus: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=859d1ea37e43dfe50c18fd4e3dd9a34bb1db8f77, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cc1obj: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=1964f8ecee6163182bc26134e2ac1f324816e434, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cc1gm2: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a396672c7ff913d21855829202e7b02ecf42ff4c, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/f951: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=59c523db893186547ac75c7a71f48be0a461c06b, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/lto1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=084a7b77df7be2d63c2d4c655b5bbc3fcdb6038d, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/cpp: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=3503bf8390d219a10d6653b8560aa21158132168, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/go1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=988cc673af4fba5dcb482f4b34957b99050a68c5, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/rust1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=b6a5d3d514446c4dcdee0707f086ab9b274a8a3c, for GNU/Linux 3.2.0, with debug_info, not stripped gcc/gnat1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=bb11ccdc2c366fe3fe0980476bcd8ca19b67f9dc, for GNU/Linux 3.2.0, with debug_info, not stripped I plan to add an option to link with -Wl,-z,now. Bootstrapped on x86_64-pc-linux-gnu with --with-included-gettext --enable-host-pie as well as without --enable-host-pie. Also tested on a Debian system where the system gcc was configured with --enable-default-pie. Co-Authored by: Iain Sandoe <iain@sandoe.co.uk> ChangeLog: * configure.ac (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. c++tools/ChangeLog: * Makefile.in: Rename PIEFLAG to PICFLAG. Set LD_PICFLAG. Use it. Use pic/libiberty.a if PICFLAG is set. * configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG. (--enable-host-pie): New check. * configure: Regenerate. fixincludes/ChangeLog: * Makefile.in: Set and use PICFLAG and LD_PICFLAG. Use the "pic" build of libiberty if PICFLAG is set. * configure.ac: * configure: Regenerate. gcc/ChangeLog: * Makefile.in: Set LD_PICFLAG. Use it. Set enable_host_pie. Remove NO_PIE_CFLAGS and NO_PIE_FLAG. Pass LD_PICFLAG to ALL_LINKERFLAGS. Use the "pic" build of libiberty if --enable-host-pie. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this check. * configure: Regenerate. * doc/install.texi: Document --enable-host-pie. gcc/ada/ChangeLog: * gcc-interface/Make-lang.in (ALL_ADAFLAGS): Remove NO_PIE_CFLAGS. Add PICFLAG. Use PICFLAG when building ada/b_gnat1.o and ada/b_gnatb.o. * gcc-interface/Makefile.in: Use pic/libiberty.a if PICFLAG is set. Remove NO_PIE_FLAG. gcc/m2/ChangeLog: * Make-lang.in: New var, GM2_PICFLAGS. Use it. gcc/d/ChangeLog: * Make-lang.in: Remove NO_PIE_CFLAGS. intl/ChangeLog: * Makefile.in: Use @PICFLAG@ in COMPILE as well. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libcody/ChangeLog: * Makefile.in: Pass LD_PICFLAG to LDFLAGS. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this check. * configure: Regenerate. libcpp/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libdecnumber/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libiberty/ChangeLog: * configure.ac: Also set shared when enable_host_pie. * configure: Regenerate. zlib/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate.
2023-06-15cprop_hardreg: Enable propagation of the stack pointer if possibleManolis Tsamis1-1/+6
Propagation of the stack pointer in cprop_hardreg is currenty forbidden in all cases, due to maybe_mode_change returning NULL. Relax this restriction and allow propagation when no mode change is requested. gcc/ChangeLog: * regcprop.cc (maybe_mode_change): Enable stack pointer propagation.
2023-06-15Add another testcase for PR 110266Andrew Pinski1-0/+9
Since the combining of sin/cos into cexpi is depedent on the target, this adds another testcase which had failed (earlier in evpr rather than vrp2) that will fail on all targets rather than ones which have sincos or C99 math functions. Committed as obvious after a quick test. gcc/testsuite/ChangeLog: PR tree-optimization/110266 * gcc.c-torture/compile/pr110266.c: New test.
2023-06-15Check for integer only complex.Andrew MacLeod2-2/+24
With the expanded capabilities of range-op dispatch, floating point complex objects can appear when folding, whic they couldn't before. In the processig for extracting integers from complex ints, make sure it is an integer complex. PR tree-optimization/110266 gcc/ * gimple-range-fold.cc (adjust_imagpart_expr): Check for integer complex type. (adjust_realpart_expr): Ditto. gcc/testsuite/ * gcc.dg/pr110266.c: New.
2023-06-15libcpp: Diagnose #include after failed __has_include [PR80753]Jakub Jelinek2-1/+29
As can be seen in the testcase, we don't diagnose #include/#include_next of a non-existent header if __has_include/__has_include_next is done for that header first. The problem is that we normally error the first time some header is not found, but in the _cpp_FFK_HAS_INCLUDE case obviously don't want to diagnose it, just expand it to 0. And libcpp caches both successful includes and unsuccessful ones. The following patch fixes that by remembering that we haven't diagnosed error when using __has_include* on it, and diagnosing it when using the cache entry in normal mode the first time. I think _cpp_FFK_NORMAL is the only mode in which we normally diagnose errors, for _cpp_FFK_PRE_INCLUDE that open_file_failed isn't reached and for _cpp_FFK_FAKE neither. 2023-06-15 Jakub Jelinek <jakub@redhat.com> PR preprocessor/80753 libcpp/ * files.cc (struct _cpp_file): Add deferred_error bitfield. (_cpp_find_file): When finding a file in cache with deferred_error set in _cpp_FFK_NORMAL mode, call open_file_failed and clear the flag. Set deferred_error in _cpp_FFK_HAS_INCLUDE mode if open_file_failed hasn't been called. gcc/testsuite/ * c-c++-common/missing-header-5.c: New test.
2023-06-15libgomp: Extend OMP_ALLOCATOR, add affinity env var docTobias Burnus8-14/+420
Support OpenMP 5.1's syntax for OMP_ALLOCATOR as well, which permits besides predefined allocators also predefined memspaces optionally followed by traits. Additionally, this commit adds the previously lacking documentation for OMP_ALLOCATOR, OMP_AFFINITY_FORMAT and OMP_DISPLAY_AFFINITY. libgomp/ChangeLog: * env.c (gomp_def_allocator_envvar): New var. (parse_allocator): Handle OpenMP 5.1 syntax. (cleanup_env): New. (omp_display_env): Output gomp_def_allocator_envvar for an allocator with traits. * libgomp.texi (OMP_ALLOCATOR, OMP_AFFINITY_FORMAT, OMP_DISPLAY_AFFINITY): New. * testsuite/libgomp.c/allocator-1.c: New test. * testsuite/libgomp.c/allocator-2.c: New test. * testsuite/libgomp.c/allocator-3.c: New test. * testsuite/libgomp.c/allocator-4.c: New test. * testsuite/libgomp.c/allocator-5.c: New test. * testsuite/libgomp.c/allocator-6.c: New test.
2023-06-15x86/AVX512: use VMOVDDUP for broadcast to V2DFJan Beulich1-2/+2
Like is already the case for the AVX/AVX2 form, VMOVDDUP - acting on double precision floating values - is more appropriate to use here, and it can also result in shorter insn encodings when source is memory or %xmm0...%xmm7, and no masking is applied (in allowing a 2-byte VEX prefix then instead of a 3-byte one). gcc/ * config/i386/sse.md (<avx512>_vec_dup<mode><mask_name>): Use vmovddup.
2023-06-15x86: add Bk and Br to comment list B's sub-charsJan Beulich1-0/+2
gcc/ * config/i386/constraints.md: Mention k and r for B.
2023-06-15LoongArch: Avoid non-returning indirect jumps through $ra [PR110136]Lulu Cheng1-2/+6
Micro-architecture unconditionally treats a "jr $ra" as "return from subroutine", hence doing "jr $ra" would interfere with both subroutine return prediction and the more general indirect branch prediction. Therefore, a problem like PR110136 can cause a significant increase in branch error prediction rate and affect performance. The same problem exists with "indirect_jump". gcc/ChangeLog: PR target/110136 * config/loongarch/loongarch.md: Modify the register constraints for template "jumptable" and "indirect_jump" from "r" to "e". Co-authored-by: Andrew Pinski <apinski@marvell.com>
2023-06-15ada: Remove unused filesMarc Poulhiès6-28/+0
gcc/ada/ChangeLog: * vxworks7-cert-rtp-base-link.spec: Removed. * vxworks7-cert-rtp-base-link__ppc64.spec: Removed. * vxworks7-cert-rtp-base-link__x86.spec: Removed. * vxworks7-cert-rtp-base-link__x86_64.spec: Removed. * vxworks7-cert-rtp-link.spec: Removed. * vxworks7-cert-rtp-link__ppcXX.spec: Removed.
2023-06-15ada: Fix wrong code for ACATS cd1c03i on Morello targetEric Botcazou1-2/+6
gcc/ada/ * gcc-interface/utils2.cc (build_binary_op) <MODIFY_EXPR>: Do not remove a VIEW_CONVERT_EXPR on the LHS if it is also on the RHS.
2023-06-15ada: Fix wrong finalization for double subtype of bounded vectorEric Botcazou1-4/+10
The special handling of temporaries created for return values and subject to a renaming needs to be restricted to the top level, where it is needed to prevent dangling references to the frame of the elaboration routine from being created, because, at a lower level, the front-end may create implicit renamings of objects as these temporaries, so a copy is not allowed. gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Restrict the special handling of temporaries created for return values and subject to a renaming to the top level.
2023-06-15ada: Make minor improvements to user's guideRonan Desplanques3-37/+36
gcc/ada/ * doc/gnat_ugn/about_this_guide.rst: Fix typo. Uniformize punctuation. * doc/gnat_ugn/the_gnat_compilation_model.rst: Uniformize punctuation. Fix capitalization. Fix indentation of code block. Fix RST formatting syntax errors. * gnat_ugn.texi: Regenerate.
2023-06-15ada: Reject Loop_Entry inside prefix of Loop_EntryYannick Moy1-3/+18
This rule was incompletely stated in SPARK RM and not checked. This is now fixed. gcc/ada/ * sem_attr.adb (Analyze_Attribute): Reject case of Loop_Entry inside the prefix of Loop_Entry, as per SPARK RM 5.5.3.1(4,8).
2023-06-15ada: Fix too small secondary stack allocation for returned conversionEric Botcazou2-30/+63
The previous fix did not address a latent issue whereby the allocation would be made using the (static) subtype of the conversion instead of the (dynamic) subtype of the return object, so this change rewrites the code responsible for determining the type used for the allocation, and also contains a small improvement to the Has_Tag_Of_Type predicate. gcc/ada/ * exp_ch3.adb (Make_Allocator_For_Return): Rewrite the logic that determines the type used for the allocation and add assertions. * exp_util.adb (Has_Tag_Of_Type): Also return true for extension aggregates.
2023-06-15ada: Fix internal error on loop iterator filter with -gnatVaEric Botcazou3-4/+13
The problem is that the condition of the iterator filter is expanded early, before it is integrated into an if statement of the loop body, so there is no place to attach the actions generated by this expansion. This happens only for simple loops, i.e. with a parameter specification, so the fix uses the same approach for them as for loops based on iterators. gcc/ada/ * sinfo.ads (Iterator_Filter): Document field. * sem_ch5.adb (Analyze_Iterator_Specification): Move comment around. (Analyze_Loop_Parameter_Specification): Only preanalyze the iterator filter, if any. * exp_ch5.adb (Expand_N_Loop_Statement): Analyze the new list built when an iterator filter is present.
2023-06-15ada: Revert latest change to Find_Hook_ContextEric Botcazou1-10/+0
The issue is that, if an aggregate is both below a conditional expression and above another conditional expression in the tree, we have currently no place to put the finalization actions generated by the innermost expression in the context of the aggregate before it is expanded, so they end up being placed after the outermost expression. But it is not clear whether that's really problematic because this does not seem to happen for array aggregates with multiple or others choices: in this case the aggregate is expanded first and the code path is not taken. gcc/ada/ * exp_util.adb (Find_Hook_Context): Revert latest change.
2023-06-15ada: Fix too small secondary stack allocation for returned aggregateEric Botcazou1-3/+14
This restores the specific treatment of aggregates that are returned through an extended return statement in a function returning a class-wide type, and which was incorrectly dropped in an earlier change. gcc/ada/ * exp_ch3.adb (Make_Allocator_For_Return): Deal again specifically with an aggregate returned through an object of a class-wide type.
2023-06-15ada: Remove dead code in Expand_Iterator_Loop_Over_ContainerEric Botcazou1-13/+4
The Condition_Actions field can only be populated for while loops. gcc/ada/ * exp_ch5.adb (Expand_Iterator_Loop_Over_Container): Do not insert an always empty list. Remove unused parameter Isc. (Expand_Iterator_Loop): Adjust call to above procedure.
2023-06-15ada: Add escape hatch to configurable run-timeRonan Desplanques2-0/+12
Before this patch, the fact that Restrictions pragmas had to fit on a single line in system.ads was difficult to reconcile with the 80-character line limit that is enforced in that file. The special rules for pragmas in system.ads made it impossible to us the Style_Checks pragma to allow long Restrictions pragmas. This patch relaxes those rules so the Style_Checks pragma can be used in system.ads. gcc/ada/ * targparm.adb: Allow pragma Style_Checks in some forms. * targparm.ads: Document new pragma permission.
2023-06-15ada: Fix missing finalization for aggregates nested in conditional expressionsEric Botcazou2-1/+23
The finalization actions for the components of the aggregates are blocked by Expand_Ctrl_Function_Call, which sets Is_Ignored_Transient on all the temporaries generated from within a conditional expression whatever the intermediate constructs. Now aggregates and their expansion in the form of block and loop statements are "impenetrable" as far as temporaries are concerned, i.e. the lifetime of temporaries generated within them does not extend beyond them, so their finalization must not be blocked there. gcc/ada/ * exp_util.ads (Within_Case_Or_If_Expression): Adjust description. * exp_util.adb (Find_Hook_Context): Stop the search for the topmost conditional expression, if within one, at contexts where temporaries may be contained. (Within_Case_Or_If_Expression): Return false upon first encoutering contexts where temporaries may be contained.
2023-06-15ada: Adjust QNX Ada priorities to match QNX system prioritiesJohannes Kliemann2-9/+7
The Ada priority range of the QNX runtime started from 0, differing from the QNX system priorities range starting from 1. As this may cause confusion, especially if used in a mixed language environment, the Ada priority range now starts at 1. The default priority of Ada tasks as mandated is the middle of the priority range. On QNX this means the default priority of Ada tasks is 30. This is much higher than the default QNX priority of 10 and may cause unexpected system interruptions when Ada tasks take a lot of CPU time. gcc/ada/ * libgnarl/s-osinte__qnx.adb: Adjust priority conversion function. * libgnat/system-qnx-arm.ads: Adjust priority range and default priority.
2023-06-15ada: Adjust comments in targparm.adsRonan Desplanques1-20/+5
This patch removes a few dangling references to the late front-end implementation of exceptions from the comments of targparm.ads, and also fixes a thinko there. gcc/ada/ * targparm.ads: Remove references to front-end-based exceptions. Fix thinko.
2023-06-15ada: Accept aspect Always_Terminates on packagesPiotr Trojanek2-2/+21
The recently added aspect Always_Terminates is now allowed on packages and generic packages, but only when it has no arguments. The intuitive meaning is that all subprograms declared in such a package are always terminating. gcc/ada/ * contracts.adb (Add_Contract_Item): Add pragma Always_Terminates to package contract. * sem_prag.adb (Analyze_Pragma): Accept pragma Always_Terminates on packages and generic packages, but only when it has no arguments.
2023-06-15ada: Accept aspect Always_Terminates on entriesPiotr Trojanek1-0/+5
The recently added aspect Always_Terminates is allowed on both procedures and entries. gcc/ada/ * sem_prag.adb (Analyze_Pragma): Accept pragma Always_Terminates when it applies to an entry.
2023-06-15ada: Reject aspect Always_Terminates on functions and generic functionsPiotr Trojanek1-0/+13
The recently added aspect Always_Terminates is only allowed on procedures. gcc/ada/ * sem_prag.adb (Analyze_Pragma): Reject pragma Always_Terminates when it applies to a function or generic function.
2023-06-15ada: Fix missing error on function call returning incomplete viewEric Botcazou1-0/+6
Testing for the presence of Non_Limited_View is not sufficient to detect whether the nonlimited view has been analyzed because Build_Limited_Views always sets the field on the limited view. Instead the discriminant is whether this nonlimited view is itself an incomplete type. gcc/ada/ * sem_ch4.adb (Analyze_Call): Adjust the test to detect the presence of an incomplete view of a type on a function call.
2023-06-15ada: Fix minor issues in commentsRonan Desplanques1-3/+2
The package Ttypef has been removed but a reference to it was left over in a comment. This patch removes that reference, and also fixes a typo. gcc/ada/ * ttypes.ads: Remove reference to Ttypef in comment. Fix typo in comment.