]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
5 months agoLoongArch: Fix the issue of function jump out of range caused by crtbeginS.o [PR118844].
Lulu Cheng [Wed, 12 Feb 2025 06:29:58 +0000 (14:29 +0800)] 
LoongArch: Fix the issue of function jump out of range caused by crtbeginS.o [PR118844].

Due to the presence of R_LARCH_B26 in
/usr/lib/gcc/loongarch64-linux-gnu/14/crtbeginS.o, its addressing
range is [PC-128MiB, PC+128MiB-4]. This means that when the code
segment size exceeds 128MB, linking with lld will definitely fail
(ld will not fail because the order of the two is different).

The linking order:
  lld: crtbeginS.o + .text + .plt
  ld : .plt + crtbeginS.o + .text

To solve this issue, add '-mcmodel=extreme' when compiling crtbeginS.o.

PR target/118844

libgcc/ChangeLog:

* config/loongarch/t-crtstuff: Add '-mcmodel=extreme'
to CRTSTUFF_T_CFLAGS_S.

(cherry picked from commit ae14d7d04da8c6cb542269722638071f999f94d8)

5 months agoDaily bump.
GCC Administrator [Thu, 20 Feb 2025 00:21:46 +0000 (00:21 +0000)] 
Daily bump.

5 months agoDaily bump.
GCC Administrator [Wed, 19 Feb 2025 00:22:07 +0000 (00:22 +0000)] 
Daily bump.

5 months agoDaily bump.
GCC Administrator [Tue, 18 Feb 2025 00:22:39 +0000 (00:22 +0000)] 
Daily bump.

5 months agoFreeBSD: Stop linking _p libs for -pg as of FreeBSD 14
Andreas Tobler [Sun, 9 Jun 2024 21:18:04 +0000 (23:18 +0200)] 
FreeBSD: Stop linking _p libs for -pg as of FreeBSD 14

As of FreeBSD version 14, FreeBSD no longer provides profiled system
libraries like libc_p and libpthread_p. Stop linking against them if
the FreeBSD major version is 14 or more.

gcc:
* config/freebsd-spec.h: Change fbsd-lib-spec for FreeBSD > 13,
do not link against profiled system libraries if -pg is invoked.
Add a define to note about this change.
* config/aarch64/aarch64-freebsd.h: Use the note to inform if
-pg is invoked on FreeBSD > 13.
* config/arm/freebsd.h: Likewise.
* config/i386/freebsd.h: Likewise.
* config/i386/freebsd64.h: Likewise.
* config/riscv/freebsd.h: Likewise.
* config/rs6000/freebsd64.h: Likewise.
* config/rs6000/sysv4.h: Likeise.

5 months agoLoongArch: When -mfpu=none, '__loongarch_frecipe' shouldn't be defined [PR118843].
Lulu Cheng [Wed, 12 Feb 2025 03:50:50 +0000 (11:50 +0800)] 
LoongArch: When -mfpu=none, '__loongarch_frecipe' shouldn't be defined [PR118843].

PR target/118843

gcc/ChangeLog:

* config/loongarch/loongarch-c.cc
(loongarch_update_cpp_builtins): Fix macro definition issues.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/pr118843.c: New test.

(cherry picked from commit ee579b7c257468b9032ab4583ec455fa871d4428)

5 months agoi386: Deprecate -m[no-]avx10.1 and make -mno-avx10.1-512 to disable the whole AVX10.1
Haochen Jiang [Tue, 11 Feb 2025 03:29:34 +0000 (11:29 +0800)] 
i386: Deprecate -m[no-]avx10.1 and make -mno-avx10.1-512 to disable the whole AVX10.1

Based on the feedback we got, we would like to re-alias avx10.x to 512
bit in the future. This leaves the current avx10.1 alias to 256 bit
inconsistent. Since it has been there for GCC 14.1 and GCC 14.2,
we decide to deprecate avx10.1 alias. The current proposal is not
adding it back in the future, but it might change if necessary.

For -mno- options, it is confusing what it is disabling when it comes
to avx10. Since there is barely usage enabling AVX10 with 512 bit
then disabling it, we will only provide -mno-avx10.x options in the
future, disabling the whole AVX10.x. If someone really wants to disable
512 bit after enabling it, -mavx10.x-512 -mno-avx10.x -mavx10.x-256 is
the only way to do that since we also do not want to break the usual
expression on -m- options enabling everything mentioned.

However, for avx10.1, since we deprecated avx10.1, there is no reason
we should have -mno-avx10.1. Thus, we need to keep -mno-avx10.1-[256,512].
To avoid confusion, we will make -mno-avx10.1-512 to disable the
whole AVX10.1 set to match the future -mno-avx10.x.

gcc/ChangeLog:

* common/config/i386/i386-common.cc
(OPTION_MASK_ISA2_AVX2_UNSET): Change AVX10.1 unset macro.
(OPTION_MASK_ISA2_AVX10_1_256_UNSET): Removed.
(OPTION_MASK_ISA2_AVX10_1_512_UNSET): Removed.
(OPTION_MASK_ISA2_AVX10_1_UNSET): New.
(ix86_handle_option): Adjust AVX10.1 unset macro.
* common/config/i386/i386-isas.h: Remove avx10.1.
* config/i386/i386-options.cc
(ix86_valid_target_attribute_inner_p): Ditto.
(ix86_option_override_internal): Adjust warning message.
* config/i386/i386.opt: Remove mavx10.1.
* config/i386/i386.opt.urls: Regenerated.
* doc/extend.texi: Remove avx10.1 and adjust doc.
* doc/sourcebuild.texi: Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx10_1-1.c: Change to avx10.1-256.
* gcc.target/i386/avx10_1-13.c: Ditto.
* gcc.target/i386/avx10_1-14.c: Ditto.
* gcc.target/i386/avx10_1-21.c: Ditto.
* gcc.target/i386/avx10_1-22.c: Ditto.
* gcc.target/i386/avx10_1-23.c: Ditto.
* gcc.target/i386/avx10_1-24.c: Ditto.
* gcc.target/i386/avx10_1-3.c: Ditto.
* gcc.target/i386/avx10_1-5.c: Ditto.
* gcc.target/i386/avx10_1-6.c: Ditto.
* gcc.target/i386/avx10_1-8.c: Ditto.
* gcc.target/i386/avx10_1-12.c: Adjust warning message.
* gcc.target/i386/avx10_1-19.c: Ditto.
* gcc.target/i386/avx10_1-17.c: Adjust to no-avx10.1-512.

5 months agoi386: Do not check vector size conflict when AVX512 is not explicitly set [PR 118815]
Haochen Jiang [Mon, 10 Feb 2025 08:53:27 +0000 (16:53 +0800)] 
i386: Do not check vector size conflict when AVX512 is not explicitly set [PR 118815]

When AVX512 is not explicitly set, we should not take EVEX512 bit into
consideration when checking vector size. It will solve the intrin header
file reporting warnings when compiling with -Wsystem-headers.

However, there is side effect on the usage for '-march=xxx -mavx10.1-256',
where xxx is with AVX512. It will not report warning on vector size for now.
Since it is a rare usage, we will take it.

gcc/ChangeLog:

PR target/118815
* config/i386/i386-options.cc (ix86_option_override_internal):
Do not check vector size conflict when AVX512 is not explicitly
set.

5 months agoDaily bump.
GCC Administrator [Mon, 17 Feb 2025 00:26:29 +0000 (00:26 +0000)] 
Daily bump.

5 months agoDaily bump.
GCC Administrator [Sun, 16 Feb 2025 00:26:05 +0000 (00:26 +0000)] 
Daily bump.

5 months agoDaily bump.
GCC Administrator [Sat, 15 Feb 2025 00:26:41 +0000 (00:26 +0000)] 
Daily bump.

5 months ago[PATCH] PR modula2/118761: gm2 driver doesnt behave as gcc for -fhelp=BLA
Gaius Mulley [Fri, 14 Feb 2025 19:17:02 +0000 (19:17 +0000)] 
[PATCH] PR modula2/118761: gm2 driver doesnt behave as gcc for -fhelp=BLA

This patch enables the gm2 driver to handle -fsyntax-only -fhelp=optimizers,
for example, correctly without terminating with gm2: fatal error:
no input files.

gcc/m2/ChangeLog:

PR modula2/118761
* gm2spec.cc (lang_specific_driver): Add case clauses for
OPT__help, OPT__help_ set in_added_libraries to 0 and early
return.

(cherry picked from commit 3c5422e719d1fbabccaa9b63605171ea8bdfe57e)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
5 months agoFortran: fix initialization of allocatable non-deferred character [PR59252]
Harald Anlauf [Fri, 7 Feb 2025 20:21:10 +0000 (21:21 +0100)] 
Fortran: fix initialization of allocatable non-deferred character [PR59252]

PR fortran/59252

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_trans_subcomponent_assign): Initialize
allocatable non-deferred character with NULL properly.

gcc/testsuite/ChangeLog:

* gfortran.dg/allocatable_char_1.f90: New test.

(cherry picked from commit 818c36a85e3faec5442eb26799bfa3bba7764b36)

5 months agoDaily bump.
GCC Administrator [Fri, 14 Feb 2025 00:22:20 +0000 (00:22 +0000)] 
Daily bump.

5 months agodriver: -fhardened and -z lazy/-z norelro [PR117739]
Marek Polacek [Tue, 26 Nov 2024 19:37:21 +0000 (14:37 -0500)] 
driver: -fhardened and -z lazy/-z norelro [PR117739]

As the manual states, using "-fhardened -fstack-protector" will produce
a warning because -fhardened wants to enable -fstack-protector-strong,
but it can't since it's been overriden by the weaker -fstack-protector.

-fhardened also attempts to enable -Wl,-z,relro,-z,now.  By the same
logic as above, "-fhardened -z norelro" or "-fhardened -z lazy" should
produce the same warning.  But we don't detect this combination, so
this patch fixes it.  I also renamed a variable to better reflect its
purpose.

Also don't check warn_hardened in process_command, since it's always
true there.

Also tweak wording in the manual as Jon Wakely suggested on IRC.

PR driver/117739

gcc/ChangeLog:

* doc/invoke.texi: Tweak wording for -Whardened.
* gcc.cc (driver_handle_option): If -z lazy or -z norelro was
specified, don't enable linker hardening.
(process_command): Don't check warn_hardened.

gcc/testsuite/ChangeLog:

