]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
5 hours agomatch.pd: Only merge truncation with conversion for -fno-signed-zeros releases/gcc-13
Joe Ramsay [Fri, 15 Mar 2024 09:20:45 +0000 (09:20 +0000)] 
match.pd: Only merge truncation with conversion for -fno-signed-zeros

This optimisation does not honour signed zeros, so should not be
enabled except with -fno-signed-zeros.

gcc/ChangeLog:

* match.pd: Fix truncation pattern for -fno-signed-zeroes

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/no_merge_trunc_signed_zero.c: New test.

(cherry picked from commit 7dd3b2b09cbeb6712ec680a0445cb0ad41070423)

6 hours ago[PATCH v3] RISC-V: Add split pattern to generate SFB instructions. [PR113095]
Monk Chiang [Wed, 24 Jan 2024 17:19:28 +0000 (10:19 -0700)] 
[PATCH v3] RISC-V: Add split pattern to generate SFB instructions. [PR113095]

Since the match.pd transforms (zero_one == 0) ? y : z <op> y,
into ((typeof(y))zero_one * z) <op> y. Add splitters to recongize
this expression to generate SFB instructions.

gcc/ChangeLog:
PR target/113095
* config/riscv/riscv.md: New splitters to rewrite single bit
sign extension as the condition to SFB instructions.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/sfb.c: New test.
* gcc.target/riscv/pr113095.c: New test.

(cherry picked from commit fb54b9772816968032518d4008be5090e0d95109)

9 hours agotarget/111600 - avoid deep recursion in access diagnostics
Richard Biener [Thu, 28 Sep 2023 09:51:30 +0000 (11:51 +0200)] 
target/111600 - avoid deep recursion in access diagnostics

pass_waccess::check_dangling_stores uses recursion to traverse the CFG.
The following changes this to use a heap allocated worklist to avoid
blowing the stack.

Instead of using a better iteration order it tries hard to preserve
the current iteration order to avoid new false positives to pop up
since the set of stores we keep track isn't properly modeling flow,
so what is diagnosed and what not is quite random.  We are also
lacking the ideal RPO compute on the inverted graph that would just
ignore reverse unreachable code (as the current iteration scheme does).

PR target/111600
* gimple-ssa-warn-access.cc (pass_waccess::check_dangling_stores):
Use a heap allocated worklist for CFG traversal instead of
recursion.

(cherry picked from commit f194c684a28a5d449bd034a2c604d04ba465e4fe)

14 hours agoLoongArch: Fix eh_return epilogue for normal returns.
Yang Yujie [Fri, 8 Dec 2023 10:01:18 +0000 (18:01 +0800)] 
LoongArch: Fix eh_return epilogue for normal returns.

On LoongArch, the regitsters $r4 - $r7 (EH_RETURN_DATA_REGNO) will be saved
and restored in the function prologue and epilogue if the given function calls
__builtin_eh_return.  This causes the return value to be overwritten on normal
return paths and breaks a rare case of libgcc's _Unwind_RaiseException.

gcc/ChangeLog:

PR target/114848
* config/loongarch/loongarch.cc: Do not restore the saved eh_return
data registers ($r4-$r7) for a normal return of a function that calls
__builtin_eh_return elsewhere.
* config/loongarch/loongarch-protos.h: Same.
* config/loongarch/loongarch.md: Same.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/eh_return-normal-return.c: New test.

(cherry picked from commit 4b421728289e6f1caa0dfaa953a11698ab95d37d)

15 hours agoDaily bump.
GCC Administrator [Tue, 30 Apr 2024 00:21:15 +0000 (00:21 +0000)] 
Daily bump.

25 hours agoRISC-V: Fix vsetvl pass ICE
Lehua Ding [Wed, 30 Aug 2023 09:48:00 +0000 (17:48 +0800)] 
RISC-V: Fix vsetvl pass ICE

This patch fix pr111234 (a vsetvl pass ICE) when fuse a mask any
vlmax vsetvl_vtype_change_only insn with a mu vsetvl insn.

PR target/111234

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc (gen_vsetvl_pat): Remove condition.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/pr111234.c: New test.

(cherry picked from commit ac55f9710fe82a4ed8cb132f57303775ce60e5d1)

27 hours agolibstdc++: Update Solaris baselines for GCC 13.2
Rainer Orth [Mon, 29 Apr 2024 12:30:35 +0000 (14:30 +0200)] 
libstdc++: Update Solaris baselines for GCC 13.2

This patch updates the Solaris baselines for the GLIBCXX_3.4.32 version
added in GCC 13.2.

Tested on i386-pc-solaris2.11 and sparc-sun-solaris2.11 (32 and 64-bit
each) on the gcc-13 branch and (together with the GLIBCXX_3.4.33 update)
on both gcc-14 branch and trunk.

2024-04-28  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
* config/abi/post/i386-solaris/baseline_symbols.txt: Regenerate.
* config/abi/post/i386-solaris/amd64/baseline_symbols.txt:
Likewise.
* config/abi/post/sparc-solaris/baseline_symbols.txt: Likewise.
* config/abi/post/sparc-solaris/sparcv9/baseline_symbols.txt:
Likewise.

39 hours agoDaily bump.
GCC Administrator [Mon, 29 Apr 2024 00:22:20 +0000 (00:22 +0000)] 
Daily bump.

2 days agoDaily bump.
GCC Administrator [Sun, 28 Apr 2024 00:21:32 +0000 (00:21 +0000)] 
Daily bump.

3 days agoDaily bump.
GCC Administrator [Sat, 27 Apr 2024 00:21:27 +0000 (00:21 +0000)] 
Daily bump.

3 days agoaarch64: Fix SCHEDULER_IDENT for Cortex-A510
Richard Ball [Fri, 26 Apr 2024 17:15:23 +0000 (18:15 +0100)] 
aarch64: Fix SCHEDULER_IDENT for Cortex-A510

The SCHEDULER_IDENT for this CPU was incorrectly
set to cortexa55. This can cause
sub-optimal asm to be generated.

gcc/ChangeLog:
PR target/114272
* config/aarch64/aarch64-cores.def (AARCH64_CORE):
Change SCHEDULER_IDENT from cortexa55 to cortexa53
for Cortex-A510.

4 days agolibstdc++: Update status tables to refer to GCC 13 not mainline
Jonathan Wakely [Fri, 26 Apr 2024 10:46:01 +0000 (11:46 +0100)] 
libstdc++: Update status tables to refer to GCC 13 not mainline

This should have been done before the 13.1.0 release.

libstdc++-v3/ChangeLog:

* doc/html/manual/status.html: Regenerate.
* doc/xml/manual/status_cxx1998.xml: Replace references to
mainline GCC.
* doc/xml/manual/status_cxx2011.xml: Likewise.
* doc/xml/manual/status_cxx2014.xml: Likewise.
* doc/xml/manual/status_cxx2017.xml: Likewise.
* doc/xml/manual/status_cxx2020.xml: Likewise.
* doc/xml/manual/status_cxx2023.xml: Likewise.
* doc/xml/manual/status_cxxtr1.xml: Likewise.
* doc/xml/manual/status_cxxtr24733.xml: Likewise.

4 days agoi386: Fix array index overflow in pr105354-2.c
Haochen Jiang [Fri, 26 Apr 2024 08:48:29 +0000 (16:48 +0800)] 
i386: Fix array index overflow in pr105354-2.c

The array index should not be over 8 for v8hi, or it will fail
under -O0 or using -fstack-protector.

gcc/testsuite/ChangeLog:

PR target/110621
* gcc.target/i386/pr105354-2.c: As mentioned.

4 days agogfortran: Allow ref'ing PDT's len() in parameter-initializer.
Andre Vehreschild [Wed, 12 Jul 2023 10:51:30 +0000 (12:51 +0200)] 
gfortran: Allow ref'ing PDT's len() in parameter-initializer.

Fix declaring a parameter initialized using a pdt_len reference
not simplifying the reference to a constant.

2023-07-12  Andre Vehreschild  <vehre@gcc.gnu.org>

gcc/fortran/ChangeLog:

PR fortran/102003
* expr.cc (find_inquiry_ref): Replace len of pdt_string by
constant.
(simplify_ref_chain): Ensure input to find_inquiry_ref is
NULL.
(gfc_match_init_expr): Prevent PDT analysis for function calls.
(gfc_pdt_find_component_copy_initializer): Get the initializer
value for given component.
* gfortran.h (gfc_pdt_find_component_copy_initializer): New
function.
* simplify.cc (gfc_simplify_len): Replace len() of PDT with pdt
component ref or constant.

gcc/testsuite/ChangeLog:

* gfortran.dg/pdt_33.f03: New test.

(cherry picked from commit f9182da3213aa57c16dd0b52862126de4a259f6a)

4 days agoDaily bump.
GCC Administrator [Fri, 26 Apr 2024 00:21:07 +0000 (00:21 +0000)] 
Daily bump.

4 days agolibstdc++: Add libstdc++_libbacktrace.a to libstdc++exp
Jonathan Wakely [Thu, 18 Apr 2024 16:26:55 +0000 (17:26 +0100)] 
libstdc++: Add libstdc++_libbacktrace.a to libstdc++exp

This completes the fixes to put all experimental symbols into
libstdc++exp.a.

On trunk the libstdc++_libbacktrace.a was removed completely and its
contents aded to libstdc++exp.a instead. We don't want to remove it on
the gcc-13 branch because that would break makefiles using it. We can
add the contents to libstdc++exp.a and then install a symlink so that
using -lstdc++_libbacktrace still works, but links to libstdc++exp.a
instead.

The libstdc++_libbacktrace.la libtool control file is removed by this
change, because I'm pretty sure it's not actually useful, and I don't
know whether it should be a symlink to libstdc++exp.la or a regular file
that refers to libstdc++_libbacktrace.a.

libstdc++-v3/ChangeLog:

* src/experimental/Makefile.am (install-exec-local): New target.
(uninstall-local): New target.
* src/experimental/Makefile.in: Regenerate.
* src/libbacktrace/Makefile.am: Build libstdc++_libbacktrace as
noinst_LTLIBRARIES so it's only a convenience library.
* src/libbacktrace/Makefile.in: Regenerate.

4 days agolibstdc++: Fix libstdc++exp.a so it really does contain Filesystem TS symbols
Jonathan Wakely [Fri, 2 Feb 2024 12:07:09 +0000 (12:07 +0000)] 
libstdc++: Fix libstdc++exp.a so it really does contain Filesystem TS symbols

In r14-3812-gb96b554592c5cb I claimed that libstdc++exp.a now contains
all the symbols from libstdc++fs.a as well as libstdc++_libbacktrace.a,
but that wasn't true. Only the symbols from the latter were added to
libstdc++exp.a, the Filesystem TS ones weren't. This seems to be because
libtool won't combine static libs that are going to be installed
separately. Because libstdc++fs.a is still installed, libtool decides it
shouldn't be included in libstdc++exp.a.

The solution is similar to what we already do for libsupc++.a: build two
static libs, libstdc++fs.a and libstdc++fsconvenience.a, where the
former is installed and the latter isn't. If we then tell libtool to
include the latter in libstdc++exp.a it will do as it's told.

libstdc++-v3/ChangeLog:

* src/experimental/Makefile.am: Use libstdc++fsconvenience.a
instead of libstdc++fs.a.
* src/experimental/Makefile.in: Regenerate.
* src/filesystem/Makefile.am: Build libstdc++fsconvenience.a as
well.
* src/filesystem/Makefile.in: Regenerate.

(cherry picked from commit abf40d2953639534af3428424f467adf3cb52177)

5 days agoarm: Zero/Sign extends for CMSE security
Richard Ball [Thu, 25 Apr 2024 14:30:42 +0000 (15:30 +0100)] 
arm: Zero/Sign extends for CMSE security

Co-Authored by: Andre Simoes Dias Vieira <Andre.SimoesDiasVieira@arm.com>

This patch makes the following changes:

1) When calling a secure function from non-secure code then any arguments
   smaller than 32-bits that are passed in registers are zero- or sign-extended.
2) After a non-secure function returns into secure code then any return value
   smaller than 32-bits that is passed in a register is  zero- or sign-extended.

This patch addresses the following CVE-2024-0151.

gcc/ChangeLog:
PR target/114837
* config/arm/arm.cc (cmse_nonsecure_call_inline_register_clear):
Add zero/sign extend.
(arm_expand_prologue): Add zero/sign extend.

gcc/testsuite/ChangeLog:

* gcc.target/arm/cmse/extend-param.c: New test.
* gcc.target/arm/cmse/extend-return.c: New test.

(cherry picked from commit ad45086178d833254d66fab518b14234418f002b)

5 days agors6000: Fix wrong align passed to build_aligned_type [PR88309]
Kewen Lin [Tue, 9 Apr 2024 02:01:36 +0000 (21:01 -0500)] 
rs6000: Fix wrong align passed to build_aligned_type [PR88309]

As the comments in PR88309 show, there are two oversights
in rs6000_gimple_fold_builtin that pass align in bytes to
build_aligned_type but which actually requires align in
bits, it causes unexpected ICE or hanging in function
is_miss_rate_acceptable due to zero align_unit value.

This patch is to fix them by converting bytes to bits, add
an assertion on positive align_unit value and notes function
build_aligned_type requires align measured in bits in its
function comment.

PR target/88309

Co-authored-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/ChangeLog:

* config/rs6000/rs6000-builtin.cc (rs6000_gimple_fold_builtin): Fix
wrong align passed to function build_aligned_type.
* tree-ssa-loop-prefetch.cc (is_miss_rate_acceptable): Add an
assertion to ensure align_unit should be positive.
* tree.cc (build_qualified_type): Update function comments.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr88309.c: New test.

5 days agoDaily bump.
GCC Administrator [Thu, 25 Apr 2024 00:21:00 +0000 (00:21 +0000)] 
Daily bump.

6 days agoRISC-V: Fix recursive vsetvli checking [PR114172]
Kito Cheng [Wed, 24 Apr 2024 08:54:44 +0000 (16:54 +0800)] 
RISC-V: Fix recursive vsetvli checking [PR114172]

extract_single_source will recursive checking the sources to
make sure if it's single source, however it may cause infinite
recursive when the source is come from itself, so it should just skip
first source to prevent that.

NOTE: This logic has existing on trunk/GCC 14, but it included in a big
vsetvli improvement patch, which is not backport to GCC 13.

```

void saxpy_rvv_m8(float *y, long vl)
{
    for (;;)
    {
        vl = __riscv_vsetvl_e32m8(vl); //ICE
        vfloat32m8_t y_vec;
        __riscv_vse32_v_f32m8(y, y_vec, vl);
    }
}
```

gcc/ChangeLog:

PR target/114172
* config/riscv/riscv-vsetvl.cc (extract_single_source):
Skip first set.

gcc/testsuite/ChangeLog:

PR target/114172
* gcc.target/riscv/rvv/vsetvl/pr114172.c: New.

6 days agoDaily bump.
GCC Administrator [Wed, 24 Apr 2024 00:21:04 +0000 (00:21 +0000)] 
Daily bump.

7 days agoDaily bump.
GCC Administrator [Tue, 23 Apr 2024 00:21:36 +0000 (00:21 +0000)] 
Daily bump.

8 days agoi386: Fix Sierra Forest auto dispatch
Haochen Jiang [Mon, 22 Apr 2024 08:57:36 +0000 (16:57 +0800)] 
i386: Fix Sierra Forest auto dispatch

gcc/ChangeLog:

* common/config/i386/i386-common.cc (processor_alias_table):
Let Sierra Forest map to CPU_TYPE enum.

8 days agolibfortran: Fix handling of formatted separators.
Jerry DeLisle [Mon, 22 Apr 2024 03:50:26 +0000 (20:50 -0700)] 
libfortran: Fix handling of formatted separators.

Backport from mainline.

PR libfortran/114304
PR libfortran/105473

libgfortran/ChangeLog:

* io/list_read.c (eat_separator): Add logic to handle spaces
preceding a comma or semicolon such that that a 'null' read
occurs without error at the end of comma or semicolon
terminated input lines. Add check and error message for ';'.
Accept tab as alternative to space.
(list_formatted_read_scalar): Treat comma as a decimal point
when specified by the decimal mode on the first item.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr105473.f90: Modify for revised checks.
* gfortran.dg/pr114304-2.f90: New test.
* gfortran.dg/pr114304.f90: New test.

8 days agoDaily bump.
GCC Administrator [Mon, 22 Apr 2024 00:21:09 +0000 (00:21 +0000)] 
Daily bump.

9 days agoAVR: target/114794 - Tweak __udivmodqi4
Georg-Johann Lay [Sun, 21 Apr 2024 12:33:50 +0000 (14:33 +0200)] 
AVR: target/114794 - Tweak __udivmodqi4

libgcc/
PR target/114794
* config/avr/lib1funcs.S (__udivmodqi4): Tweak.

(cherry picked from commit a44d16efa7a508f8b8f303417d0714c39f159725)

9 days agoc-family: Allow arguments with NULLPTR_TYPE as sentinels [PR114780]
Jakub Jelinek [Fri, 19 Apr 2024 22:12:36 +0000 (00:12 +0200)] 
c-family: Allow arguments with NULLPTR_TYPE as sentinels [PR114780]

While in C++ the ellipsis argument conversions include
"An argument that has type cv std::nullptr_t is converted to type void*"
in C23 a nullptr_t argument is not promoted in any way, but va_arg
description says:
"the type of the next argument is nullptr_t and type is a pointer type that has the same
representation and alignment requirements as a pointer to a character type."
So, while in C++ check_function_sentinel will never see NULLPTR_TYPE, for
C23 it can see that and currently we incorrectly warn about those.

The only question is whether we should warn on any argument with
nullptr_t type or just about nullptr (nullptr_t argument with integer_zerop
value).  Through undefined behavior guess one could pass non-NULL pointer
that way, say by union { void *p; nullptr_t q; } u; u.p = &whatever;
and pass u.q to ..., but valid code should always pass something that will
read as (char *) 0 when read using va_arg (ap, char *), so I think it is
better not to warn rather than warn in those cases.

Note, clang seems to pass (void *)0 rather than expression of nullptr_t
type to ellipsis in C23 mode as if it did the C++ ellipsis argument
conversions, in that case guess not warning about that would be even safer,
but what GCC does I think follows the spec more closely, even when in a
valid program one shouldn't be able to observe the difference.

2024-04-20  Jakub Jelinek  <jakub@redhat.com>

PR c/114780
* c-common.cc (check_function_sentinel): Allow as sentinel any
argument of NULLPTR_TYPE.

* gcc.dg/format/sentinel-2.c: New test.

(cherry picked from commit 2afdecccbaf5c5b1c7a235509b37092540906c02)

9 days agortlanal: Fix set_noop_p for volatile loads or stores [PR114768]
Jakub Jelinek [Fri, 19 Apr 2024 06:47:53 +0000 (08:47 +0200)] 
rtlanal: Fix set_noop_p for volatile loads or stores [PR114768]

On the following testcase, combine propagates the mem/v load into mem store
with the same address and then removes it, because noop_move_p says it is a
no-op move.  If it was the other way around, i.e. mem/v store and mem load,
or both would be mem/v, it would be kept.
The problem is that rtx_equal_p never checks any kind of flags on the rtxes
(and I think it would be quite dangerous to change it at this point), and
set_noop_p checks side_effects_p on just one of the operands, not both.
In the MEM <- MEM set, it only checks it on the destination, in
store to ZERO_EXTRACT only checks it on the source.

The following patch adds the missing side_effects_p checks.

2024-04-19  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/114768
* rtlanal.cc (set_noop_p): Don't return true for MEM <- MEM
sets if src has side-effects or for stores into ZERO_EXTRACT
if ZERO_EXTRACT operand has side-effects.

* gcc.dg/pr114768.c: New test.

(cherry picked from commit 9f295847a9c32081bdd0fe908ffba58e830a24fb)

9 days agointernal-fn: Temporarily disable flag_trapv during .{ADD,SUB,MUL}_OVERFLOW etc. expan...
Jakub Jelinek [Thu, 18 Apr 2024 07:45:14 +0000 (09:45 +0200)] 
internal-fn: Temporarily disable flag_trapv during .{ADD,SUB,MUL}_OVERFLOW etc. expansion [PR114753]

__builtin_{add,sub,mul}_overflow{,_p} builtins are well defined
for all inputs even for -ftrapv, and the -fsanitize=signed-integer-overflow
ifns shouldn't abort in libgcc but emit the desired ubsan diagnostics
or abort depending on -fsanitize* setting regardless of -ftrapv.
The expansion of these internal functions uses expand_expr* in various
places (e.g. MULT_EXPR at least in 2 spots), so temporarily disabling
flag_trapv in all those spots would be hard.
The following patch disables it around the bodies of 3 functions
which can do the expand_expr calls.
If it was in the C++ FE, I'd use some RAII sentinel, but I don't think
we have one in the middle-end.

2024-04-18  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/114753
* internal-fn.cc (expand_mul_overflow): Save flag_trapv and
temporarily clear it for the duration of the function, then
restore previous value.
(expand_vector_ubsan_overflow): Likewise.
(expand_arith_overflow): Likewise.

* gcc.dg/pr114753.c: New test.

(cherry picked from commit 6c152c9db3b5b9d43e12846fb7a44977c0b65fc2)

9 days agoasan: Don't instrument .ABNORMAL_DISPATCHER [PR114743]
Jakub Jelinek [Wed, 17 Apr 2024 08:24:18 +0000 (10:24 +0200)] 
asan: Don't instrument .ABNORMAL_DISPATCHER [PR114743]

.ABNORMAL_DISPATCHER is currently the only internal function with
ECF_NORETURN, and asan likes to instrument ECF_NORETURN calls by adding
some builtin call before them, which breaks the .ABNORMAL_DISPATCHER
discovery added in gsi_safe_*.

The following patch fixes asan not to instrument .ABNORMAL_DISPATCHER
calls, like it doesn't instrument a couple of specific builtin calls
as well.

2024-04-17  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/114743
* asan.cc (maybe_instrument_call): Don't instrument calls to
.ABNORMAL_DISPATCHER.

* gcc.dg/asan/pr112709-2.c (freddy): New function from
gcc.dg/ubsan/pr112709-2.c version of the test.

(cherry picked from commit 299d14a54672a4d12c1abbe4031a732bb56cddaa)

9 days agoattribs: Don't crash on NULL TREE_TYPE in diag_attr_exclusions [PR114634]
Jakub Jelinek [Mon, 15 Apr 2024 08:25:22 +0000 (10:25 +0200)] 
attribs: Don't crash on NULL TREE_TYPE in diag_attr_exclusions [PR114634]

The enumerator still doesn't have TREE_TYPE set but diag_attr_exclusions
assumes that all decls must have types.
I think it is better in something as unimportant as diag_attr_exclusions
to be more robust, if there is no type, it can just diagnose exclusions
on the DECL_ATTRIBUTES, like for types it only diagnoses it on
TYPE_ATTRIBUTES.

2024-04-15  Jakub Jelinek  <jakub@redhat.com>

PR c++/114634
* attribs.cc (diag_attr_exclusions): Set attrs[1] to NULL_TREE for
decls with NULL TREE_TYPE.

* g++.dg/ext/attrib68.C: New test.

(cherry picked from commit 7ec54f5fdfec298812a749699874db4d6a7246bb)

9 days agoc++: Fix bogus warnings about ignored annotations [PR114691]
Jakub Jelinek [Fri, 12 Apr 2024 18:53:10 +0000 (20:53 +0200)] 
c++: Fix bogus warnings about ignored annotations [PR114691]

The middle-end warns about the ANNOTATE_EXPR added for while/for loops
if they declare a var inside of the loop condition.
This is because the assumption is that ANNOTATE_EXPR argument is used
immediately in a COND_EXPR (later GIMPLE_COND), but simplify_loop_decl_cond
wraps the ANNOTATE_EXPR inside of a TRUTH_NOT_EXPR, so it no longer
holds.

The following patch fixes that by adding the TRUTH_NOT_EXPR inside of the
ANNOTATE_EXPR argument if any.

2024-04-12  Jakub Jelinek  <jakub@redhat.com>

PR c++/114691
* semantics.cc (simplify_loop_decl_cond): Use cp_build_unary_op with
TRUTH_NOT_EXPR on ANNOTATE_EXPR argument (if any) rather than
ANNOTATE_EXPR itself.

* g++.dg/ext/pr114691.C: New test.

(cherry picked from commit 91146346f57cc54dfeb2669347edd0eb3d13af7f)

9 days agoLimit special asan/ubsan/bitint returns_twice handling to calls in bbs with abnormal...
Jakub Jelinek [Fri, 12 Apr 2024 08:59:54 +0000 (10:59 +0200)] 
Limit special asan/ubsan/bitint returns_twice handling to calls in bbs with abnormal pred [PR114687]