* c-c++-common/fhardened-16.c: New test.
* c-c++-common/fhardened-17.c: New test.
* c-c++-common/fhardened-18.c: New test.
* c-c++-common/fhardened-19.c: New test.
* c-c++-common/fhardened-20.c: New test.
* c-c++-common/fhardened-21.c: New test.

Reviewed-by: Jakub Jelinek <jakub@redhat.com>
(cherry picked from commit a134dcd8a010744a0097d190f73a4efc2e381531)

5 months ago[PATCH] PR modula2/115112 Incorrect line debugging information occurs during INC...
Gaius Mulley [Thu, 13 Feb 2025 18:17:17 +0000 (18:17 +0000)] 
[PATCH] PR modula2/115112 Incorrect line debugging information occurs during INC builtin

This patch fixes location bugs in BuildDecProcedure,
BuildIncProcedure, BuildInclProcedure, BuildExclProcedure and
BuildThrow.  All these procedure functions use the token position
passed as a parameter (rather than from the quad stack).  It also
fixes location bugs in CheckRangeIncDec to ensure that the token
position is stored on the quad stack before calling subsidiary
procedure functions.

gcc/m2/ChangeLog:

PR modula2/115112
* gm2-compiler/M2Quads.mod (BuildPseudoProcedureCall): Pass
tokno to each build procedure.
(BuildThrowProcedure): New parameter functok.
(BuildIncProcedure): New parameter proctok.
Pass proctok on the quad stack during every push.
(BuildDecProcedure): Ditto.
(BuildInclProcedure): New parameter proctok.
(BuildExclProcedure): New parameter proctok.

gcc/testsuite/ChangeLog:

PR modula2/115112
* gm2/pim/run/pass/dectest.mod: New test.
* gm2/pim/run/pass/inctest.mod: New test.

(cherry picked from commit 4d0faaaaf917528d1c59bfad5401274c5be71b7b)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
5 months agoc++: Constrain visibility for CNTTPs with internal types [PR118849]
Nathaniel Shead [Wed, 12 Feb 2025 12:07:43 +0000 (23:07 +1100)] 
c++: Constrain visibility for CNTTPs with internal types [PR118849]

While looking into PR118846 I noticed that we don't currently constrain
the linkage of functions involving CNTTPs of internal-linkage types.  It
seems to me that this would be sensible to do.

PR c++/118849

gcc/cp/ChangeLog:

* decl2.cc (min_vis_expr_r): Constrain visibility according to
the type of decl_constant_var_p decls.

gcc/testsuite/ChangeLog:

* g++.dg/template/linkage6.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
5 months agoDaily bump.
GCC Administrator [Thu, 13 Feb 2025 00:22:19 +0000 (00:22 +0000)] 
Daily bump.

5 months ago[PATCH] PR modula2/118703 Abort compiling m2pim_NumberIO_BinToStr
Gaius Mulley [Wed, 12 Feb 2025 21:26:04 +0000 (21:26 +0000)] 
[PATCH] PR modula2/118703 Abort compiling m2pim_NumberIO_BinToStr

This patch builds access to the gcc builtins clz, clzl, clzll,
ctz, ctzl and ctzll within m2builtins.cc.  The patch provides
modula2 api access to clz, clzll, ctz and ctzll though the
Builtins definition module.  This PR was raised because of
PR118689.

gcc/m2/ChangeLog:

PR modula2/118703
* gm2-gcc/m2builtins.cc (define_builtin_gcc): New function.
(m2builtins_init): Call define_builtin_gcc.
* gm2-libs/Builtins.def (clz): New procedure function.
(clzll): Ditto.
(ctz): Ditto.
(ctzll): Ditto.
* gm2-libs/Builtins.mod (clz): New procedure function.
(clzll): Ditto.
(ctz): Ditto.
(ctzll): Ditto.
* gm2-libs/cbuiltin.def (clz): New procedure function.
(clzll): Ditto.
(ctz): Ditto.
(ctzll): Ditto.

gcc/testsuite/ChangeLog:

PR modula2/118703
* gm2/builtins/run/pass/testbitfns.mod: New test.

(cherry picked from commit e2d32c81a993a27f3e9b5408f5d20580fe58feca)

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
5 months agoDaily bump.
GCC Administrator [Wed, 12 Feb 2025 00:22:40 +0000 (00:22 +0000)] 
Daily bump.

5 months agox86: Correct ASM_OUTPUT_SYMBOL_REF
H.J. Lu [Tue, 11 Feb 2025 05:47:54 +0000 (13:47 +0800)] 
x86: Correct ASM_OUTPUT_SYMBOL_REF

x is not a macro argument.  It just happens to work as final.cc passes
x for 2nd argument:

final.cc:      ASM_OUTPUT_SYMBOL_REF (file, x);

PR target/118825
* config/i386/i386.h (ASM_OUTPUT_SYMBOL_REF): Replace x with
SYM.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 7317fc0b03380a83ad03a5fc4fabef5f38c44c9d)

5 months agoi386: Fix AVX512BW intrin header with __OPTIMIZE__ [PR 118813]
Haochen Jiang [Mon, 10 Feb 2025 06:00:57 +0000 (14:00 +0800)] 
i386: Fix AVX512BW intrin header with __OPTIMIZE__ [PR 118813]

When moving intrins around for AVX10 implementation in GCC 14,
the intrin _kshiftli_mask32 and _kshiftri_mask32 are wrongly
wrapped by "#if __OPTIMIZE__" instead of "#ifdef __OPTIMIZE__",
leading to the intrin file not `-Wsystem-headers -Wundef` clean
since r14-4490.

gcc/ChangeLog:

PR target/118813
* config/i386/avx512bwintrin.h: Fix wrong __OPTIMIZE__
wrap.

5 months agoDaily bump.
GCC Administrator [Tue, 11 Feb 2025 00:22:44 +0000 (00:22 +0000)] 
Daily bump.

5 months agoi386: Fix ICE with conditional QI/HI vector maxmin [PR118776]
Jakub Jelinek [Sat, 8 Feb 2025 07:54:31 +0000 (08:54 +0100)] 
i386: Fix ICE with conditional QI/HI vector maxmin [PR118776]

The following testcase ICEs starting with GCC 12 since r12-4526
although the bug has been introduced already in r12-2751.
The problem was in the addition of cond_<code><mode> define_expand
which uses nonimmediate_operand predicates for both maxmin operands
for all VI1248_AVX512VLBW modes.  It works fine with
VI48_AVX512VL modes because the <code><mode>3_mask VI48_AVX512VL
define_expand uses ix86_fixup_binary_operands_no_copy and the
*avx512f_<code><mode>3<mask_name> VI48_AVX512VL define_insn uses
% in constraint and !(MEM_P && MEM_P) check in condition (and
<code><mode>3 define_expand with VI124_256_AVX512F_AVX512BW iterator
does that too), but eventhough the 8-bit and 16-bit element maxmin
is commutative too, the <mask_codefor><code><mode>3<mask_name>
define_insn with VI12_AVX512VL iterator didn't use % in constraint
to make it commutative.  So, e.g. cond_umaxv32qi define_expand
allowed nonimmediate_operand for both umax operands, but used
gen_umaxv32qi_mask which wasn't commutative and only allowed
nonimmediate_operand for the second operand.

The following patch fixes it by keeping the <code><mode>3
VI124_256_AVX512F_AVX512BW define_expand as is (it does
ix86_fixup_binary_operands_no_copy) but extending the
<code><mode>3_mask define_expand from VI48_AVX512VL to
VI1248_AVX512VLBW which keeps the current modes with their
ISA conditions and adds the VI12_AVX512VL modes under additional
TARGET_AVX512BW condition, and turning the actual define_insn
into an * prefixed name (which it was before just for the non-masked
case) and having the same commutative operand handling as in other
define_insns.

2025-02-08  Jakub Jelinek  <jakub@redhat.com>

PR target/118776
* config/i386/sse.md (<code><mode>3_mask): Use VI1248_AVX512VLBW
iterator rather than VI48_AVX512VL.
(<mask_codefor><code><mode>3<mask_name>): Rename to ...
(*avx512bw_<code><mode>3<mask_name>): ... this.  Use
nonimmediate_operand rather than register_operand predicate and %v
rather than v constraint for operand 1 and adjust condition to reject
MEMs in both operand 1 and 2.

* gcc.target/i386/pr118776.c: New test.

(cherry picked from commit 64d8ea056a5c339700118a412dea1c44a57acf55)

5 months agoc++: Fix up name independent decl in structured binding handling in range for [PR115586]
Jakub Jelinek [Fri, 7 Feb 2025 16:08:39 +0000 (17:08 +0100)] 
c++: Fix up name independent decl in structured binding handling in range for [PR115586]

cp_parser_range_for temporarily reverts IDENTIFIER_BINDING changes
to hide the decls from the structured bindings from lookup during
parsing of the expression after :
If there are 2 or more name independent decls, we undo IDENTIFIER_BINDING
for the same name multiple times, even when just one has been added
(with a TREE_LIST inside of it as decl).

The following patch fixes it by handling the _ name at most once, the
later loop will DTRT then and just reinstall the temporarily hidden
binding with the TREE_LIST in there.

2025-02-07  Jakub Jelinek  <jakub@redhat.com>

PR c++/115586
* parser.cc (cp_parser_range_for): For name independent decls in
structured bindings, only push the name/binding once per
structured binding.

* g++.dg/cpp26/name-independent-decl9.C: New test.
* g++.dg/cpp26/name-independent-decl10.C: New test.

(cherry picked from commit ca7c6d1212b8589deed18386427c67851af2b9ad)

5 months agoc++: Don't use CLEANUP_EH_ONLY for new expression cleanup [PR118763]
Jakub Jelinek [Fri, 7 Feb 2025 13:30:11 +0000 (14:30 +0100)] 
c++: Don't use CLEANUP_EH_ONLY for new expression cleanup [PR118763]

The following testcase is miscompiled since r12-6325 stopped
preevaluating the initializers for new expression.
If evaluating the initializers throws, there is a correct cleanup
for that, but it is marked CLEANUP_EH_ONLY.  While in standard
C++ that is just fine, if it has statement expressions, it can
return or goto out of the expression and we should delete the
pointer in that case too.

There is already a sentry variable initialized to true and
set to false after everything is initialized and used as a guard
for the cleanup, so just removing the CLEANUP_EH_ONLY flag does
everything we need.  And in the normal case of the initializer
not using statement expressions at least with -O2 we get the same code,
while the change changes one
try { sentry = true; ... sentry = false; } catch { if (sentry) delete ...; }
into
try { sentry = true; ... sentry = false; } finally { if (sentry) delete ...; }
optimizations will see that sentry is false when reaching the finally
other than through an exception.

Though, wonder what other CLEANUP_EH_ONLY cleanups might be an issue
with statement expressions.

2025-02-07  Jakub Jelinek  <jakub@redhat.com>

PR c++/118763
* init.cc (build_new_1): Don't set CLEANUP_EH_ONLY.

* g++.dg/asan/pr118763.C: New test.

(cherry picked from commit fcecc74cb38723457a0447924d9993b31252a8f9)

5 months agoc++: Allow constexpr reads from volatile std::nullptr_t objects [PR118661]
Jakub Jelinek [Fri, 7 Feb 2025 13:27:18 +0000 (14:27 +0100)] 
c++: Allow constexpr reads from volatile std::nullptr_t objects [PR118661]

As mentioned in the PR, https://eel.is/c++draft/conv.lval#note-1
says that even volatile reads from std::nullptr_t typed objects actually
don't read anything and https://eel.is/c++draft/expr.const#10.9
says that even those are ok in constant expressions.

So, the following patch adjusts the r9-4793 changes to have an exception
for NULLPTR_TYPE.
As [conv.lval]/3 also talks about accessing to inactive member, I've added
testcase to cover that as well.

2025-02-07  Jakub Jelinek  <jakub@redhat.com>

PR c++/118661
* constexpr.cc (potential_constant_expression_1): Don't diagnose
lvalue-to-rvalue conversion of volatile lvalue if it has NULLPTR_TYPE.
* decl2.cc (decl_maybe_constant_var_p): Return true for constexpr
decls with NULLPTR_TYPE even if they are volatile.

* g++.dg/cpp0x/constexpr-volatile4.C: New test.
* g++.dg/cpp0x/constexpr-union9.C: New test.

(cherry picked from commit 6c8e6d6febaed3c167ca9534935c2cb18045528e)

5 months agoloop-iv, riscv: Fix get_biv_step_1 for RISC-V [PR117506]
Jakub Jelinek [Thu, 6 Feb 2025 14:39:18 +0000 (15:39 +0100)] 
loop-iv, riscv: Fix get_biv_step_1 for RISC-V [PR117506]

The following test ICEs on RISC-V at least latently since
r14-1622-g99bfdb072e67fa3fe294d86b4b2a9f686f8d9705 which added
RISC-V specific case to get_biv_step_1 to recognize also
({zero,sign}_extend:DI (plus:SI op0 op1))

The reason for the ICE is that op1 in this case is CONST_POLY_INT
which unlike the really expected VOIDmode CONST_INTs has its own
mode and still satisfies CONSTANT_P.
GET_MODE (rhs) (SImode) is different from outer_mode (DImode), so
the function later does
        *inner_step = simplify_gen_binary (code, outer_mode,
                                           *inner_step, op1);
but that obviously ICEs because while *inner_step is either VOIDmode
or DImode, op1 has SImode.

The following patch fixes it by extending op1 using code so that
simplify_gen_binary can handle it.  Another option would be
to change the !CONSTANT_P (op1) 3 lines above this to
!CONST_INT_P (op1), I think it isn't very likely that we get something
useful from other constants there.

2025-02-06  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/117506
* loop-iv.cc (get_biv_step_1): For {ZERO,SIGN}_EXTEND
of PLUS apply {ZERO,SIGN}_EXTEND to op1.

* gcc.dg/pr117506.c: New test.
* gcc.target/riscv/pr117506.c: New test.

(cherry picked from commit bb9cee8928f7f4dfb94e7a8f232eda736b711450)

5 months agoicf: Compare call argument types in certain cases and asm operands [PR117432]
Jakub Jelinek [Fri, 31 Jan 2025 23:50:24 +0000 (00:50 +0100)] 
icf: Compare call argument types in certain cases and asm operands [PR117432]

compare_operand uses operand_equal_p under the hood, which e.g. for
INTEGER_CSTs will just match the values rather regardless of their types.
Now, in many comparing the type is redundant, if we have
  x_2 = y_3 + 1;
we've already compared the type for the lhs and also for rhs1, there won't
be any surprises on rhs2.
As noted in the PR, there are cases where the type of the operand is the
sole place of information and we don't want to ICF merge functions if the
types differ.
One case is stdarg functions, arguments passed to ..., it is different
if we pass 1, 1L, 1LL.
Another case are the K&R unprototyped functions (sure, gone in C23).
And yet another case are inline asm operands, "r" (1) is different from "r"
(1L) from "r" (1LL).