The tree-cfg.cc verifier only diagnoses returns_twice calls preceded
by non-label/debug stmts if it is in a bb with abnormal predecessor.
The following testcase shows that if a user lies in the attributes
(a function which never returns can't be pure, and can't return
twice when it doesn't ever return at all), when we figure it out,
we can remove the abnormal edges to the "returns_twice" call and perhaps
whole .ABNORMAL_DISPATCHER etc.
edge_before_returns_twice_call then ICEs because it can't find such
an edge.

The following patch limits the special handling to calls in bbs where
the verifier requires that.

2024-04-12  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/114687
* gimple-iterator.cc (gsi_safe_insert_before): Only use
edge_before_returns_twice_call if bb_has_abnormal_pred.
(gsi_safe_insert_seq_before): Likewise.

* gcc.dg/asan/pr114687.c: New test.

(cherry picked from commit c9e94ae448ba309dba74de3ee1974a3ed9248889)

9 days agoasan, v3: Fix up handling of > 32 byte aligned variables with -fsanitize=address...
Jakub Jelinek [Thu, 11 Apr 2024 09:12:11 +0000 (11:12 +0200)] 
asan, v3: Fix up handling of > 32 byte aligned variables with -fsanitize=address -fstack-protector* [PR110027]

On Tue, Mar 26, 2024 at 02:08:02PM +0800, liuhongt wrote:
> > > So, try to add some other variable with larger size and smaller alignment
> > > to the frame (and make sure it isn't optimized away).
> > >
> > > alignb above is the alignment of the first partition's var, if
> > > align_frame_offset really needs to depend on the var alignment, it probably
> > > should be the maximum alignment of all the vars with alignment
> > > alignb * BITS_PER_UNIT <=3D MAX_SUPPORTED_STACK_ALIGNMENT
> > >
>
> In asan_emit_stack_protection, when it allocated fake stack, it assume
> bottom of stack is also aligned to alignb. And the place violated this
> is the first var partition. which is 32 bytes offsets,  it should be
> BIGGEST_ALIGNMENT / BITS_PER_UNIT.
> So I think we need to use MAX (BIGGEST_ALIGNMENT /
> BITS_PER_UNIT, ASAN_RED_ZONE_SIZE) for the first var partition.

Your first patch aligned offsets[0] to maximum of alignb and
ASAN_RED_ZONE_SIZE.  But as I wrote in the reply to that mail, alignb there
is the alignment of just a single variable which is the first one to appear
in the sorted list and is placed in the highest spot in the stack frame.
That is not necessarily the largest alignment, the sorting ensures that it
is a variable with the largest size in the frame (and only if several of
them have equal size, largest alignment from the same sized ones).  Your
second patch used maximum of BIGGEST_ALIGNMENT / BITS_PER_UNIT and
ASAN_RED_ZONE_SIZE.  That doesn't change anything at all when using
-mno-avx512f - offsets[0] is still just 32-byte aligned in that case
relative to top of frame, just changes the -mavx512f case to be 64-byte
aligned offsets[0] (aka offsets[0] is then either 0 or -64 instead of either
0 or -32).  That will not help if any variable in the frame needs 128-byte,
256-byte, 512-byte ...  4096-byte alignment.  If you want to fix the bug in
the spot you've touched, you'd need to walk all the
stack_vars[stack_vars_sorted[si2]] for si2 [si + 1, n - 1] and for those
where the loop would do anything (i.e.
stack_vars[i2].representative == i2
&& TREE_CODE (decl2) == SSA_NAME
   ? SA.partition_to_pseudo[var_to_partition (SA.map, decl2)] == NULL_RTX
   : DECL_RTL (decl2) == pc_rtx
and the pred applies (but that means also walking the earlier ones!
because with -fstack-protector* the vars can be processed in several calls) and
alignb2 * BITS_PER_UNIT <= MAX_SUPPORTED_STACK_ALIGNMENT
and compute maximum of those alignments.
That maximum is already computed,
data->asan_alignb = MAX (data->asan_alignb, alignb);
computes that, but you get the final result only after you do all the
expand_stack_vars calls.  You'd need to compute it before.

Though, that change would be still in the wrong place.
The thing is, it would be a waste of the precious stack space when it isn't
needed at all (e.g.  when asan will not at compile time do the use after
return checking, or if it won't do it at runtime, or even if it will do at
runtime it will waste the space on the stack).

The following patch fixes it solely for the __asan_stack_malloc_N
allocations, doesn't enlarge unnecessarily further the actual stack frame.
Because asan is only supported on FRAME_GROWS_DOWNWARD architectures
(mips, rs6000 and xtensa are conditional FRAME_GROWS_DOWNWARD arches, which
for -fsanitize=address or -fstack-protector* use FRAME_GROWS_DOWNWARD 1,
otherwise 0, others supporting asan always just use 1), the assumption for
the dynamic stack realignment is that the top of the stack frame (aka offset
0) is aligned to alignb passed to the function (which is the maximum of alignb
of all the vars in the frame).  As checked by the assertion in the patch,
offsets[0] is 0 most of the time and so that assumption is correct, the only
case when it is not 0 is if -fstack-protector* is on together with
-fsanitize=address and cfgexpand.cc (create_stack_guard) created a stack
guard.  That is the only variable which is allocated in the stack frame
right away, for all others with -fsanitize=address defer_stack_allocation
(or -fstack-protector*) returns true and so they aren't allocated
immediately but handled during the frame layout phases.  So, the original
frame_offset of 0 is changed because of the stack guard to
-pointer_size_in_bytes and later at the
              if (data->asan_vec.is_empty ())
                {
                  align_frame_offset (ASAN_RED_ZONE_SIZE);
                  prev_offset = frame_offset.to_constant ();
                }
to -ASAN_RED_ZONE_SIZE.  The asan_emit_stack_protection code wasn't
taking this into account though, so essentially assumed in the
__asan_stack_malloc_N allocated memory it needs to align it such that
pointer corresponding to offsets[0] is alignb aligned.  But that isn't
correct if alignb > ASAN_RED_ZONE_SIZE, in that case it needs to ensure that
pointer corresponding to frame offset 0 is alignb aligned.

The following patch fixes that.  Unlike the previous case where
we knew that asan_frame_size + base_align_bias falls into the same bucket
as asan_frame_size, this isn't in some cases true anymore, so the patch
recomputes which bucket to use and if going to bucket 11 (because there is
no __asan_stack_malloc_11 function in the library) disables the after return
sanitization.

2024-04-11  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/110027
* asan.cc (asan_emit_stack_protection): Assert offsets[0] is
zero if there is no stack protect guard, otherwise
-ASAN_RED_ZONE_SIZE.  If alignb > ASAN_RED_ZONE_SIZE and there is
stack pointer guard, take the ASAN_RED_ZONE_SIZE bytes allocated at
the top of the stack into account when computing base_align_bias.
Recompute use_after_return_class from asan_frame_size + base_align_bias
and set to -1 if that would overflow to 11.

* gcc.dg/asan/pr110027.c: New test.

(cherry picked from commit 467898d513e602f5b5fc4183052217d7e6d6e8ab)

9 days agoc++: Fix up maybe_warn_for_constant_evaluated calls [PR114580]
Jakub Jelinek [Tue, 9 Apr 2024 07:31:42 +0000 (09:31 +0200)] 
c++: Fix up maybe_warn_for_constant_evaluated calls [PR114580]

When looking at maybe_warn_for_constant_evaluated for the trivial
infinite loops patch, I've noticed that it can emit weird diagnostics
for if constexpr in templates, first warn that std::is_constant_evaluted()
always evaluates to false (because the function template is not constexpr)
and then during instantiation warn that std::is_constant_evaluted()
always evaluates to true (because it is used in if constexpr condition).
Now, only the latter is actually true, even when the if constexpr
is in a non-constexpr function, it will still always evaluate to true.

So, the following patch fixes it to call maybe_warn_for_constant_evaluated
always with IF_STMT_CONSTEXPR_P (if_stmt) as the second argument rather than
true if it is if constexpr with non-dependent condition etc.

2024-04-09  Jakub Jelinek  <jakub@redhat.com>

PR c++/114580
* semantics.cc (finish_if_stmt_cond): Call
maybe_warn_for_constant_evaluated with IF_STMT_CONSTEXPR_P (if_stmt)
as the second argument, rather than true/false depending on if
it is if constexpr with non-dependent constant expression with
bool type.

* g++.dg/cpp2a/is-constant-evaluated15.C: New test.

(cherry picked from commit cfed80b9e4f562c99679739548df9369117dd791)

9 days agovect: Don't clear base_misaligned in update_epilogue_loop_vinfo [PR114566]
Jakub Jelinek [Fri, 5 Apr 2024 12:56:14 +0000 (14:56 +0200)] 
vect: Don't clear base_misaligned in update_epilogue_loop_vinfo [PR114566]

The following testcase is miscompiled, because in the vectorized
epilogue the vectorizer assumes it can use aligned loads/stores
(if the base decl gets alignment increased), but it actually doesn't
increase that.
This is because r10-4203-g97c1460367 added the hunk following
patch removes.  The explanation feels reasonable, but actually it
is not true as the testcase proves.
The thing is, we vectorize the main loop with 64-byte vectors
and the corresponding data refs have base_alignment 16 (the
a array has DECL_ALIGN 128) and offset_alignment 32.  Now, because
of the offset_alignment 32 rather than 64, we need to use unaligned
loads/stores in the main loop (and ditto in the first load/store
in vectorized epilogue).  But the second load/store in the vectorized
epilogue uses only 32-byte vectors and because it is a multiple
of offset_alignment, it checks if we could increase alignment of the
a VAR_DECL, the function returns true, sets base_misaligned = true
and says the access is then aligned.
But when update_epilogue_loop_vinfo clears base_misaligned with the
assumption that the var had to have the alignment increased already,
the update of DECL_ALIGN doesn't happen anymore.

Now, I'd think this base_alignment = false was needed before
r10-4030-gd2db7f7901 change was committed where it incorrectly
overwrote DECL_ALIGN even if it was already larger, rather than
just always increasing it.  But with that change in, it doesn't
make sense to me anymore.

Note, the testcase is latent on the trunk, but reproduces on the 13
branch.

2024-04-05  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/114566
* tree-vect-loop.cc (update_epilogue_loop_vinfo): Don't clear
base_misaligned.

* gcc.target/i386/avx512f-pr114566.c: New test.

(cherry picked from commit a844095e17c1a5aada1364c6f6eaade87ead463c)

9 days agoc++: Fix ICE with weird copy assignment operator [PR114572]
Jakub Jelinek [Fri, 5 Apr 2024 07:31:28 +0000 (09:31 +0200)] 
c++: Fix ICE with weird copy assignment operator [PR114572]

While ctors/dtors don't return anything (undeclared void or this pointer
on arm) and copy assignment operators normally return a reference to *this,
it isn't invalid to return uselessly some class object which might need
destructing, but the OpenMP clause handling code wasn't expecting that.

The following patch fixes that.

2024-04-05  Jakub Jelinek  <jakub@redhat.com>

PR c++/114572
* cp-gimplify.cc (cxx_omp_clause_apply_fn): Call build_cplus_new
on build_call_a result if it has class type.

* testsuite/libgomp.c++/pr114572.C: New test.

(cherry picked from commit 592536eb3c0a97a55b1019ff0216ef77e6ca847e)

9 days agofold-const: Handle NON_LVALUE_EXPR in native_encode_initializer [PR114537]
Jakub Jelinek [Thu, 4 Apr 2024 08:47:52 +0000 (10:47 +0200)] 
fold-const: Handle NON_LVALUE_EXPR in native_encode_initializer [PR114537]

The following testcase is incorrectly rejected.  The problem is that
for bit-fields native_encode_initializer expects the corresponding
CONSTRUCTOR elt value must be INTEGER_CST, but that isn't the case
here, it is wrapped into NON_LVALUE_EXPR by maybe_wrap_with_location.
We could STRIP_ANY_LOCATION_WRAPPER as well, but as all we are looking for
is INTEGER_CST inside, just looking through NON_LVALUE_EXPR seems easier.

2024-04-04  Jakub Jelinek  <jakub@redhat.com>

PR c++/114537
* fold-const.cc (native_encode_initializer): Look through
NON_LVALUE_EXPR if val is INTEGER_CST.

* g++.dg/cpp2a/bit-cast16.C: New test.

(cherry picked from commit 1baec8deb014b8a7da58879a407a4c00cdeb5a09)

9 days agolibquadmath: Don't assume the storage for __float128 arguments is aligned [PR114533]
Jakub Jelinek [Wed, 3 Apr 2024 08:02:35 +0000 (10:02 +0200)] 
libquadmath: Don't assume the storage for __float128 arguments is aligned [PR114533]

With the register_printf_type/register_printf_modifier/register_printf_specifier
APIs the C library is just told the size of the argument and is provided with
a callback to fetch the argument from va_list using va_arg into C library provided
memory.  The C library isn't told what alignment requirement it has, but we were
using direct load of a __float128 value from that memory which assumes
__alignof (__float128) alignment.

The following patch fixes that by using memcpy instead.

I haven't been able to reproduce an actual crash, tried
 #include <quadmath.h>
 #include <stdlib.h>
 #include <stdio.h>

int main ()
{
  __float128 r;
  int prec = 20;
  int width = 46;
  char buf[128];

  r = 2.0q;
  r = sqrtq (r);
  int n = quadmath_snprintf (buf, sizeof buf, "%+-#*.20Qe", width, r);
  if ((size_t) n < sizeof buf)
    printf ("%s\n", buf);
    /* Prints: +1.41421356237309504880e+00 */
  quadmath_snprintf (buf, sizeof buf, "%Qa", r);
  if ((size_t) n < sizeof buf)
    printf ("%s\n", buf);
    /* Prints: 0x1.6a09e667f3bcc908b2fb1366ea96p+0 */
  n = quadmath_snprintf (NULL, 0, "%+-#46.*Qe", prec, r);
  if (n > -1)
    {
      char *str = malloc (n + 1);
      if (str)
        {
          quadmath_snprintf (str, n + 1, "%+-#46.*Qe", prec, r);
          printf ("%s\n", str);
          /* Prints: +1.41421356237309504880e+00 */
        }
      free (str);
    }
  printf ("%+-#*.20Qe\n", width, r);
  printf ("%Qa\n", r);
  printf ("%+-#46.*Qe\n", prec, r);
  printf ("%d %Qe %d %Qe %d %Qe\n", 1, r, 2, r, 3, r);
  return 0;
}
In any case, I think memcpy for loading from it is right.

2024-04-03  Simon Chopin  <simon.chopin@canonical.com>
    Jakub Jelinek  <jakub@redhat.com>

PR libquadmath/114533
* printf/printf_fp.c (__quadmath_printf_fp): Use memcpy to copy
__float128 out of args.
* printf/printf_fphex.c (__quadmath_printf_fphex): Likewise.

Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
(cherry picked from commit 8455d6f6cd43b7b143ab9ee19437452fceba9cc9)

9 days agoexpr: Fix up emit_push_insn [PR114552]
Jakub Jelinek [Wed, 3 Apr 2024 07:59:45 +0000 (09:59 +0200)] 
expr: Fix up emit_push_insn [PR114552]

r13-990 added optimizations in multiple spots to optimize during
expansion storing of constant initializers into targets.
In the load_register_parameters and expand_expr_real_1 cases,
it checks it has a tree as the source and so knows we are reading
that whole decl's value, so the code is fine as is, but in the
emit_push_insn case it checks for a MEM from which something
is pushed and checks for SYMBOL_REF as the MEM's address, but
still assumes the whole object is copied, which as the following
testcase shows might not always be the case.  In the testcase,
k is 6 bytes, then 2 bytes of padding, then another 4 bytes,
while the emit_push_insn wants to store just the 6 bytes.

The following patch simply verifies it is the whole initializer
that is being stored, I think that is best thing to do so late
in GCC 14 cycle as well for backporting.

For GCC 15, perhaps the code could stop requiring it must be at offset zero,
nor that the size is equal, but could use
get_symbol_constant_value/fold_ctor_reference gimple-fold APIs to actually
extract just part of the initializer if we e.g. push just some subset
(of course, still verify that it is a subset).  For sizes which are power
of two bytes and we have some integer modes, we could use as type for
fold_ctor_reference corresponding integral types, otherwise dunno, punt
or use some structure (e.g. try to find one in the initializer?), whatever.
But even in the other spots it could perhaps handle loading of
COMPONENT_REFs or MEM_REFs from the .rodata vars.

2024-04-03  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/114552
* expr.cc (emit_push_insn): Only use store_constructor for
immediate_const_ctor_p if int_expr_size matches size.

* gcc.c-torture/execute/pr114552.c: New test.

(cherry picked from commit 03039744f368a24a452e4ea8d946e9c2cedaf1aa)

9 days agoFix up postboot dependencies [PR106472]
Jakub Jelinek [Tue, 2 Apr 2024 11:40:27 +0000 (13:40 +0200)] 
Fix up postboot dependencies [PR106472]

On Wed, Mar 13, 2024 at 10:13:37AM +0100, Jakub Jelinek wrote:
> While the first Makefile.tpl hunk looks obviously ok, the others look
> completely wrong to me.
> There is nothing special about libgo vs. libbacktrace/libatomic
> compared to any other target library which is not bootstrapped vs. any
> of its dependencies which are in the bootstrapped set.
> So, Makefile.tpl shouldn't hardcode such dependencies.

Here is my version of the fix.
The dependencies in the toplevel Makefile simply didn't take into account
that some target modules could be in a bootstrapped build built in some
configurations as bootstrap modules (typically as dependencies of other
target bootstrap modules), while in other configurations just as
dependencies of non-bootstrap target modules and so not built during the
bootstrap, but after it.
Makefile.tpl arranges for those postboot target module -> target module
dependencies to be emitted only inside of an @unless gcc-bootstrap block,
while for @if gcc-bootstrap it just emits
configure-target-whatever: stage_last
dependencies which ensure those postbootstrap target modules are only built
after everything that is bootstrapped has been.

Now, the libbacktrace/libatomic target modules have bootstrap=true
target_modules = { module= libbacktrace; bootstrap=true; };
target_modules = { module= libatomic; bootstrap=true; lib_path=.libs; };
because those modules are dependencies of libphobos target module, so
when d is included among bootstrapped languages, those are all bootstrapped
and everything works correctly.
While if d is not included, libphobos target module is disabled,
libbacktrace/libatomic target modules aren't bootstrapped, nothing during
bootstrap needs them, but post bootstrap libgo target module depends on
the libatomic and libbacktrace target modules, libgfortran target module
depends on the libbacktrace target module and libgm2 target module depends
on the libatomic target module, but those dependencies were emitted only
@unless gcc-bootstrap.  There is a similar theoretical problem for zlib
target module if GCJ would be ressurected, libphobos as bootstrap target
module depends on the zlib target module, but if d is not configured,
fastjar also depends on it.

The following patch arranges for the @if gcc-bootstrap case to emit also
target module -> target module dependencies, but conditionally on the
on dependency not being bootstrapped.

In the generated Makefile.in you can see what the Makefile.tpl change
produces and that it just adds extra dependencies which weren't there
before in the @if gcc-bootstrap case.

I've bootstrapped without this patch with
../configure --enable-languages=c,c++,go; make
on x86_64-linux (note, make -j2 or higher usually worked) which failed
as described in the PR, then with this patch with the same command which
built fine and the Makefile difference between the two builds being
diff -up obj40{a,b}/Makefile
--- obj40a/Makefile     2024-03-31 00:35:22.243791499 +0100
+++ obj40b/Makefile     2024-03-31 22:40:38.143299144 +0200
@@ -29376,6 +29376,14 @@ configure-bison: stage_last
 configure-flex: stage_last
 configure-m4: stage_last

+configure-target-fastjar: maybe-configure-target-zlib
+all-target-fastjar: maybe-all-target-zlib
+all-target-libgo: maybe-all-target-libbacktrace
+all-target-libgo: maybe-all-target-libatomic
+all-target-libgm2: maybe-all-target-libatomic
+configure-target-libgfortran: maybe-all-target-libbacktrace
+configure-target-libgo: maybe-all-target-libbacktrace
+

 # Dependencies for target modules on other target modules are
 # described by lang_env_dependencies; the defaults apply to anything

which I believe are exactly the extra dependencies we want.
Plus I've done normal x86_64-linux and i686-linux bootstraps/regtests
which in my case include --enable-languages=default,ada,obj-c++,lto,go,d,rust,m2
for x86_64 and the same except ada for i686; those with my usual make -j32.
The Makefile difference in those builds vs. unpatched case
is just an extra empty line.

2024-04-02  Jakub Jelinek  <jakub@redhat.com>

PR bootstrap/106472
* Makefile.tpl (make-postboot-target-dep): New lambda.
Use it to add --enable-bootstrap dependencies of target modules
on other target modules if the latter aren't bootstrapped.
* Makefile.in: Regenerate.

(cherry picked from commit 9a5e4aade2b847c5262577a1490ce6f3df9a9841)

9 days agoDaily bump.
GCC Administrator [Sun, 21 Apr 2024 00:20:22 +0000 (00:20 +0000)] 
Daily bump.

10 days agoDaily bump.
GCC Administrator [Sat, 20 Apr 2024 00:20:28 +0000 (00:20 +0000)] 
Daily bump.

11 days agoipa: Force args obtined through pass-through maps to the expected type (PR 113964)
Martin Jambor [Fri, 19 Apr 2024 14:48:12 +0000 (16:48 +0200)] 
ipa: Force args obtined through pass-through maps to the expected type (PR 113964)

Interactions of IPA-CP and IPA-SRA on the same data is a rather big
source of issues, I'm afraid.  PR 113964 is a situation where IPA-CP
propagates an unsigned short in a union parameter into a function
which itself calls a different function which has a same union
parameter and both these union parameters are split with IPA-SRA.  The
leaf function however uses a signed short member of the union.

In the calling function, we get the unsigned constant as the
replacement for the union and it is then passed in the call without
any type compatibility checks.  Apparently on riscv64 it matters
whether the parameter is signed or unsigned short and so the leaf
function can see different values.

Fixed by using useless_type_conversion_p at the appropriate place and
if it fails, use force_value_to type as elsewhere in similar
situations.

gcc/ChangeLog:

2024-04-04  Martin Jambor  <mjambor@suse.cz>

PR ipa/113964
* ipa-param-manipulation.cc (ipa_param_adjustments::modify_call):
Force values obtined through pass-through maps to the expected
split type.

gcc/testsuite/ChangeLog:

2024-04-04  Patrick O'Neill  <patrick@rivosinc.com>
    Martin Jambor  <mjambor@suse.cz>

PR ipa/113964
* gcc.dg/ipa/pr114247.c: New test.

(cherry picked from commit 8cd0d29270d4ed86c69b80c08de66dcb6c1e22fe)

11 days agoipa: Avoid duplicate replacements in IPA-SRA transformation phase
Martin Jambor [Fri, 19 Apr 2024 14:48:12 +0000 (16:48 +0200)] 
ipa: Avoid duplicate replacements in IPA-SRA transformation phase

When the analysis part of IPA-SRA figures out that it would split out
a scalar part of an aggregate which is known by IPA-CP to contain a
known constant, it skips it knowing that the transformation part looks
at IPA-CP aggregate results too and does the right thing (which can
include doing the propagation in GIMPLE because that is the last
moment the parameter exists).

However, when IPA-SRA wants to split out a smaller aggregate out
of an aggregate, which happens to be of the same size as a known
scalar constant at the same offset, the transformation bit fails to
recognize the situation, tries to do both splitting and constant
propagation and in PR 111571 testcase creates a nonsensical call
statement on which the call redirection then ICEs.

Fixed by making sure we don't try to do two replacements of the same
part of the same parameter.

The look-up among replacements requires these are sorted and this
patch just sorts them if they are not already sorted before each new
look-up.  The worst number of sortings that can happen is number of
parameters which are both split and have aggregate constants times
param_ipa_max_agg_items (default 16).  I don't think complicating the
source code to optimize for this unlikely case is worth it but if need
be, it can of course be done.

gcc/ChangeLog:

2024-03-15  Martin Jambor  <mjambor@suse.cz>

PR ipa/111571
* ipa-param-manipulation.cc
(ipa_param_body_adjustments::common_initialization): Avoid creating
duplicate replacement entries.

gcc/testsuite/ChangeLog:

2024-03-15  Martin Jambor  <mjambor@suse.cz>

PR ipa/111571
* gcc.dg/ipa/pr111571.c: New test.

(cherry picked from commit ca56b43105fc09021ec445f1978a17cd85ae5e0c)

11 days agoDaily bump.
GCC Administrator [Fri, 19 Apr 2024 00:21:09 +0000 (00:21 +0000)] 
Daily bump.

12 days agoDaily bump.
GCC Administrator [Thu, 18 Apr 2024 00:20:54 +0000 (00:20 +0000)] 
Daily bump.

13 days agoAVR: target/114752 - Fix ICE on inline asm const 64-bit float operand
Georg-Johann Lay [Wed, 17 Apr 2024 08:26:05 +0000 (10:26 +0200)] 
AVR: target/114752 - Fix ICE on inline asm const 64-bit float operand

gcc/
PR target/114752
* config/avr/avr.cc (avr_print_operand) [CONST_DOUBLE_P]: Handle DFmode.

(cherry picked from commit 909c6faf2c726178d115726e56304eac91cff6e9)

13 days agoRTEMS: Fix powerpc configuration
Sebastian Huber [Mon, 12 Feb 2024 13:53:21 +0000 (14:53 +0100)] 
RTEMS: Fix powerpc configuration

gcc/ChangeLog:

* config/rs6000/rtems.h (OS_MISSING_POWERPC64): Define.

(cherry picked from commit ce3c743d8cfbadc0aaa80267bc002fd05267ffac)

13 days agoRTEMS: Add multilib configuration for aarch64
Sebastian Huber [Mon, 25 Mar 2024 07:00:02 +0000 (08:00 +0100)] 
RTEMS: Add multilib configuration for aarch64

Add a multilib with workarounds for Cortex-A53 errata.

gcc/ChangeLog:

* config.gcc (aarch64-*-rtems*): Add target makefile fragment
t-aarch64-rtems.
* config/aarch64/t-aarch64-rtems: New file.

(cherry picked from commit ddee4376d15ddde9280c9a6725ddd76bf33f2871)

13 days agoDaily bump.
GCC Administrator [Wed, 17 Apr 2024 00:22:30 +0000 (00:22 +0000)] 
Daily bump.

2 weeks agoDaily bump.
GCC Administrator [Tue, 16 Apr 2024 00:22:23 +0000 (00:22 +0000)] 
Daily bump.

2 weeks agoAVR: Add 8 more avrxmega3 MCUs.
Georg-Johann Lay [Mon, 15 Apr 2024 17:23:32 +0000 (19:23 +0200)] 
AVR: Add 8 more avrxmega3 MCUs.

gcc/
* config/avr/avr-mcus.def: Add: avr16du14, avr16du20, avr16du28,
avr16du32, avr32du14, avr32du20, avr32du28,  avr32du32.
* doc/avr-mmcu.texi: Rebuild.

(cherry picked from commit 6e11bb451babfe47bb6b7ad42335019f2771a32e)

2 weeks agolibstdc++: Update baseline symbols for riscv64-linux
Andreas Schwab [Sun, 31 Dec 2023 09:49:34 +0000 (10:49 +0100)] 
libstdc++: Update baseline symbols for riscv64-linux

* config/abi/post/riscv64-linux-gnu/baseline_symbols.txt: Update.

2 weeks agoc++: compound-requirement partial substitution [PR113966]
Patrick Palka [Mon, 19 Feb 2024 16:34:45 +0000 (11:34 -0500)] 
c++: compound-requirement partial substitution [PR113966]

When partially substituting a requires-expr, we don't want to perform
any additional checks beyond the substitution itself so as to minimize
checking requirements out of order.  So don't check the return-type-req
of a compound-requirement during partial substitution.  And don't check
the noexcept condition either since we can't do that on templated trees.

PR c++/113966

gcc/cp/ChangeLog:

* constraint.cc (tsubst_compound_requirement): Don't check
the noexcept condition or the return-type-requirement when
partially substituting.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-friend17.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 3a6f3354eaaf38b5e6be41e4ebf521d299593a6e)

2 weeks agoc++: requires-exprs and partial constraint subst [PR110006]
Patrick Palka [Sat, 3 Feb 2024 00:07:08 +0000 (19:07 -0500)] 
c++: requires-exprs and partial constraint subst [PR110006]

In r11-3261-gb28b621ac67bee we made tsubst_requires_expr never partially
substitute into a requires-expression so as to avoid checking its
requirements out of order during e.g. generic lambda regeneration.

These PRs however illustrate that we still sometimes do need to
partially substitute into a requires-expression, in particular when it
appears in associated constraints that we're directly substituting for
sake of declaration matching or dguide constraint rewriting.  In these
cases we're being called from tsubst_constraint during which
processing_constraint_expression_p is true, so this patch checks this
predicate to control whether we defer substitution or partially
substitute.

In turn, we now need to propagate semantic tsubst flags through
tsubst_requires_expr rather than just using tf_none, notably for sake of
dguide constraint rewriting which sets tf_dguide.

PR c++/110006
PR c++/112769

gcc/cp/ChangeLog:

* constraint.cc (subst_info::quiet): Accomodate non-diagnostic
tsubst flags.
(tsubst_valid_expression_requirement): Likewise.
(tsubst_simple_requirement): Return a substituted _REQ node when
processing_template_decl.
(tsubst_type_requirement_1): Accomodate non-diagnostic tsubst
flags.
(tsubst_type_requirement): Return a substituted _REQ node when
processing_template_decl.
(tsubst_compound_requirement): Likewise.  Accomodate non-diagnostic
tsubst flags.
(tsubst_nested_requirement): Likewise.
(tsubst_requires_expr): Don't defer partial substitution when
processing_constraint_expression_p is true, in which case return
a substituted REQUIRES_EXPR.
* pt.cc (tsubst_expr) <case REQUIRES_EXPR>: Accomodate
non-diagnostic tsubst flags.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-alias18.C: New test.
* g++.dg/cpp2a/concepts-friend16.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 686b5eb9c9ee623a604dde5c49fa11c23f384c62)