So, the following patch determines based on lack of fntype (e.g. for
internal functions), or on !prototype_p, or on stdarg_p (in that case
using number of named arguments) which arguments need to have type checked
and does that, plus compares types on inline asm operands (maybe it would be
enough to do that just for input operands but we have just a routine to
handle both and I didn't feel we need to differentiate).

Furthermore, I've noticed fntype{1,2} isn't actually compared if it is a
direct call (gimple_call_fndecl is non-NULL).  That is wrong too, we could
have
  void (*fn) (int, long long) = (void (*) (int, long long)) foo;
  fn (1, 1LL);
in one case and
  void (*fn) (long long, int) = (void (*) (long long, int)) foo;
  fn (1LL, 1);
in another, both folded into a direct call of foo with different
gimple_call_fntype.  Sure, one of them would be UB at runtime (or both), but
what if we ICF merge it into something that into the one UB at runtime
and the program actually calls the correct one only?

2025-02-01  Jakub Jelinek  <jakub@redhat.com>

PR ipa/117432
* ipa-icf-gimple.cc (func_checker::compare_asm_inputs_outputs):
Also return_false if operands have incompatible types.
(func_checker::compare_gimple_call): Check fntype1 vs. fntype2
compatibility for all non-internal calls and assume fntype1 and
fntype2 are non-NULL for those.  For calls to non-prototyped
calls or for stdarg_p functions after the last named argument (if any)
check type compatibility of call arguments.

* gcc.c-torture/execute/pr117432.c: New test.
* gcc.target/i386/pr117432.c: New test.

(cherry picked from commit ebd111a2896816e4f5ddf5108f361b3d9d287fa0)

5 months agoniter: Make build_cltz_expr more robust [PR118689]
Jakub Jelinek [Fri, 31 Jan 2025 10:02:41 +0000 (11:02 +0100)] 
niter: Make build_cltz_expr more robust [PR118689]

Since my r15-7223 the niter analysis can recognize one loop during bootstrap
as being ctz like.
The patch just turned
@@ -2173,7 +2173,7 @@ PROC m2pim_NumberIO_BinToStr (CARDINAL x
   _T535_44 = &buf[i.40_2]{lb: 1 sz: 4};
   _T536_45 = x_21 & 1;
   *_T535_44 = _T536_45;
-  _T537_47 = x_21 / 2;
+  _T537_47 = x_21 >> 1;
   x_48 = _T537_47;
   # DEBUG x => x_48
   if (x_48 != 0)
which is not a big deal for the number_of_iterations_cltz optimization, it
recognizes both right shift by 1 and unsigned division by 2 (and similarly
for clz left shift by 1 or multiplication by 2).
But starting with forwprop1 that change also resulted in
@@ -1875,9 +1875,9 @@ PROC m2pim_NumberIO_BinToStr (CARDINAL x
   i.40_2 = (INTEGER) _T530_34;
   _T536_45 = x_21 & 1;
   MEM <CARDINAL[1:64]> [(CARDINAL *)&buf][i.40_2]{lb: 1 sz: 4} = _T536_45;
-  _T537_47 = x_21 / 2;
+  _T537_47 = x_21 >> 1;
   # DEBUG x => _T537_47
-  if (x_21 > 1)
+  if (_T537_47 != 0)
     goto <bb 3>; [INV]
   else
     goto <bb 8>; [INV]
and apparently it is only the latter form that number_of_iterations_cltz
pattern matches, not the former (after all, that was the exact reason
for r15-7223).
The problem is that build_cltz_expr assumes if IFN_C[LT]Z can't be used it
can use the __builtin_c[lt]z{,l,ll} builtins, and while most of the FEs do
create them, modula 2 does not.

The following patch just lets us punt if the FE doesn't build those builtins.
I've filed a PR against modula2 so that they add the builtins too.

2025-01-31  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/118689
PR modula2/115032
* tree-ssa-loop-niter.cc (build_cltz_expr): Return NULL_TREE if fn is
NULL and use_ifn is false.

(cherry picked from commit 85e1714b0606579a339c234510063e057fe662af)

5 months agod: give dependency files better filenames [PR118477]
Arsen Arsenović [Wed, 29 Jan 2025 20:14:33 +0000 (21:14 +0100)] 
d: give dependency files better filenames [PR118477]

Currently, the dependency files for root-file.o and common-file.o were
both d/.deps/file.Po, which would cause parallel builds to fail
sometimes with:

  make[3]: Leaving directory '/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/build/gcc'
  make[3]: Entering directory '/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/build/gcc'
  mv: cannot stat 'd/.deps/file.TPo': No such file or directory
  make[3]: *** [/var/tmp/portage/sys-devel/gcc-14.1.1_p20240511/work/gcc-14-20240511/gcc/d/Make-lang.in:421: d/root-file.o] Error 1 shuffle=131581365

Also, this means that dependencies of one of root-file or common-file
are missing when developing.  After this patch, those two files get
assigned dependency files d/.deps/root-file.Po and
d/.deps/common-file.Po respectively, so match the actual object
files in the d/ subdirectory.

There are other files with similar conflicts (mangle-package.o,
visitor-package.o for instance).

2025-01-29  Arsen Arsenović  <arsen@aarsen.me>
    Jakub Jelinek  <jakub@redhat.com>

PR d/118477
* Make-lang.in (DCOMPILE, DPOSTCOMPILE): Use $(basename $(@F))
instead of $(*F).

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
(cherry picked from commit d9ac0ad1e9a4ceec2d354ac0368da7462bea5675)

5 months agoc++: Return false from __is_bounded_array for zero-sized arrays [PR118655]
Jakub Jelinek [Wed, 29 Jan 2025 08:32:04 +0000 (09:32 +0100)] 
c++: Return false from __is_bounded_array for zero-sized arrays [PR118655]

This is basically Marek's PR114479 r14-9759 __is_array fix applied to
__is_bounded_array as well.  Similarly to that trait, when not using
the builtin it returned false for zero sized arrays but when using
the builtin it returns true.

2025-01-29  Jakub Jelinek  <jakub@redhat.com>

PR c++/118655
* semantics.cc (trait_expr_value) <case CPTK_IS_BOUNDED_ARRAY>: Return
false for zero-sized arrays.

* g++.dg/ext/is_bounded_array.C: Extend.

(cherry picked from commit 3a6ddbf7b241e1cd9f73495ea373b0a12015bb07)

5 months agocombine: Fix up make_extraction [PR118638]
Jakub Jelinek [Tue, 28 Jan 2025 09:14:05 +0000 (10:14 +0100)] 
combine: Fix up make_extraction [PR118638]

The following testcase is miscompiled at -Os on x86_64-linux.
The problem is during make_compound_operation of
(ashiftrt:SI (ashift:SI (mult:SI (reg:SI 107 [ a_5 ])
            (const_int 3 [0x3]))
        (const_int 31 [0x1f]))
    (const_int 31 [0x1f]))
where it incorrectly returns
(mult:SI (sign_extract:SI (reg:SI 107 [ a_5 ])
        (const_int 2 [0x2])
        (const_int 0 [0]))
    (const_int 3 [0x3]))
which isn't obviously true, the former returns either 0 or -1 depending
on the least significant bit of the multiplication,
the latter returns either 0 or -3 depending on the second least significant
bit of the multiplication argument.

The bug has been introduced in PR96998 r11-4563, which added handling of x
* (2^N) similar to x << N.  In the above case, pos is 0 and len is 1,
sign extracting a single least significant bit of the multiplication.
As 3 is not a power of 2, shift_amt is -1.
But IN_RANGE (-1, 1, 1 - 1) is still true, because the basic requirement of
IN_RANGE that LOWER is not greater than UPPER is violated.
The intention of using 1 as LOWER is to avoid matching multiplication by 1,
that really shouldn't appear in the IL.  But to avoid violating IN_RANGE
requirement, we need to verify that len is at least 2.

I've added this len > 1 check to the inner if rather than outer because I
think for GCC 16 we should add a further optimization.
In the particular case of 1 least significant bit sign extraction from
multiplication by 3, we could actually say it is equivalent to
(sign_extract:SI (reg:SI 107 [ a_5 ])
        (const_int 1 [0x2])
        (const_int 0 [0]))
That is because 3 is an odd number and multiplication by 2 will yield the
least significant bit 0 (we are sign extracting just one) and so the
multiplication doesn't change anything on the outcome.
More generally, even for larger len, multiplication by C which is
(1 << X) + 1 where X is >= len should be optimizable just to extraction
of the multiplicand's least significant len bits.

2025-01-28  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/118638
* combine.cc (make_extraction): Only optimize (mult x 2^n) if len is
larger than 1.

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

(cherry picked from commit b529a417249335724d1f74bcf3167f6f9a623823)

5 months agoc++: Only destruct elts of array for new expression if exception is thrown during...
Jakub Jelinek [Sat, 25 Jan 2025 09:15:24 +0000 (10:15 +0100)] 
c++: Only destruct elts of array for new expression if exception is thrown during the initialization [PR117827]

The following testcase r12-6328, because the elements of the array
are destructed twice, once when the callee encounters delete[] p;
and then second time when the exception is thrown.
The array elts should be only destructed if exception is thrown from
one of the constructors during the build_vec_init emitted code in case of
new expressions, but when the new expression completes, it is IMO
responsibility of user code to delete[] it when it is no longer needed.

So, the following patch uses the cleanup_flags argument to build_vec_init
to get notified of the flags that need to be changed when the expression
is complete and build_disable_temp_cleanup to do the changes.

2025-01-25  Jakub Jelinek  <jakub@redhat.com>

PR c++/117827
* init.cc (build_new_1): Pass address of a make_tree_vector ()
initialized gc tree vector to build_vec_init and append
build_disable_temp_cleanup to init_expr from it.

* g++.dg/init/array66.C: New test.

(cherry picked from commit ce268ca2a923f8f35cc9dd5a7d0468a3980f129f)

5 months agotree-assume: Fix UB in assume_query [PR118605]
Jakub Jelinek [Thu, 23 Jan 2025 10:46:18 +0000 (11:46 +0100)] 
tree-assume: Fix UB in assume_query [PR118605]

The assume_query constructor does
assume_query::assume_query (function *f, bitmap p) : m_parm_list (p),
                                                     m_func (f)
where m_parm_list is bitmap &.  This is compile time UB, because
as soon as the constructor returns, m_parm_list reference is still
bound to the parameter of the constructor which is no longer in scope.

Now, one possible fix would be change the ctor argument to be bitmap &,
but that doesn't really work because in the only user of that class
we have
      auto_bitmap decls;
...
      assume_query query (fun, decls);
and auto_bitmap just has
  operator bitmap () { return &m_bits; }
Could be perhaps const bitmap &, but why?  bitmap is a pointer:
typedef class bitmap_head *bitmap;
and the EXECUTE_IF_SET_IN_BITMAP macros don't really change that point,
they just inspect what is inside of that bitmap_head the pointer points
to.

So, the simplest I think is avoid references (which cause even worse
code as it has to be dereferenced twice rather than once).

2025-01-23  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/118605
* tree-assume.cc (assume_query::m_parm_list): Change type
from bitmap & to bitmap.

(cherry picked from commit 27a05f8d11798889ecfb610db9bde781c3d218f7)

5 months agobuiltins: Store unspecified value to *exp for inf/nan [PR114877]
Jakub Jelinek [Thu, 23 Jan 2025 10:11:23 +0000 (11:11 +0100)] 
builtins: Store unspecified value to *exp for inf/nan [PR114877]

The fold_builtin_frexp folding for NaN/Inf just returned the first argument
with evaluating second arguments side-effects, rather than storing something
to what the second argument points to.

The PR argues that the C standard requires the function to store something
there but what exactly is stored is unspecified, so not storing there
anything can result in UB if the value isn't initialized and is read later.

glibc and newlib store there 0, musl apparently doesn't store anything.

The following patch stores there zero (or would you prefer storing there
some other value, 42, INT_MAX, INT_MIN, etc.?; zero is cheapest to form
in assembly though) and adjusts the test so that it
doesn't rely on not storing there anything but instead checks for
-Wmaybe-uninitialized warning to find out that something has been stored
there.
Unfortunately I had to disable the NaN tests for -O0, while we can fold
__builtin_isnan (__builtin_nan ("")) at compile time, we can't fold
__builtin_isnan ((i = 0, __builtin_nan (""))) at compile time.
fold_builtin_classify uses just tree_expr_nan_p and if that isn't true
(because expr is a COMPOUND_EXPR with tree_expr_nan_p on the second arg),
it does
      arg = builtin_save_expr (arg);
      return fold_build2_loc (loc, UNORDERED_EXPR, type, arg, arg);
and that isn't folded at -O0 further, as we wrap it into SAVE_EXPR and
nothing propagates the NAN to the comparison.
I think perhaps tree_expr_nan_p etc. could have case COMPOUND_EXPR:
added and recurse on the second argument, but that feels like stage1
material to me if we want to do that at all.

2025-01-23  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/114877
* builtins.cc (fold_builtin_frexp): Handle rvc_nan and rvc_inf cases
like rvc_zero, return passed in arg and set *exp = 0.

* gcc.dg/torture/builtin-frexp-1.c: Add -Wmaybe-uninitialized as
dg-additional-options.
(bar): New function.
(TESTIT_FREXP2): Rework the macro so that it doesn't test whether
nothing has been stored to what the second argument points to, but
instead that something has been stored there, whatever it is.
(main): Temporarily don't enable the nan tests for -O0.

(cherry picked from commit d19b0682f18f9f5217aee8002e3d04f8ded04ae8)

5 months agomatch.pd: Fix (FTYPE) N CMP (FTYPE) M optimization for GENERIC [PR118522]
Jakub Jelinek [Fri, 17 Jan 2025 10:30:07 +0000 (11:30 +0100)] 
match.pd: Fix (FTYPE) N CMP (FTYPE) M optimization for GENERIC [PR118522]

The last case of this optimization assumes that if 2 integral types
have same precision and TYPE_UNSIGNED, then they are uselessly convertible.
While that is very likely the case for GIMPLE, it is not the case for
GENERIC, so the following patch adds there a convert so that the
optimization produces also valid GENERIC.  Without it we got
(int) p == b where b had _BitInt(32) type, so incompatible types.

2025-01-17  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/118522
* match.pd ((FTYPE) N CMP (FTYPE) M): Add convert, as in GENERIC
integral types with the same precision and sign might actually not
be compatible types.

* gcc.dg/bitint-120.c: New test.

(cherry picked from commit 3ab9eb6946f7b832834b3d808c5617935e0be727)

5 months agovec.h: Properly destruct elements in auto_vec auto storage [PR118400]
Jakub Jelinek [Thu, 16 Jan 2025 08:17:50 +0000 (09:17 +0100)] 
vec.h: Properly destruct elements in auto_vec auto storage [PR118400]

For T with non-trivial destructors, we were destructing objects in the
vector on release only when not using auto storage of auto_vec.

The following patch calls truncate (0) instead of m_vecpfx.m_num clearing,
and truncate takes care of that destruction:
  unsigned l = length ();
  gcc_checking_assert (l >= size);
  if (!std::is_trivially_destructible <T>::value)
    vec_destruct (address () + size, l - size);
  m_vecpfx.m_num = size;

2025-01-16  Jakub Jelinek  <jakub@redhat.com>

PR ipa/118400
* vec.h (vec<T, va_heap, vl_ptr>::release): Call m_vec->truncate (0)
instead of clearing m_vec->m_vecpfx.m_num.

(cherry picked from commit 43f4d44bebd63b354f8798fcef512d4d2b42c655)

5 months agoDaily bump.
GCC Administrator [Mon, 10 Feb 2025 00:22:46 +0000 (00:22 +0000)] 
Daily bump.

5 months agolibgcc: On FreeBSD use GCC's crt objects for static linking
Dimitry Andric [Tue, 28 Jan 2025 17:36:16 +0000 (18:36 +0100)] 
libgcc: On FreeBSD use GCC's crt objects for static linking

Add crtbeginT.o to extra_parts on FreeBSD. This ensures we use GCC's
crt objects for static linking. Otherwise it could mix crtbeginT.o
from the base system with libgcc's crtend.o, possibly leading to
segfaults.

libgcc:
PR target/118685
* config.host (*-*-freebsd*): Add crtbeginT.o to extra_parts.

Signed-off-by: Dimitry Andric <dimitry@andric.com>
5 months agoDaily bump.
GCC Administrator [Sun, 9 Feb 2025 00:21:48 +0000 (00:21 +0000)] 
Daily bump.

5 months agoDaily bump.
GCC Administrator [Sat, 8 Feb 2025 00:22:01 +0000 (00:22 +0000)] 
Daily bump.

5 months agoFortran: FIx ICE in associate with elemental function [PR118750]
Paul Thomas [Thu, 6 Feb 2025 16:40:19 +0000 (16:40 +0000)] 
Fortran:  FIx ICE in associate with elemental function [PR118750]

2025-02-06  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/118750
* resolve.cc (resolve_assoc_var): If the target expression has
a rank, do not use gfc_expression_rank, since it will return 0
if the function is elemental. Resolution will have produced the
correct rank.

gcc/testsuite/
PR fortran/118750
* gfortran.dg/associate_72.f90: New test.

(cherry picked from commit a03303b4d5b2ca58e5750a4d5bd735d85a091273)

5 months agoFortran: Fix error recovery for bad component arrayspecs [PR108434]
Paul Thomas [Sat, 11 Jan 2025 08:23:48 +0000 (08:23 +0000)] 
Fortran: Fix error recovery for bad component arrayspecs [PR108434]

2025-01-11  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran/
PR fortran/108434
* class.cc (generate_finalization_wrapper): To avoid memory
leaks from callocs, return immediately if the derived type
error flag is set.
* decl.cc (build_struct): If the declaration of a derived type
or class component does not have a deferred arrayspec, correct,
set the error flag of the derived type and emit an immediate
error.

gcc/testsuite/
PR fortran/108434
* gfortran.dg/pr108434.f90 : Add tests from comment 1.

(cherry picked from commit d64ca15351029164bac30b49fb3c4f9723e755de)

5 months agoDaily bump.
GCC Administrator [Fri, 7 Feb 2025 00:24:04 +0000 (00:24 +0000)] 
Daily bump.

5 months agoFortran: host association issue with symbol in COMMON block [PR108454]
Harald Anlauf [Thu, 30 Jan 2025 21:21:19 +0000 (22:21 +0100)] 
Fortran: host association issue with symbol in COMMON block [PR108454]

When resolving a flavorless symbol that is already registered with a COMMON
block, and which neither has the intrinsic, generic, or external attribute,
skip searching among interfaces to avoid false resolution to a derived type
of the same name.

PR fortran/108454

gcc/fortran/ChangeLog:

* resolve.cc (resolve_common_blocks): Initialize variable.
(resolve_symbol): If a symbol is already registered with a COMMON
block, do not search for an interface with the same name.

gcc/testsuite/ChangeLog:

* gfortran.dg/common_29.f90: New test.

(cherry picked from commit d6418fe22684f9335474d1fd405ade45954c069d)

6 months agoLoongArch: Fix ICE caused by illegal calls to builtin functions [PR118561].
Lulu Cheng [Wed, 22 Jan 2025 09:57:21 +0000 (17:57 +0800)] 
LoongArch: Fix ICE caused by illegal calls to builtin functions [PR118561].

PR target/118561

gcc/ChangeLog:

* config/loongarch/loongarch-builtins.cc
(loongarch_expand_builtin_lsx_test_branch):
NULL_RTX will not be returned when an error is detected.
(loongarch_expand_builtin): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/pr118561.c: New test.

(cherry picked from commit 50d2bde68a097c2e9fb3bdd7e6664c8988889828)

6 months agoDaily bump.
GCC Administrator [Thu, 6 Feb 2025 00:22:56 +0000 (00:22 +0000)] 
Daily bump.

6 months agoRTEMS: Add Cortex-M33 multilib
Sebastian Huber [Tue, 4 Feb 2025 03:09:02 +0000 (04:09 +0100)] 
RTEMS: Add Cortex-M33 multilib

Enable use of Armv8-M instruction set.

Account for CVE-2021-35465 mitigation [PR102035].
The -mfix-cmse-cve-2021-35465 option is enabled by default,
if -mcpu=cortex-m33 is used.

gcc/

* config/arm/t-rtems: Add Cortex-M33 multilib.

(cherry picked from commit f2a8f3c364a0d196efb0687ea421190b46d041d5)

6 months agoDaily bump.
GCC Administrator [Wed, 5 Feb 2025 00:23:06 +0000 (00:23 +0000)] 
Daily bump.

6 months agoFortran: F2008 passing of internal procs to a proc pointer [PR117434]
Paul Thomas [Wed, 6 Nov 2024 07:17:25 +0000 (07:17 +0000)] 
Fortran: F2008 passing of internal procs to a proc pointer [PR117434]

2024-11-06  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/117434
* interface.cc (gfc_compare_actual_formal): Skip 'Expected a
procedure pointer error' if the formal argument typespec has an
interface and the type of the actual arg is BT_PROCEDURE.

gcc/testsuite/
PR fortran/117434
* gfortran.dg/proc_ptr_54.f90: New test. This is temporarily
compile-only until one one seven four five five is fixed.
* gfortran.dg/proc_ptr_55.f90: New test.
* gfortran.dg/proc_ptr_56.f90: New test.

(cherry picked from commit 4dbf4c0fdb188e1c348688de91e010f696cd59fc)

6 months agoDaily bump.
GCC Administrator [Tue, 4 Feb 2025 00:22:40 +0000 (00:22 +0000)] 
Daily bump.

6 months agooptions: Adjust cl_optimization_compare to avoid checking ICE [PR115913]
Lewis Hyatt [Sun, 26 Jan 2025 23:57:00 +0000 (18:57 -0500)] 
options: Adjust cl_optimization_compare to avoid checking ICE [PR115913]

At the end of a sequence like:
 #pragma GCC push_options
 ...
 #pragma GCC pop_options

the handler for pop_options calls cl_optimization_compare() (as generated by
optc-save-gen.awk) to make sure that all global state has been restored to
the value it had prior to the push_options call. The verification is
performed for almost all entries in the global_options struct. This leads to
unexpected checking asserts, as discussed in the PR, in case the state of
warnings-related options has been intentionally modified in between
push_options and pop_options via a call to #pragma GCC diagnostic. Address
that by skipping the verification for CL_WARNING-flagged options.

gcc/ChangeLog:

PR middle-end/115913
* optc-save-gen.awk (cl_optimization_compare): Skip options with
CL_WARNING flag.

gcc/testsuite/ChangeLog:

PR middle-end/115913
* c-c++-common/cpp/pr115913.c: New test.

6 months agoDaily bump.
GCC Administrator [Mon, 3 Feb 2025 00:22:01 +0000 (00:22 +0000)] 
Daily bump.

6 months agoDaily bump.
GCC Administrator [Sun, 2 Feb 2025 00:22:57 +0000 (00:22 +0000)] 
Daily bump.

6 months agoAda: Fix segfault on uninitialized variable as operand of primitive operator
Eric Botcazou [Sat, 1 Feb 2025 09:56:44 +0000 (10:56 +0100)] 
Ada: Fix segfault on uninitialized variable as operand of primitive operator

...of derived real type.  It comes from an unexpected internal adjustment.

gcc/ada/
PR ada/118712
* sem_warn.adb (Check_References): Deal with small adjustments of
references.

gcc/testsuite/
* gnat.dg/warn33.adb: New test.
* gnat.dg/warn33_pkg.ads: New helper.

6 months agoDaily bump.
GCC Administrator [Sat, 1 Feb 2025 00:22:48 +0000 (00:22 +0000)] 
Daily bump.

6 months agoFortran: fix bogus diagnostics on renamed interface import [PR110993]
Harald Anlauf [Sun, 26 Jan 2025 21:56:57 +0000 (22:56 +0100)] 
Fortran: fix bogus diagnostics on renamed interface import [PR110993]

PR fortran/110993

gcc/fortran/ChangeLog:

* frontend-passes.cc (check_externals_procedure): Do not compare
interfaces of a non-bind(C) procedure against a bind(C) global one.
(check_against_globals): Use local name from rename-on-use in the
search for interfaces.

gcc/testsuite/ChangeLog:

* gfortran.dg/use_rename_14.f90: New test.

(cherry picked from commit 9104472b645f76a212af9f9c58378500f9ba937e)

6 months agoDaily bump.
GCC Administrator [Fri, 31 Jan 2025 00:24:43 +0000 (00:24 +0000)] 
Daily bump.

6 months agoDaily bump.
GCC Administrator [Thu, 30 Jan 2025 00:24:13 +0000 (00:24 +0000)] 
Daily bump.

6 months agoFortran: fix passing of component ref to assumed-rank dummy [PR118683]
Harald Anlauf [Tue, 28 Jan 2025 20:21:40 +0000 (21:21 +0100)] 
Fortran: fix passing of component ref to assumed-rank dummy [PR118683]

While the fix for pr117774 addressed the passing of an inquiry reference
to an assumed-rank dummy, it missed the similar case of passing a component
reference.  The newer testcase gfortran.dg/pr81978.f90 uncovered this
latent issue with a UBSAN instrumented compiler.

PR fortran/118683

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_conv_procedure_call): The bounds update for
passing to assumed-rank dummies shall also handle component
references besides inquiry references.

(cherry picked from commit 5d001fa122bf04cfd0611ff7723969a0421b3094)

6 months agotestsuite/118127: Pass fortran tests on ppc64le for IEEE128 long doubles
Siddhesh Poyarekar [Thu, 19 Dec 2024 13:09:15 +0000 (08:09 -0500)] 
testsuite/118127: Pass fortran tests on ppc64le for IEEE128 long doubles

Denormal behaviour is well defined for IEEE128 long doubles, so
XFAIL some gfortran tests only for targets with the IBM128 long double
ABI.

gcc/testsuite/ChangeLog:

PR testsuite/118127
* lib/target-supports.exp
(check_effective_target_long_double_is_ibm128): New
procedure.
* gfortran.dg/default_format_2.f90: xfail for
long_double_is_ibm128.
* gfortran.dg/default_format_denormal_2.f90: Likewise.
* gfortran.dg/large_real_kind_form_io_2.f90: Likewise.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
(cherry picked from commit d4d4e874dee2d5b0abe5ceb9f2a78e5602e86030)

6 months agolibstdc++: Fix views::transform(move_only_fn{}) forwarding [PR118413]
Patrick Palka [Wed, 29 Jan 2025 15:02:28 +0000 (10:02 -0500)] 
libstdc++: Fix views::transform(move_only_fn{}) forwarding [PR118413]

The range adaptor perfect forwarding simplification mechanism is currently
only enabled for trivially copyable bound arguments, to prevent undesirable
copies of complex objects.  But "trivially copyable" is the wrong property
to check for here, since a move-only type with a trivial move constructor
is considered trivially copyable, and after P2492R2 we can't assume copy
constructibility of the bound arguments.  This patch makes the mechanism
more specifically check for trivial copy constructibility instead so
that it's properly disabled for move-only bound arguments.

PR libstdc++/118413

libstdc++-v3/ChangeLog:

* include/std/ranges (views::__adaptor::_Partial): Adjust
constraints on the "simple" partial specializations to require
is_trivially_copy_constructible_v instead of
is_trivially_copyable_v.
* testsuite/std/ranges/adaptors/adjacent_transform/1.cc (test04):
Extend P2494R2 test.
* testsuite/std/ranges/adaptors/transform.cc (test09): Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit 09d1cbee10b8c51aed48f047f30717f622d6f811)

6 months agoc++: re-enable NSDMI CONSTRUCTOR folding [PR118355]
Marek Polacek [Mon, 13 Jan 2025 20:09:14 +0000 (15:09 -0500)] 
c++: re-enable NSDMI CONSTRUCTOR folding [PR118355]

In c++/102990 we had a problem where massage_init_elt got {},
digest_nsdmi_init turned that {} into { .value = (int) 1.0e+0 },
and we crashed in the call to fold_non_dependent_init because
a FIX_TRUNC_EXPR/FLOAT_EXPR got into tsubst*.  So we avoided
calling fold_non_dependent_init for a CONSTRUCTOR.

But that broke the following test, where we no longer fold the
CONST_DECL in
  { .type = ZERO }
to
  { .type = 0 }
and then process_init_constructor_array does:

            if (next != error_mark_node
                && (initializer_constant_valid_p (next, TREE_TYPE (next))
                    != null_pointer_node))
              {
                /* Use VEC_INIT_EXPR for non-constant initialization of
                   trailing elements with no explicit initializers.  */
                picflags |= PICFLAG_VEC_INIT;

because { .type = ZERO } isn't initializer_constant_valid_p.  Then we
create a VEC_INIT_EXPR and say we can't convert the argument.

So we have to fold the elements of the CONSTRUCTOR.  We just can't
instantiate the elements in a template.

This also fixes c++/118047.

PR c++/118047
PR c++/118355

gcc/cp/ChangeLog:

* typeck2.cc (massage_init_elt): Call fold_non_dependent_init
unless for a CONSTRUCTOR in a template.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/nsdmi-list10.C: New test.
* g++.dg/cpp0x/nsdmi-list9.C: New test.

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

6 months agoDaily bump.
GCC Administrator [Wed, 29 Jan 2025 00:24:29 +0000 (00:24 +0000)] 
Daily bump.

6 months agoc++: friend vs inherited guide confusion [PR117855]
Patrick Palka [Tue, 28 Jan 2025 14:27:02 +0000 (09:27 -0500)] 
c++: friend vs inherited guide confusion [PR117855]

We recently started using the lang_decl_fn::context field to track
inheritedness of a deduction guide (for C++23 inherited CTAD).  This
new overloading of the field accidentally made DECL_FRIEND_CONTEXT
return non-NULL for inherited guides, which breaks the below testcase
during overload resolution with an inherited guide.

This patch fixes this by refining DECL_FRIEND_CONTEXT appropriately.

PR c++/117855

gcc/cp/ChangeLog:

* cp-tree.h (DECL_FRIEND_CONTEXT): Exclude deduction guides.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/class-deduction-inherited7.C: New test.

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

6 months agoAArch64: don't override march to assembler with mcpu if march is specified [PR110901]
Tamar Christina [Thu, 16 Jan 2025 19:23:50 +0000 (19:23 +0000)] 
AArch64: don't override march to assembler with mcpu if march is specified [PR110901]

When both -mcpu and -march are specified, the value of -march wins out.

This is done correctly for the calls to cc1 and for the assembler directives we
put out in assembly files.

However in the call to as we don't do this and instead use the arch from the
cpu.  This leads to a situation that GCC cannot reliably be used to compile
assembly files which don't have a .arch directive.

This is quite common with .S files which use macros to selectively enable
codepath based on what the preprocessor sees.

The fix is to change MCPU_TO_MARCH_SPEC to not override the march if an march
is already specified.

gcc/ChangeLog:

PR target/110901
* config/aarch64/aarch64.h (MCPU_TO_MARCH_SPEC): Don't override if
march is set.

gcc/testsuite/ChangeLog:

PR target/110901
* gcc.target/aarch64/options_set_29.c: New test.

(cherry picked from commit 773beeaafb0ea31bd4e308b64781731d64b571ce)

6 months agoAArch64: have -mcpu=native detect architecture extensions for unknown non-homogenous...
Tamar Christina [Thu, 16 Jan 2025 19:25:26 +0000 (19:25 +0000)] 
AArch64: have -mcpu=native detect architecture extensions for unknown non-homogenous systems [PR113257]

in g:e91a17fe39c39e98cebe6e1cbc8064ee6846a3a7 we added the ability for
-mcpu=native on unknown CPUs to still enable architecture extensions.

This has worked great but was only added for homogenous systems.

However the same thing works for big.LITTLE as in such system the cores must
have the same extensions otherwise it doesn't fundamentally work.

i.e. task migration from one core to the other wouldn't work.

This extends the same handling to non-homogenous systems.

gcc/ChangeLog:

PR target/113257
* config/aarch64/driver-aarch64.cc (get_cpu_from_id, DEFAULT_CPU): New.
(host_detect_local_cpu): Use it.

gcc/testsuite/ChangeLog:

PR target/113257
* gcc.target/aarch64/cpunative/info_34: New test.
* gcc.target/aarch64/cpunative/native_cpu_34.c: New test.
* gcc.target/aarch64/cpunative/info_35: New test.
* gcc.target/aarch64/cpunative/native_cpu_35.c: New test.

Co-authored-by: Richard Sandiford <richard.sandiford@arm.com>
(cherry picked from commit 1ff85affe46623fe1a970de95887df22f4da9d16)

6 months agoasan: Fix missing FakeStack flag cleanup
Ilya Leoshkevich [Tue, 7 Jan 2025 23:17:07 +0000 (00:17 +0100)] 
asan: Fix missing FakeStack flag cleanup

The FakeStack flag is not zeroed out when can_store_by_pieces()
returns false.  Over time, this causes FakeStack::Allocate() to perform
the maximum number of loop iterations, significantly slowing down the
instrumented program.

Link: https://inbox.sourceware.org/gcc-patches/20250109001702.154685-1-iii@linux.ibm.com/
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
gcc/ChangeLog:

* asan.cc (asan_emit_stack_protection): Always zero the flag
unless it is cleared by the __asan_stack_free_N() libcall.

(cherry picked from commit 13d971601175541146fda54682cde4d3f9cd2759)

6 months agoDaily bump.
GCC Administrator [Tue, 28 Jan 2025 00:27:40 +0000 (00:27 +0000)] 
Daily bump.

6 months agolibstdc++: perfectly forward std::ranges::clamp arguments
Giuseppe D'Angelo [Sun, 19 Jan 2025 15:30:20 +0000 (16:30 +0100)] 
libstdc++: perfectly forward std::ranges::clamp arguments

As reported in PR118185, std::ranges::clamp does not correctly forward
the projected value to the comparator. Add the missing forward.

libstdc++-v3/ChangeLog:

PR libstdc++/118185
PR libstdc++/100249
* include/bits/ranges_algo.h (__clamp_fn): Correctly forward the
projected value to the comparator.
* testsuite/25_algorithms/clamp/118185.cc: New test.

Signed-off-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
(cherry picked from commit b342614139c0a981b369176980663941b9c27f39)

6 months agoc++: explicit spec of constrained member tmpl [PR107522]
Patrick Palka [Thu, 16 Jan 2025 21:40:08 +0000 (16:40 -0500)] 
c++: explicit spec of constrained member tmpl [PR107522]

When defining a explicit specialization of a constrained member template
(of a class template) such as f and g in the below testcase, the
DECL_TEMPLATE_PARMS of the corresponding TEMPLATE_DECL are partially
instantiated, whereas its associated constraints are carried over
from the original template and thus are in terms of the original
DECL_TEMPLATE_PARMS.  So during normalization for such an explicit
specialization we need to consider the (parameters of) the most general
template, since that's what the constraints are in terms of and since we
always use the full set of template arguments during satisfaction.

PR c++/107522

gcc/cp/ChangeLog:

* constraint.cc (get_normalized_constraints_from_decl): Use the
most general template for an explicit specialization of a
member template.

gcc/testsuite/ChangeLog:

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

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

6 months agoDaily bump.
GCC Administrator [Mon, 27 Jan 2025 00:24:04 +0000 (00:24 +0000)] 
Daily bump.

6 months agoDaily bump.
GCC Administrator [Sun, 26 Jan 2025 00:23:24 +0000 (00:23 +0000)] 
Daily bump.

6 months agoDaily bump.
GCC Administrator [Sat, 25 Jan 2025 00:26:39 +0000 (00:26 +0000)] 
Daily bump.

6 months agoFortran: Fix UTF-8 output with A edit descriptor.
Jerry DeLisle [Thu, 23 Jan 2025 20:58:14 +0000 (12:58 -0800)] 
Fortran: Fix UTF-8 output with A edit descriptor.

This adjusts the source len for the case where the user has
specified a field width with the A descriptor.

PR libfortran/118571

libgfortran/ChangeLog:

* io/write.c (write_utf8_char4): Adjust the src_len to the
format width w_len when greater than zero.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 4daf088123b2c4c3114a4b96d5353c3d72eb8ac9)

6 months agoFortran: do not copy back for parameter actual arguments [PR81978]
Harald Anlauf [Sun, 19 Jan 2025 20:06:56 +0000 (21:06 +0100)] 
Fortran: do not copy back for parameter actual arguments [PR81978]

When an array is packed for passing as an actual argument, and the array
has the PARAMETER attribute (i.e., it is a named constant that can reside
in read-only memory), do not copy back (unpack) from the temporary.

PR fortran/81978

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_conv_array_parameter): Do not copy back data
if actual array parameter has the PARAMETER attribute.
* trans-expr.cc (gfc_conv_subref_array_arg): Likewise.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr81978.f90: New test.