2 weeks agomiddle-end/114599 - fix bitmap allocation for check_ifunc_callee_symtab_nodes
Richard Biener [Sun, 14 Apr 2024 19:57:40 +0000 (12:57 -0700)] 
middle-end/114599 - fix bitmap allocation for check_ifunc_callee_symtab_nodes

There's no default bitmap obstack during global CTORs, so allocate the
bitmap locally.

PR middle-end/114599
PR gcov-profile/114115
* symtab.cc (ifunc_ref_map): Do not use auto_bitmap.
(is_caller_ifunc_resolver): Optimize bitmap_bit_p/bitmap_set_bit
pair.
(symtab_node::check_ifunc_callee_symtab_nodes): Properly
allocate ifunc_ref_map here.

(cherry picked from commit 9ab8fdfeef5b1a47b358e08a98177b2fad65fed9)

2 weeks agotree-profile: Disable indirect call profiling for IFUNC resolvers
H.J. Lu [Sun, 14 Apr 2024 19:57:39 +0000 (12:57 -0700)] 
tree-profile: Disable indirect call profiling for IFUNC resolvers

We can't profile indirect calls to IFUNC resolvers nor their callees as
it requires TLS which hasn't been set up yet when the dynamic linker is
resolving IFUNC symbols.

Add an IFUNC resolver caller marker to cgraph_node and set it if the
function is called by an IFUNC resolver.  Disable indirect call profiling
for IFUNC resolvers and their callees.