(cherry picked from commit 0d1e62b83561baa185bf080515750a89dd3ac410)

6 months agoc++: ICE with nested anonymous union [PR117153]
Marek Polacek [Mon, 25 Nov 2024 14:45:13 +0000 (09:45 -0500)] 
c++: ICE with nested anonymous union [PR117153]

In a template, for

  union {
    union {
      T d;
    };
  };

build_anon_union_vars crates a malformed COMPONENT_REF: we have no
DECL_NAME for the nested anon union so we create something like "object.".
Most of the front end doesn't seem to care, but if such a tree gets to
potential_constant_expression, it can cause a crash.

We can use FIELD directly for the COMPONENT_REF's member.  tsubst_stmt
should build up a proper one in:

    if (VAR_P (decl) && !DECL_NAME (decl)
&& ANON_AGGR_TYPE_P (TREE_TYPE (decl)))
      /* Anonymous aggregates are a special case.  */
      finish_anon_union (decl);

PR c++/117153

gcc/cp/ChangeLog:

* decl2.cc (build_anon_union_vars): Use FIELD for the second operand
of a COMPONENT_REF.

gcc/testsuite/ChangeLog:

* g++.dg/other/anon-union6.C: New test.
* g++.dg/other/anon-union7.C: New test.

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

6 months agotestsuite: arm: Use -Os -fno-math-errno in vfp-1.c [PR116448]
Torbjörn SVENSSON [Fri, 24 Jan 2025 16:56:51 +0000 (17:56 +0100)] 
testsuite: arm: Use -Os -fno-math-errno in vfp-1.c [PR116448]