Tested with profiledbootstrap on Fedora 39/x86-64.

gcc/ChangeLog:

PR tree-optimization/114115
* cgraph.h (symtab_node): Add check_ifunc_callee_symtab_nodes.
(cgraph_node): Add called_by_ifunc_resolver.
* cgraphunit.cc (symbol_table::compile): Call
symtab_node::check_ifunc_callee_symtab_nodes.
* symtab.cc (check_ifunc_resolver): New.
(ifunc_ref_map): Likewise.
(is_caller_ifunc_resolver): Likewise.
(symtab_node::check_ifunc_callee_symtab_nodes): Likewise.
* tree-profile.cc (gimple_gen_ic_func_profiler): Disable indirect
call profiling for IFUNC resolvers and their callees.

gcc/testsuite/ChangeLog:

PR tree-optimization/114115
* gcc.dg/pr114115.c: New test.

(cherry picked from commit cab32bacaea268ec062b1fb4fc662d90c9d1cfce)

2 weeks agoAArch64: remove ls64 from being mandatory on armv8.7-a..
Tamar Christina [Mon, 15 Apr 2024 11:12:30 +0000 (12:12 +0100)] 
AArch64: remove ls64 from being mandatory on armv8.7-a..

The Arm Architectural Reference Manual (Version J.a, section A2.9 on FEAT_LS64)
shows that ls64 is an optional extensions and should not be enabled by default
for Armv8.7-a.

This drops it from the mandatory bits for the architecture and brings GCC inline
with LLVM and the achitecture.

Note that we will not be changing binutils to preserve compatibility with older
released compilers.

gcc/ChangeLog:

* config/aarch64/aarch64-arches.def (AARCH64_ARCH): Remove LS64 from
Armv8.7-a.

gcc/testsuite/ChangeLog:

* g++.target/aarch64/acle/ls64.C: Add +ls64.
* g++.target/aarch64/acle/ls64_lto.C: Likewise.
* gcc.target/aarch64/acle/ls64_lto.c: Likewise.
* gcc.target/aarch64/acle/pr110100.c: Likewise.
* gcc.target/aarch64/acle/pr110132.c: Likewise.
* gcc.target/aarch64/pragma_cpp_predefs_2.c: Correct header checks.

2 weeks agoAArch64: Do not allow SIMD clones with simdlen 1 [PR113552]
Tamar Christina [Mon, 15 Apr 2024 11:11:48 +0000 (12:11 +0100)] 
AArch64: Do not allow SIMD clones with simdlen 1 [PR113552]

This is a backport of g:306713c953d509720dc394c43c0890548bb0ae07.

The AArch64 vector PCS does not allow simd calls with simdlen 1,
however due to a bug we currently do allow it for num == 0.

This causes us to emit a symbol that doesn't exist and we fail to link.

gcc/ChangeLog:

PR tree-optimization/113552
* config/aarch64/aarch64.cc
(aarch64_simd_clone_compute_vecsize_and_simdlen): Block simdlen 1.

gcc/testsuite/ChangeLog:

PR tree-optimization/113552
* gcc.target/aarch64/pr113552.c: New test.
* gcc.target/aarch64/simd_pcs_attribute-3.c: Remove bogus check.

2 weeks agoDaily bump.
GCC Administrator [Mon, 15 Apr 2024 00:21:31 +0000 (00:21 +0000)] 
Daily bump.

2 weeks agoDaily bump.
GCC Administrator [Sun, 14 Apr 2024 00:22:20 +0000 (00:22 +0000)] 
Daily bump.

2 weeks agoDaily bump.
GCC Administrator [Sat, 13 Apr 2024 00:21:39 +0000 (00:21 +0000)] 
Daily bump.

2 weeks agoDaily bump.
GCC Administrator [Fri, 12 Apr 2024 00:21:35 +0000 (00:21 +0000)] 
Daily bump.

2 weeks agolibstdc++: Regenerate baseline_symbols.txt files for Linux
Jakub Jelinek [Thu, 11 Apr 2024 13:55:53 +0000 (15:55 +0200)] 
libstdc++: Regenerate baseline_symbols.txt files for Linux

The following patch regenerates the ABI files for 13 branch (I've only changed
the Linux files which were updated in r13-7289, all but m68k, riscv64 and
powerpc64 are from actual Fedora 39 gcc builds, the rest hand edited).
We've added one symbol very early in the 13.2 cycle, but then added 2
further ones very soon afterwards, quite a long time before 13.2 release
and haven't regenerated.  The patch applies cleanly to trunk as well.

2024-04-11  Jakub Jelinek  <jakub@redhat.com>

* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt: Update.
* config/abi/post/i486-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/m68k-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/aarch64-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/s390x-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/riscv64-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/powerpc64le-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt: Update.

(cherry picked from commit 508b2b9df12b1049a0850e3a29193b1277dcd817)

2 weeks agoRISC-V: Fix __atomic_compare_exchange with 32 bit value on RV64
Kito Cheng [Wed, 28 Feb 2024 08:01:52 +0000 (16:01 +0800)] 
RISC-V: Fix __atomic_compare_exchange with 32 bit value on RV64

atomic_compare_and_swapsi will use lr.w to do obtain the original value,
which sign extends to DI.  RV64 only has DI comparisons, so we also need
to sign extend the expected value to DI as otherwise the comparison will
fail when the expected value has the 32nd bit set.

gcc/ChangeLog:

PR target/114130
* config/riscv/sync.md (atomic_compare_and_swap<mode>): Sign
extend the expected value if needed.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr114130.c: New.

Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
(cherry picked from commit fd07a29e39f5347d6cef3e7042a32306f97a1719)

2 weeks agoDaily bump.
GCC Administrator [Thu, 11 Apr 2024 00:21:22 +0000 (00:21 +0000)] 
Daily bump.

2 weeks agoDaily bump.
GCC Administrator [Wed, 10 Apr 2024 00:21:05 +0000 (00:21 +0000)] 
Daily bump.

3 weeks agoDaily bump.
GCC Administrator [Tue, 9 Apr 2024 00:21:53 +0000 (00:21 +0000)] 
Daily bump.

3 weeks agoipa: Self-DCE of uses of removed call LHSs (PR 108007)
Martin Jambor [Mon, 8 Apr 2024 15:34:33 +0000 (17:34 +0200)] 
ipa: Self-DCE of uses of removed call LHSs (PR 108007)

PR 108007 is another manifestation where we rely on DCE to clean-up
after IPA-SRA and if the user explicitely switches DCE off, IPA-SRA
can leave behind statements which are fed uninitialized values and
trap, even though their results are themselves never used.

I have already fixed this for unused parameters in callees, this bug
shows that almost the same thing can happen for removed returns, on
the side of callers.  This means that the issue has to be fixed
elsewhere, in call redirection.  This patch adds a function which
looks for (and through, using a work-list) uses of operations fed
specific SSA names and removes them all.

That would have been easy if it wasn't for debug statements during
tree-inline (from which call redirection is also invoked).  Debug
statements are decoupled from the rest at this point and iterating
over uses of SSAs does not bring them up.  During tree-inline they are
handled especially at the end, I assume in order to make sure that
relative ordering of UIDs are the same with and without debug info.

This means that during tree-inline we need to make a hash of killed
SSAs, that we already have in copy_body_data, available to the
function making the purging.  So the patch duly does also that, making
the interface slightly ugly.  Moreover, all newly unused SSA names
need to be freed and as PR 112616 showed, it must be done in a defined
order, which is what newly added ipa_release_ssas_in_hash does.

This backport to gcc-13 also contains
54e505d0446f86b7ad383acbb8e5501f20872b64 in order not to reintroduce
PR 113757.

gcc/ChangeLog:

2024-04-05  Martin Jambor  <mjambor@suse.cz>

PR ipa/108007
PR ipa/112616
* cgraph.h (cgraph_edge): Add a parameter to
redirect_call_stmt_to_callee.
* ipa-param-manipulation.h (ipa_param_adjustments): Add a
parameter to modify_call.
(ipa_release_ssas_in_hash): Declare.
* cgraph.cc (cgraph_edge::redirect_call_stmt_to_callee): New
parameter killed_ssas, pass it to padjs->modify_call.
* ipa-param-manipulation.cc (purge_all_uses): New function.
(ipa_param_adjustments::modify_call): New parameter killed_ssas.
Instead of substituting uses, invoke purge_all_uses.  If
hash of killed SSAs has not been provided, create a temporary one
and release SSAs that have been added to it.
(compare_ssa_versions): New function.
(ipa_release_ssas_in_hash): Likewise.
* tree-inline.cc (redirect_all_calls): Create
id->killed_new_ssa_names earlier, pass it to edge redirection,
adjust a comment.
(copy_body): Release SSAs in id->killed_new_ssa_names.

gcc/testsuite/ChangeLog:

2024-01-15  Martin Jambor  <mjambor@suse.cz>

PR ipa/108007
PR ipa/112616
* gcc.dg/ipa/pr108007.c: New test.
* gcc.dg/ipa/pr112616.c: Likewise.

(cherry picked from commit a9a8426e534760b8d3a250e9bd3cff4db131a2be)

3 weeks agoDaily bump.
GCC Administrator [Mon, 8 Apr 2024 12:19:26 +0000 (12:19 +0000)] 
Daily bump.

3 weeks agoFortran: fix DATA and derived types with pointer components [PR114474]
Harald Anlauf [Wed, 27 Mar 2024 20:18:04 +0000 (21:18 +0100)] 
Fortran: fix DATA and derived types with pointer components [PR114474]

When matching actual arguments in match_actual_arg, these are initially
treated as a possible dummy procedure, assuming that the correct type is
determined later.  This resolution could fail when the procedure is a
derived type constructor with a pointer component and appears in a DATA
statement, where the pointer shall be associated with an initial data
target.  Check for those cases where the type obviously has not been
resolved yet, and which were missed because there was no component
reference.

gcc/fortran/ChangeLog:

PR fortran/114474
* primary.cc (gfc_variable_attr): Catch variables used in structure
constructors within DATA statements that are still tagged with a
temporary type BT_PROCEDURE from match_actual_arg and which have the
target attribute, and fix their typespec.