gcc/testsuite/ChangeLog:

PR testsuite/116448
* gcc.target/arm/vfp-1.c: Use -Os -fno-math-errno.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
(cherry picked from commit 062c04c45b2156b27ddc3b6541d8484e9db63bc3)

6 months agors6000: Fix ICE for invalid constants in built-in functions
Peter Bergner [Thu, 16 Jan 2025 16:53:27 +0000 (10:53 -0600)] 
rs6000: Fix ICE for invalid constants in built-in functions

For invalid constant operand values used in built-in functions, return
const0_rtx to signify an error occurred during expansion.

2025-01-16  Peter Bergner  <bergner@linux.ibm.com>

gcc/
* config/rs6000/rs6000-builtin.cc (rs6000_expand_builtin): Return
const0_rtx when there is an error.

gcc/testsuite/
* gcc.target/powerpc/mma-builtin-error.c: New test.

(cherry picked from commit 0696af74b3392e2178215607337b116d1bb53e34)

6 months agors6000: Fix loop limit for built-in constant checking
Peter Bergner [Thu, 16 Jan 2025 16:49:45 +0000 (10:49 -0600)] 
rs6000: Fix loop limit for built-in constant checking

The loop checking for built-in constant operand restrictions was missing
some operands due to the loop limit being too small.  Fixing that exposed
a testsuite failure which is caused by a typo in the pmxvi4ger8pp definition
where we had made the PMASK field too small.

2025-01-16  Peter Bergner  <bergner@linux.ibm.com>

gcc/
* config/rs6000/rs6000-builtin.cc (rs6000_expand_builtin): Use correct
array size for the loop limit.
* config/rs6000/rs6000-builtins.def: Fix field size for PMASK operand.

(cherry picked from commit 1a2d63a78f99b7fdc2eff5bf9065682d5bbbaaca)

6 months agoDaily bump.
GCC Administrator [Fri, 24 Jan 2025 00:24:23 +0000 (00:24 +0000)] 
Daily bump.

6 months agohppa: Fix typo in ADDITIONAL_REGISTER_NAMES in pa32-regs.h
John David Anglin [Thu, 23 Jan 2025 19:35:22 +0000 (14:35 -0500)] 
hppa: Fix typo in ADDITIONAL_REGISTER_NAMES in pa32-regs.h

2025-01-23  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa32-regs.h (ADDITIONAL_REGISTER_NAMES): Change
register 86 name to "%fr31L".

6 months agoDaily bump.
GCC Administrator [Thu, 23 Jan 2025 00:25:48 +0000 (00:25 +0000)] 
Daily bump.

6 months agortl: Remove invalid compare simplification [PR117186]
Richard Sandiford [Wed, 22 Jan 2025 15:23:54 +0000 (15:23 +0000)] 
rtl: Remove invalid compare simplification [PR117186]

g:d882fe5150fbbeb4e44d007bb4964e5b22373021, posted at
https://gcc.gnu.org/pipermail/gcc-patches/2000-July/033786.html ,
added code to treat:

  (set (reg:CC cc) (compare:CC (gt:M (reg:CC cc) 0) (lt:M (reg:CC cc) 0)))