gcc/testsuite/ChangeLog:

PR fortran/114474
* gfortran.dg/data_pointer_3.f90: New test.

(cherry picked from commit bbb7c513dddc5c9b2d5e9b78bc1c2f85a0cfe07e)

3 weeks agojit, Darwin: Implement library exports list.
Iain Sandoe [Sat, 13 Jan 2024 17:20:47 +0000 (17:20 +0000)] 
jit, Darwin: Implement library exports list.

Currently, we have no exports list for libgccjit, which means that
all symbols are exported, including those from libstdc++ which is
linked statically into the lib.  This causes failures when the
shared libstdc++ is used but some c++ symbols are satisfied from
libgccjit.

This implements an export file for Darwin (which is currently
manually created by cross-checking libgccjit.map).  Ideally we'd
script this, at some point.  Update libtool current and age to
reflect the current ABI version (we are not bumping the SO name
at this stage).

This fixes a number of new failures in jit testing.

gcc/jit/ChangeLog:

* Make-lang.in: Implement exports list, and use a shared
libgcc.
* libgccjit.exports: New file.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit b120e355e59142bd15d6b010461d07236288d843)

3 weeks agolibphobos, Darwin: Enable libphobos for most Darwin.
Iain Sandoe [Mon, 1 Apr 2024 12:58:20 +0000 (13:58 +0100)] 
libphobos, Darwin: Enable libphobos for most Darwin.

Earlier Darwin systems can be made to work too - but they need non-
standard 'binutils', so for now these must be enabled specifically.

libphobos/ChangeLog:

* configure.tgt: Enable libphobos for Darwin >= 12.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
3 weeks agotestsuite: Remove duplicate -lgcov [PR114034]
Iain Sandoe [Sun, 31 Mar 2024 10:22:58 +0000 (11:22 +0100)] 
testsuite: Remove duplicate -lgcov [PR114034]

Duplicate library entries now cause linker warnings with newer linker
versions on Darwin which leads to these tests regressing.  The library
is already added by the test flags so there is no need to put an extra
one in the options.

PR testsuite/114034

gcc/testsuite/ChangeLog:

* g++.dg/gcov/gcov-dump-1.C: Remove extra -lgcov.
* g++.dg/gcov/gcov-dump-2.C: Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 799a056cf804f433ce0050a5a6bf900f7a01ecb1)

3 weeks agoDaily bump.
GCC Administrator [Fri, 5 Apr 2024 00:20:32 +0000 (00:20 +0000)] 
Daily bump.

3 weeks agoDarwin,debug : Switch to DWARF 3 or 4 when dsymutil supports it.
Iain Sandoe [Sun, 17 Sep 2023 14:56:07 +0000 (15:56 +0100)] 
Darwin,debug : Switch to DWARF 3 or 4 when dsymutil supports it.

The main reason that Darwin has been using DWARF2 only as debug is that
earlier debug linkers (dsymutil) did not support any extensions to this
so that the default "non-strict" mode used in GCC would cause tool errors.

There are two sources for dsymutil, those based off a closed source base
"dwarfutils" and those based off LLVM.

For dsymutil versions based off LLVM-7+ we can use up to DWARF-4, and for
versions based on dwarfutils 121+ we can use DWARF-3.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:

* config/darwin-protos.h (enum darwin_external_toolchain): New.
* config/darwin.cc (DSYMUTIL_VERSION): New.
(darwin_override_options): Choose the default debug DWARF version
depending on the configured dsymutil version.

(cherry picked from commit 47346acb72b50d178dae72393c851d57beec383f)

3 weeks agotestsuite, Darwin: Allow for an undefined symbol [PR114036].
Iain Sandoe [Sun, 31 Mar 2024 10:27:53 +0000 (11:27 +0100)] 
testsuite, Darwin: Allow for an undefined symbol [PR114036].

Darwin's linker defaults to requiring all symbols to be defined at
static link time (unless specifically noted or dynamic lookuo is
enabled).

For this test, we just need to note that the symbol is expected to
be undefined.

PR testsuite/114036

gcc/testsuite/ChangeLog:

* gcc.misc-tests/gcov-14.c: Allow for 'Foo' to be undefined
on Darwin link lines.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit ad8e34eaa870608e2b07b4e7147e6ef2944bb8b5)

3 weeks agoDarwin: Do not emit .macinfo when dsymutil cannot consume it.
Iain Sandoe [Sun, 31 Mar 2024 22:25:31 +0000 (23:25 +0100)] 
Darwin: Do not emit .macinfo when dsymutil cannot consume it.

Some verions of dsymutil do not ignore .macinfo sections, but instead
ignore the entire debug in the file.

To avoid this total loss of debug, when we detect that the debug level
is g3 and the dsymutil version cannot support it, we reduce the level
to g2 and issue a note.

This behaviour can be overidden by -gstrict-dwarf (although the objects
will contain macinfo; dsymutil will not produce a .dSYM with it).

gcc/ChangeLog:

* config/darwin.cc (darwin_override_options): Reduce the debug
level to 2 if dsymutil cannot handle .macinfo sections.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 3c499f8f6f7d19b21d7047efabbe6396ee1c2cac)

3 weeks agotestsuite, Darwin: Use the IOKit framework in framework-1.c [PR114049].
Iain Sandoe [Mon, 18 Mar 2024 10:06:44 +0000 (10:06 +0000)] 
testsuite, Darwin: Use the IOKit framework in framework-1.c [PR114049].

The intent of the test is to show that we find a framework that
is installed in /System/Library/Frameworks when the user has added
a '-F' option.  The trick is to choose some header that is present
for all the Darwin versions we support and that does not contain any
content we cannot parse.  We had been using the Kernel framework for
this, but recent SDK versions have revealed that this is not suitable.

Replacing with a use of IOKit.

PR target/114049

gcc/testsuite/ChangeLog:

* gcc.dg/framework-1.c: Use an IOKit header instead of a
Kernel one.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 4adb1a5839e7a3310a127c1776f1f95d7edaa6ff)

3 weeks agoTestsuite, Darwin: skip PIE test
Francois-Xavier Coudert [Mon, 30 Oct 2023 11:41:17 +0000 (12:41 +0100)] 
Testsuite, Darwin: skip PIE test

gcc/testsuite/ChangeLog:

* gcc.dg/pie-2.c: Skip test on darwin.

(cherry picked from commit a0c557690c8d5327deda6e21f8d1deca8451a4cb)

3 weeks agoTestsuite, DWARF2: adjust regexp to match darwin output
Francois-Xavier Coudert [Sun, 20 Aug 2023 10:53:19 +0000 (12:53 +0200)] 
Testsuite, DWARF2: adjust regexp to match darwin output

gcc/testsuite/ChangeLog:

* gcc.dg/debug/dwarf2/inline4.c: Ajdust regexp to match darwin
output.

(cherry picked from commit 94e68ce96c285e479736851f1ad8cc87c8c3ff0c)

3 weeks agoTestsuite, LTO: silence warning to make test pass on Darwin
Francois-Xavier Coudert [Sun, 20 Aug 2023 10:17:50 +0000 (12:17 +0200)] 
Testsuite, LTO: silence warning to make test pass on Darwin

gcc/testsuite/ChangeLog:

* gcc.dg/lto/20091013-1_2.c: Add -Wno-stringop-overread.

(cherry picked from commit b9426543e8d3b9333d1561844472c3f568fa6913)

3 weeks agotestsuite, x86: Handle a broken assembler
Iain Sandoe [Sun, 29 Oct 2023 07:19:53 +0000 (07:19 +0000)] 
testsuite, x86: Handle a broken assembler

Earlier assembler support for complex fp16 on x86_64 Darwin is broken.
This adds an additional test to the existing target-supports that fails
for the broken assemblers but works for the newer, fixed, ones.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp: Test an asm line that fails on broken
Darwin assembler versions.

(cherry picked from commit d65eb8a6bbeae7533dd41cb307b427f3f8585d9b)

3 weeks agoRISC-V: Fix C23 (...) functions returning large aggregates [PR114175]
Edwin Lu [Mon, 18 Mar 2024 18:43:41 +0000 (11:43 -0700)] 
RISC-V: Fix C23 (...) functions returning large aggregates [PR114175]

We assume that TYPE_NO_NAMED_ARGS_STDARG_P don't have any named arguments and
there is nothing to advance, but that is not the case for (...) functions
returning by hidden reference which have one such artificial argument.
This causes gcc.dg/c23-stdarg-[68].c to fail

Fix the issue by checking if arg.type is NULL as r14-9503-g218d1749612
explains

Tested on linux rv64gcv.

gcc/ChangeLog:

PR target/114175
* config/riscv/riscv.cc (riscv_setup_incoming_varargs): Only skip
riscv_funciton_arg_advance for TYPE_NO_NAMED_ARGS_STDARG_P functions
if arg.type is NULL

(cherry picked from commit 60586710b0646efdbbd77a7f53b93fb5edb87a61)

3 weeks agoDaily bump.
GCC Administrator [Thu, 4 Apr 2024 00:21:12 +0000 (00:21 +0000)] 
Daily bump.

3 weeks agolibstdc++, Darwin: Handle a linker warning [PR112397].
Iain Sandoe [Thu, 8 Feb 2024 17:54:31 +0000 (17:54 +0000)] 
libstdc++, Darwin: Handle a linker warning [PR112397].

Darwin's linker warns when we make a direct branch to code that is
in a weak definition (citing that if a different implementation of
the weak function is chosen by the dynamic linker this would be an
error).

As the analysis in the PR shows, this can happen when we have hot/
cold partitioning and there is an error path that is primarily cold
but makes use of epilogue code in the hot section.  In this simple
case, we can easily deduce that the code is in fact safe; however
that is not something we can realistically implement in the linker.

Since the user-replaceable allocators are implemented using weak
definitions, this is a warning that is frequently flagged up in both
the testsuite and end-user code.

The chosen solution here is to suppress the hot/cold partitioning for
these cases (it is unlikely to impact performance much c.f. the
actual allocation).

PR target/112397

libstdc++-v3/ChangeLog:

* configure: Regenerate.
* configure.ac: Detect if we are building for Darwin.
* libsupc++/Makefile.am: If we are building for Darwin, then
suppress hot/cold partitioning for the array allocators.
* libsupc++/Makefile.in: Regenerated.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 1609fdff16f17ead37666f6d0e801800ee3d04d2)

3 weeks agolibstdc++: Sync the atomic_link_flags implementation with GCC.
Iain Sandoe [Mon, 18 Mar 2024 09:57:33 +0000 (09:57 +0000)] 
libstdc++: Sync the atomic_link_flags implementation with GCC.

For Darwin, in order to allow uninstalled testing, we need to provide
a '-B' option pointing to each path containing an uninstalled library
that we are using (these get appended to the embedded runpaths).

This updates the version of the atomic_link_flags proc in the libstdc++
testsuite to do the same as the one in the GCC testsuite.

libstdc++-v3/ChangeLog:

* testsuite/lib/dg-options.exp (atomic_link_flags): Emit a -B
option for the path to the uninstalled libatomic.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 71a44faa8a4f76d68356c66c6054e6c242df820f)