as a nop.  This PR shows that that isn't always correct.
The compare in the set above is between two 0/1 booleans (at least
on STORE_FLAG_VALUE==1 targets), whereas the unknown comparison that
produced the incoming (reg:CC cc) is unconstrained; it could be between
arbitrary integers, or even floats.  The fold is therefore replacing a
cc that is valid for both signed and unsigned comparisons with one that
is only known to be valid for signed comparisons.

  (gt (compare (gt cc 0) (lt cc 0) 0)

does simplify to:

  (gt cc 0)

but:

  (gtu (compare (gt cc 0) (lt cc 0) 0)

does not simplify to:

  (gtu cc 0)

The optimisation didn't come with a testcase, but it was added for
i386's cmpstrsi, now cmpstrnsi.  That probably doesn't matter as much
as it once did, since it's now conditional on -minline-all-stringops.
But the patch is almost 25 years old, so whatever the original
motivation was, it seems likely that other things now rely on it.

It therefore seems better to try to preserve the optimisation on rtl
rather than get rid of it.  To do that, we need to look at how the
result of the outer compare is used.  We'd therefore be looking at four
instructions (the gt, the lt, the compare, and the use of the compare),
but combine already allows that for 3-instruction combinations thanks
to:

  /* If the source is a COMPARE, look for the use of the comparison result
     and try to simplify it unless we already have used undobuf.other_insn.  */

When applied to boolean inputs, a comparison operator is
effectively a boolean logical operator (AND, ANDNOT, XOR, etc.).
simplify_logical_relational_operation already had code to simplify
logical operators between two comparison results, but:

* It only handled IOR, which doesn't cover all the cases needed here.
  The others are easily added.

* It treated comparisons of integers as having an ORDERED/UNORDERED result.
  Therefore:

  * it would not treat "true for LT + EQ + GT" as "always true" for
    comparisons between integers, because the mask excluded the UNORDERED
    condition.

  * it would try to convert "true for LT + GT" into LTGT even for comparisons
    between integers.  To prevent an ICE later, the code used:

       /* Many comparison codes are only valid for certain mode classes.  */
       if (!comparison_code_valid_for_mode (code, mode))
         return 0;

    However, this used the wrong mode, since "mode" is here the integer
    result of the comparisons (and the mode of the IOR), not the mode of
    the things being compared.  Thus the effect was to reject all
    floating-point-only codes, even when comparing floats.

  I think instead the code should detect whether the comparison is between
  integer values and remove UNORDERED from consideration if so.  It then
  always produces a valid comparison (or an always true/false result),
  and so comparison_code_valid_for_mode is not needed.  In particular,
  "true for LT + GT" becomes NE for comparisons between integers but
  remains LTGT for comparisons between floats.

* There was a missing check for whether the comparison inputs had
  side effects.

While there, it also seemed worth extending
simplify_logical_relational_operation to unsigned comparisons, since
that makes the testing easier.

As far as that testing goes: the patch exhaustively tests all
combinations of integer comparisons in:

  (cmp1 (cmp2 X Y) (cmp3 X Y))

for the 10 integer comparisons, giving 1000 fold attempts in total.
It then tries all combinations of (X in {-1,0,1} x Y in {-1,0,1})
on the result of the fold, giving 9 checks per fold, or 9000 in total.
That's probably more than is typical for self-tests, but it seems to
complete in neglible time, even for -O0 builds.

gcc/
PR rtl-optimization/117186
* rtl.h (simplify_context::simplify_logical_relational_operation): Add
an invert0_p parameter.
* simplify-rtx.cc (unsigned_comparison_to_mask): New function.
(mask_to_unsigned_comparison): Likewise.
(comparison_code_valid_for_mode): Delete.
(simplify_context::simplify_logical_relational_operation): Add
an invert0_p parameter.  Handle AND and XOR.  Handle unsigned
comparisons.  Handle always-false results.  Ignore the low bit
of the mask if the operands are always ordered and remove the
then-redundant check of comparison_code_valid_for_mode.  Check
for side-effects in the operands before simplifying them away.
(simplify_context::simplify_binary_operation_1): Remove
simplification of (compare (gt ...) (lt ...)) and instead...
(simplify_context::simplify_relational_operation_1): ...handle
comparisons of comparisons here.
(test_comparisons): New function.
(test_scalar_ops): Call it.

gcc/testsuite/
PR rtl-optimization/117186
* gcc.dg/torture/pr117186.c: New test.
* gcc.target/aarch64/pr117186.c: Likewise.

6 months agoaarch64: Detect word-level modification in early-ra [PR118184]
Richard Sandiford [Wed, 22 Jan 2025 15:23:54 +0000 (15:23 +0000)] 
aarch64: Detect word-level modification in early-ra [PR118184]

REGMODE_NATURAL_SIZE is set to 64 bits for everything except
VLA SVE modes.  This means that it's possible to modify (say)
the highpart of a TI pseudo or a V2DI pseudo independently
of the lowpart.  Modifying such highparts requires a reload
if the highpart ends up in the upper 64 bits of an FPR,
since RTL semantics do not allow the highpart of a single
hard register to be modified independently of the lowpart.

early-ra missed a check for this case, which meant that it
effectively treated an assignment to (subreg:DI (reg:TI R) 0)
as an assignment to the whole of R.

gcc/
PR target/118184
* config/aarch64/aarch64-early-ra.cc (allocno_assignment_is_rmw):
New function.
(early_ra::record_insn_defs): Mark the live range information as
untrustworthy if an assignment would change part of an allocno
but preserve the rest.

gcc/testsuite/
* gcc.dg/torture/pr118184.c: New test.

6 months agoDaily bump.
GCC Administrator [Wed, 22 Jan 2025 00:26:41 +0000 (00:26 +0000)] 
Daily bump.

6 months agoc++: Wrap force_target_expr in get_member_function_from_ptrfunc with save_expr [PR118509]
Jakub Jelinek [Tue, 21 Jan 2025 23:18:24 +0000 (00:18 +0100)] 
c++: Wrap force_target_expr in get_member_function_from_ptrfunc with save_expr [PR118509]

My October PR117259 fix to get_member_function_from_ptrfunc to use a
TARGET_EXPR rather than SAVE_EXPR unfortunately caused some regressions as
well as the following testcase shows.
What happens is that
get_member_function_from_ptrfunc -> build_base_path calls save_expr,
so since the PR117259 change in mnay cases it will call save_expr on
a TARGET_EXPR.  And, for some strange reason a TARGET_EXPR is not considered
an invariant, so we get a SAVE_EXPR wrapped around the TARGET_EXPR.
That SAVE_EXPR <TARGET_EXPR <...>> gets initially added only to the second
operand of ?:, so at that point it would still work fine during expansion.
But unfortunately an expression with that subexpression is handed to the
caller also through *instance_ptrptr = instance_ptr; and gets evaluated
once again when computing the first argument to the method.
So, essentially, we end up with
(TARGET_EXPR <D.2907, ...>, (... ? ... SAVE_EXPR <TARGET_EXPR <D.2907, ...>
 ... : ...)) (... SAVE_EXPR <TARGET_EXPR <D.2907, ...> ..., ...);
and while D.2907 is initialized during gimplification in the code dominating
everything that uses it, the extra temporary created for the SAVE_EXPR
is initialized only conditionally (if the ?: condition is true) but then
used unconditionally, so we get
pmf-4.C: In function ‘void foo(C, B*)’:
pmf-4.C:12:11: warning: ‘<anonymous>’ may be used uninitialized [-Wmaybe-uninitialized]
   12 |   (y->*x) ();
      |   ~~~~~~~~^~
pmf-4.C:12:11: note: ‘<anonymous>’ was declared here
   12 |   (y->*x) ();
      |   ~~~~~~~~^~
diagnostic and wrong-code issue too.

As the trunk fix to just treat TARGET_EXPR as invariant seems a little bit risky
and I'd like to get it tested on the trunk for a while, for 14.2.1 this patch
instead wraps those TARGET_EXPRs into SAVE_EXPRs.  Eventually that can be reverted
and the trunk fix backported.

2025-01-21  Jakub Jelinek  <jakub@redhat.com>

PR c++/118509
* typeck.cc (get_member_function_from_ptrfunc): Wrap force_target_expr
with save_expr.

* g++.dg/expr/pmf-4.C: New test.

6 months agoc++/modules: Propagate FNDECL_USED_AUTO when propagating deduced return types [PR118049]
Nathaniel Shead [Fri, 17 Jan 2025 10:29:08 +0000 (21:29 +1100)] 
c++/modules: Propagate FNDECL_USED_AUTO when propagating deduced return types [PR118049]

In the linked testcase, we're erroring because the declared return types
of the functions do not appear to match.  This is because when merging
the deduced return types for 'foo' in 'auto-5_b.C', we overwrote the
return type for the declaration with the deduced return type from
'auto-5_a.C' but neglected to track that we were originally declared
with 'auto'.

As a drive-by improvement to QOI, also add checks for if the deduced
return types do not match; this is currently useful because we do not
check the equivalence of the bodies of functions yet.

PR c++/118049

gcc/cp/ChangeLog:

* module.cc (trees_in::is_matching_decl): Propagate
FNDECL_USED_AUTO as well.

gcc/testsuite/ChangeLog:

* g++.dg/modules/auto-5_a.C: New test.
* g++.dg/modules/auto-5_b.C: New test.
* g++.dg/modules/auto-5_c.C: New test.
* g++.dg/modules/auto-6_a.H: New test.
* g++.dg/modules/auto-6_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
(cherry picked from commit f054c36c4fcb693e04411dc691ef4172479143d6)

6 months agoDaily bump.
GCC Administrator [Tue, 21 Jan 2025 00:23:29 +0000 (00:23 +0000)] 
Daily bump.

6 months agoUpdate gcc zh_CN.po
Joseph Myers [Mon, 20 Jan 2025 21:24:59 +0000 (21:24 +0000)] 
Update gcc zh_CN.po

* zh_CN.po: Update.

6 months agod: Fix failing test with 32-bit compiler [PR114434]
Iain Buclaw [Mon, 20 Jan 2025 19:01:03 +0000 (20:01 +0100)] 
d: Fix failing test with 32-bit compiler [PR114434]

Since the introduction of gdc.test/runnable/test23514.d, it's exposed an
incorrect compilation when adding a 64-bit constant to a link-time
address.  The current cast to size_t causes a loss of precision, which
can result in incorrect compilation.

PR d/114434

gcc/d/ChangeLog:

* expr.cc (ExprVisitor::visit (PtrExp *)): Get the offset as a
dinteger_t rather than a size_t.
(ExprVisitor::visit (SymOffExp *)): Likewise.

(cherry picked from commit 9ab38952a2033d6d4a8e31c3c4d2ab1a25a406c6)

6 months agoDaily bump.
GCC Administrator [Mon, 20 Jan 2025 00:23:17 +0000 (00:23 +0000)] 
Daily bump.

6 months agoi386: Reorder *movdi_internal ISA attribute by ascending alternative index
Uros Bizjak [Sun, 19 Jan 2025 21:29:21 +0000 (22:29 +0100)] 
i386: Reorder *movdi_internal ISA attribute by ascending alternative index

Reorder ISA attribute by ascending alternative index. No functional change.

gcc/ChangeLog:

* config/i386/i386.md (*movdi_internal): Reorder ISA attribute
by ascending alternative index.

(cherry picked from commit 9d4b1e3772547c8c836638d09fc9a84c3c73e277)

6 months agoi386: Disable SImode/DImode moves from/to mask regs without avx512bw [PR118067]
Uros Bizjak [Fri, 20 Dec 2024 15:16:15 +0000 (16:16 +0100)] 
i386: Disable SImode/DImode moves from/to mask regs without avx512bw [PR118067]

SImode and DImode moves from/to mask registers are valid only with AVX512BW,
so mark relevant alternatives in *movsi_internal and *movdi_internal as such.

Even with the patch, the testcase still fails, but now with:

pr118067.c: In function ‘foo’:
pr118067.c:13:1: internal compiler error: maximum number of generated reload insns per insn achieved (90)
   13 | }
      | ^
0x2c3b581 internal_error(char const*, ...)
        ../../git/gcc/gcc/diagnostic-global-context.cc:517
0xb68938 lra_constraints(bool)
        ../../git/gcc/gcc/lra-constraints.cc:5411
0xb51a0d lra(_IO_FILE*, int)
        ../../git/gcc/gcc/lra.cc:2449
0xaf9f4d do_reload
        ../../git/gcc/gcc/ira.cc:5977
0xafa462 execute
        ../../git/gcc/gcc/ira.cc:6165

PR target/118067

gcc/ChangeLog:

* config/i386/i386.md (*movdi_internal):
Disable alternatives from/to mask registers without AVX512BW.
(*movsi_internal): Ditto.

(cherry picked from commit 219ddae16f9d724baeff86934f8981aa5ef7b95f)

6 months agoc++: Friend classes don't shadow enclosing template class paramater [PR118255]
Simon Martin [Sun, 5 Jan 2025 09:36:47 +0000 (10:36 +0100)] 
c++: Friend classes don't shadow enclosing template class paramater [PR118255]

We currently reject the following code

=== code here ===
template <int non_template> struct S { friend class non_template; };
class non_template {};
S<0> s;
=== code here ===

While EDG agrees with the current behaviour, clang and MSVC don't (see
https://godbolt.org/z/69TGaabhd), and I believe that this code is valid,
since the friend clause does not actually declare a type, so it cannot
shadow anything. The fact that we didn't error out if the non_template
class was declared before S backs this up as well.

This patch fixes this by skipping the call to check_template_shadow for
hidden bindings.

PR c++/118255

gcc/cp/ChangeLog:

* name-lookup.cc (pushdecl): Don't call check_template_shadow
for hidden bindings.

gcc/testsuite/ChangeLog:

* g++.dg/lookup/pr99116-1.C: Adjust test expectation.
* g++.dg/template/friend84.C: New test.

(cherry picked from commit b5a069203fc074ab75d994c4a7e0f2db6a0a00fd)

6 months agoDaily bump.
GCC Administrator [Sun, 19 Jan 2025 00:23:25 +0000 (00:23 +0000)] 
Daily bump.

6 months agoDaily bump.
GCC Administrator [Sat, 18 Jan 2025 00:23:38 +0000 (00:23 +0000)] 
Daily bump.

6 months agod: Fix ICE in expand_d_format when diagnosing empty enum [PR117115]
Iain Buclaw [Fri, 17 Jan 2025 19:10:39 +0000 (20:10 +0100)] 
d: Fix ICE in expand_d_format when diagnosing empty enum [PR117115]

This was fixed in upstream dmd, and merged in r15-6824. Backport the
individual fix from the upstream merge for releases/gcc-14.

PR d/117115

gcc/testsuite/ChangeLog:

* gdc.dg/pr117115.d: New test.

(cherry picked from commit 975c4f1a5de4ede89ee9499cd1a73d613a4aeae4)

6 months agoAVR: Use INT_N to built-in define __int24.
Georg-Johann Lay [Thu, 16 Jan 2025 18:43:27 +0000 (19:43 +0100)] 
AVR: Use INT_N to built-in define __int24.

This patch uses the INT_N interface to define __int24 in avr-modes.def.

Since the testsuite uses -Wpedantic and __int24 is a C/C++ extension,
uses of __int24 and __uint24 is now marked as __extension__.

PR target/118329
gcc/
* config/avr/avr-modes.def: Add INT_N (PSI, 24).
* config/avr/avr.cc (avr_init_builtin_int24)
<__int24>: Remove definition.
<__uint24>: Adjust definition to INT_N interface.
gcc/testsuite/
* gcc.target/avr/torture/get-mem.c: (__int24, __uint24):
Add __extension__ to respective typedefs.
* gcc.target/avr/torture/set-mem.c: Same.
* gcc.target/avr/torture/int24-mul.c: Same.
* gcc.target/avr/torture/pr109907-2.c: Same.
* gcc.target/avr/torture/pr61443.c: Same.
* gcc.target/avr/torture/pr63633-ice-mult.c: Same.

(cherry picked from commit 6580b89957ccabbb5aaf43736b36b9bd399fbc13)