3 weeks agolibstdc++, Darwin: Do not use dev/null as the file for executables.
Iain Sandoe [Tue, 19 Mar 2024 10:40:50 +0000 (10:40 +0000)] 
libstdc++, Darwin: Do not use dev/null as the file for executables.

Darwin has a separate debug linker, which is invoked when the command
line contains source files and debug is enabled.

Using /dev/null as the executable name does not, therefore, work when
debug is enabled, since the debug linker does not accept /dev/null as
a valid executable name.

The leads to incorrectly UNSUPPORTED testcases because of the unintended
error result from the test compilation.

The solution here is to use a temporary file that is deleted at the
end of the test (which is the mechanism used elsewhere)

libstdc++-v3/ChangeLog:

* testsuite/lib/libstdc++.exp (v3_target_compile): Instead of
/dev/null, use a temporary file for test executables on Darwin.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit e47330d0742c985fd8d5fe7089aa381d34967d61)

3 weeks agoTestsuite, i386: Mark test as requiring ifunc
Francois-Xavier Coudert [Mon, 30 Oct 2023 14:41:10 +0000 (15:41 +0100)] 
Testsuite, i386: Mark test as requiring ifunc

Test is currently failing on x86_64-apple-darwin.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr105554.c: Require ifunc.

(cherry picked from commit 7666d94db0684f04264712f3e3fdb542518960c5)

3 weeks agoTestsuite: restrict test to nonpic targets
Francois-Xavier Coudert [Mon, 11 Dec 2023 08:26:23 +0000 (09:26 +0100)] 
Testsuite: restrict test to nonpic targets

The test is currently failing on x86_64-apple-darwin.

gcc/testsuite/ChangeLog:

PR testsuite/112297
* gcc.target/i386/pr100936.c: Require nonpic target.

(cherry picked from commit 02f562484c17522d79a482ac702a5fa3c2dfdd10)

3 weeks agolibcc1: fix <vector> include
Francois-Xavier Coudert [Sat, 16 Mar 2024 08:50:00 +0000 (09:50 +0100)] 
libcc1: fix <vector> include

Use INCLUDE_VECTOR before including system.h, instead of directly
including <vector>, to avoid running into poisoned identifiers.

Signed-off-by: Dimitry Andric <dimitry@andric.com>
PR middle-end/111632

libcc1/ChangeLog:

* libcc1plugin.cc: Fix include.
* libcp1plugin.cc: Fix include.

(cherry picked from commit 5213047b1d50af63dfabb5e5649821a6cb157e33)

3 weeks agoInclude safe-ctype.h after C++ standard headers, to avoid over-poisoning
Francois-Xavier Coudert [Thu, 7 Mar 2024 13:36:03 +0000 (14:36 +0100)] 
Include safe-ctype.h after C++ standard headers, to avoid over-poisoning

When building gcc's C++ sources against recent libc++, the poisoning of
the ctype macros due to including safe-ctype.h before including C++
standard headers such as <list>, <map>, etc, causes many compilation
errors, similar to:

  In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23:
  In file included from /home/dim/src/gcc/master/gcc/system.h:233:
  In file included from /usr/include/c++/v1/vector:321:
  In file included from
  /usr/include/c++/v1/__format/formatter_bool.h:20:
  In file included from
  /usr/include/c++/v1/__format/formatter_integral.h:32:
  In file included from /usr/include/c++/v1/locale:202:
  /usr/include/c++/v1/__locale:546:5: error: '__abi_tag__' attribute
  only applies to structs, variables, functions, and namespaces
    546 |     _LIBCPP_INLINE_VISIBILITY
        |     ^
  /usr/include/c++/v1/__config:813:37: note: expanded from macro
  '_LIBCPP_INLINE_VISIBILITY'
    813 | #  define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
        |                                     ^
  /usr/include/c++/v1/__config:792:26: note: expanded from macro
  '_LIBCPP_HIDE_FROM_ABI'
    792 |
    __attribute__((__abi_tag__(_LIBCPP_TOSTRING(
  _LIBCPP_VERSIONED_IDENTIFIER))))
        |                          ^
  In file included from /home/dim/src/gcc/master/gcc/gensupport.cc:23:
  In file included from /home/dim/src/gcc/master/gcc/system.h:233:
  In file included from /usr/include/c++/v1/vector:321:
  In file included from
  /usr/include/c++/v1/__format/formatter_bool.h:20:
  In file included from
  /usr/include/c++/v1/__format/formatter_integral.h:32:
  In file included from /usr/include/c++/v1/locale:202:
  /usr/include/c++/v1/__locale:547:37: error: expected ';' at end of
  declaration list
    547 |     char_type toupper(char_type __c) const
        |                                     ^
  /usr/include/c++/v1/__locale:553:48: error: too many arguments
  provided to function-like macro invocation
    553 |     const char_type* toupper(char_type* __low, const
    char_type* __high) const
        |                                                ^
  /home/dim/src/gcc/master/gcc/../include/safe-ctype.h:146:9: note:
  macro 'toupper' defined here
    146 | #define toupper(c) do_not_use_toupper_with_safe_ctype
        |         ^

This is because libc++ uses different transitive includes than
libstdc++, and some of those transitive includes pull in various ctype
declarations (typically via <locale>).

There was already a special case for including <string> before
safe-ctype.h, so move the rest of the C++ standard header includes to
the same location, to fix the problem.

PR middle-end/111632

gcc/ChangeLog:

* system.h: Include safe-ctype.h after C++ standard headers.

Signed-off-by: Dimitry Andric <dimitry@andric.com>
(cherry picked from commit 9970b576b7e4ae337af1268395ff221348c4b34a)

3 weeks agolibstdc++: Destroy allocators in re-inserted container nodes [PR114401]
Jonathan Wakely [Thu, 21 Mar 2024 13:25:15 +0000 (13:25 +0000)] 
libstdc++: Destroy allocators in re-inserted container nodes [PR114401]

The allocator objects in container node handles were not being destroyed
after the node was re-inserted into a container. They are stored in a
union and so need to be explicitly destroyed when the node becomes
empty. The containers were zeroing the node handle's pointer, which
makes it empty, causing the handle's destructor to think there's nothing
to clean up.

Add a new member function to the node handle which destroys the
allocator and zeros the pointer. Change the containers to call that
instead of just changing the pointer manually.

We can also remove the _M_empty member of the union which is not
necessary.

libstdc++-v3/ChangeLog:

PR libstdc++/114401
* include/bits/hashtable.h (_Hashtable::_M_reinsert_node): Call
release() on node handle instead of just zeroing its pointer.
(_Hashtable::_M_reinsert_node_multi): Likewise.
(_Hashtable::_M_merge_unique): Likewise.
(_Hashtable::_M_merge_multi): Likewise.
* include/bits/node_handle.h (_Node_handle_common::release()):
New member function.
(_Node_handle_common::_Optional_alloc::_M_empty): Remove
unnecessary union member.
(_Node_handle_common): Declare _Hashtable as a friend.
* include/bits/stl_tree.h (_Rb_tree::_M_reinsert_node_unique):
Call release() on node handle instead of just zeroing its
pointer.
(_Rb_tree::_M_reinsert_node_equal): Likewise.
(_Rb_tree::_M_reinsert_node_hint_unique): Likewise.
(_Rb_tree::_M_reinsert_node_hint_equal): Likewise.
* testsuite/23_containers/multiset/modifiers/114401.cc: New test.
* testsuite/23_containers/set/modifiers/114401.cc: New test.
* testsuite/23_containers/unordered_multiset/modifiers/114401.cc: New test.
* testsuite/23_containers/unordered_set/modifiers/114401.cc: New test.

(cherry picked from commit c2e28df90a1640cebadef6c6c8ab5ea964071bb1)

3 weeks agolibstdc++: Constrain std::vector default constructor [PR113841]
Jonathan Wakely [Fri, 9 Feb 2024 17:06:20 +0000 (17:06 +0000)] 
libstdc++: Constrain std::vector default constructor [PR113841]

This is needed to avoid errors outside the immediate context when
evaluating is_default_constructible_v<vector<T, A>> when A is not
default constructible.

To avoid diagnostic regressions for 23_containers/vector/48101_neg.cc we
need to make the std::allocator<cv T> partial specializations default
constructible, which they probably should have been anyway.

libstdc++-v3/ChangeLog:

PR libstdc++/113841
* include/bits/allocator.h (allocator<cv T>): Add default
constructor to partial specializations for cv-qualified types.
* include/bits/stl_vector.h (_Vector_impl::_Vector_impl()):
Constrain so that it's only present if the allocator is default
constructible.
* include/bits/stl_bvector.h (_Bvector_impl::_Bvector_impl()):
Likewise.
* testsuite/23_containers/vector/cons/113841.cc: New test.

(cherry picked from commit 142cc4c223d695e515ed2504501b91d8a7ac6eb8)

3 weeks agolibstdc++: Begin lifetime of storage in std::vector<bool> [PR114367]
Jonathan Wakely [Mon, 18 Mar 2024 13:00:17 +0000 (13:00 +0000)] 
libstdc++: Begin lifetime of storage in std::vector<bool> [PR114367]

This doesn't cause a problem with GCC, but Clang correctly diagnoses a
bug in the code. The objects in the allocated storage need to begin
their lifetime before we start using them.

This change uses the allocator's construct function instead of using
std::construct_at directly, in order to support fancy pointers.

libstdc++-v3/ChangeLog:

PR libstdc++/114367
* include/bits/stl_bvector.h (_M_allocate): Use allocator's
construct function to begin lifetime of words.

(cherry picked from commit 16afbd9c9c4282d56062cef95e6eccfdcf3efe03)

3 weeks agoDaily bump.
GCC Administrator [Wed, 3 Apr 2024 00:21:21 +0000 (00:21 +0000)] 
Daily bump.

3 weeks agotestsuite, Darwin: Skip g++.dg/debug/dwarf2/pr85550.C
Iain Sandoe [Sun, 1 Oct 2023 19:38:44 +0000 (20:38 +0100)] 
testsuite, Darwin: Skip g++.dg/debug/dwarf2/pr85550.C

There are two problems here; first that the emitted asm for
-fdebug-types-section is ELF-specfic leading to assembler errors for
Mach-O.  If we fix this, we get a secondary fail since the debug linker
does not recognise DW_FORM_ref_sig8.  Disable ths test until we get
DWARF-5 support in the external Darwin toolchain components.

gcc/testsuite/ChangeLog:

* g++.dg/debug/dwarf2/pr85550.C: Skip for Darwin.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
(cherry picked from commit 76547f4c97b1c0744487d624c5e2e5a15d0370a9)

3 weeks agotestsuite: adjust for darwin linker warning
Francois-Xavier Coudert [Fri, 8 Sep 2023 19:55:56 +0000 (21:55 +0200)] 
testsuite: adjust for darwin linker warning

On recent macOS versions, no_pie is deprecated and the linker complains
about it: "-no_pie is deprecated when targeting new OS versions"

gcc/testsuite/ChangeLog:

* gcc.dg/darwin-segaddr.c: Adjust for darwin linker warning.
* gcc.dg/pie-7.c: Likewise.

(cherry picked from commit d9926c0d974646dc6024d5a881fe1bee2f499139)