[gcc r15-4103] Handle non-grouped stores as single-lane SLP: adjust 'gcc.dg/vect/slp-26.c', GCN

2024-10-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:b137e4bbcc488b44a037baad62a8da90659d7468

commit r15-4103-gb137e4bbcc488b44a037baad62a8da90659d7468
Author: Thomas Schwinge 
Date:   Thu Oct 3 12:52:30 2024 +0200

Handle non-grouped stores as single-lane SLP: adjust 
'gcc.dg/vect/slp-26.c', GCN

As of commit d34cda720988674bcf8a24267c9e1ec61335d6de
"Handle non-grouped stores as single-lane SLP", we see for
'--target=amdgcn-amdhsa' (tested '-march=gfx908', '-march=gfx1100'):

PASS: gcc.dg/vect/slp-26.c (test for excess errors)
PASS: gcc.dg/vect/slp-26.c execution test
PASS: gcc.dg/vect/slp-26.c scan-tree-dump-times vect "vectorized 1 
loops" 1
[-PASS:-]{+FAIL:+} gcc.dg/vect/slp-26.c scan-tree-dump-times vect 
"vectorizing stmts using SLP" 1

gcc.dg/vect/slp-26.c: pattern found 2 times

Apply the same change to 'amdgcn-*-*' as done for 'riscv_v'.

gcc/testsuite/
* gcc.dg/vect/slp-26.c: Adjust GCN.

Diff:
---
 gcc/testsuite/gcc.dg/vect/slp-26.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/slp-26.c 
b/gcc/testsuite/gcc.dg/vect/slp-26.c
index cdb5d9c694be..23917474ddc1 100644
--- a/gcc/testsuite/gcc.dg/vect/slp-26.c
+++ b/gcc/testsuite/gcc.dg/vect/slp-26.c
@@ -50,5 +50,5 @@ int main (void)
 /* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect" { target { 
! { mips_msa || { amdgcn-*-* || { riscv_v || loongarch_sx } } } } } } } */
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { 
mips_msa || { amdgcn-*-* || { riscv_v || loongarch_sx } } } } } } */
 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { 
target { ! { mips_msa || { amdgcn-*-* || { riscv_v || loongarch_sx } } } } } } 
} */
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { 
target { mips_msa || { amdgcn-*-* || loongarch_sx } } } } } */
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { 
target riscv_v } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { 
target { mips_msa || loongarch_sx } } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { 
target { riscv_v || amdgcn-*-* } } } } */


[gcc r15-4102] nvptx: Re-enable 'gcc.misc-tests/options.exp'

2024-10-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:e966502553c7db5dffb53ae6583b4ed6b3296839

commit r15-4102-ge966502553c7db5dffb53ae6583b4ed6b3296839
Author: Thomas Schwinge 
Date:   Mon Nov 28 12:59:52 2022 +0100

nvptx: Re-enable 'gcc.misc-tests/options.exp'

..., just conditionalize its profiling test (as done elsewhere).  The
re-enabled test cases all PASS.

For the record, for example for GCN target, this causes:

 Running [...]/gcc/testsuite/gcc.misc-tests/options.exp ...
-PASS: compiler driver --coverage option(s)
 PASS: compiler driver -fdump-ipa-all-address option(s)
 PASS: compiler driver -fdump-ipa-all-alias option(s)
 PASS: compiler driver -fdump-ipa-all-all option(s)

That was:

Running [...]/gcc/testsuite/gcc.misc-tests/options.exp ...
Executing on host: [xgcc] [...] --coverage [...]
[...]
ld: error: undefined symbol: __gcov_exit
>>> referenced by /tmp/ccRGdqjA.o:(_sub_D_00100_1)
>>> referenced by /tmp/ccRGdqjA.o:(_sub_D_00100_1)
collect2: error: ld returned 1 exit status
compiler exited with status 1
output is:
[...]
PASS: compiler driver --coverage option(s)

..., so that's nothing to worry about.

gcc/testsuite/
* gcc.misc-tests/options.exp: Re-enable for nvptx.

Diff:
---
 gcc/testsuite/gcc.misc-tests/options.exp | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/gcc/testsuite/gcc.misc-tests/options.exp 
b/gcc/testsuite/gcc.misc-tests/options.exp
index 6e6e40c183d5..0c2ba6781cd3 100644
--- a/gcc/testsuite/gcc.misc-tests/options.exp
+++ b/gcc/testsuite/gcc.misc-tests/options.exp
@@ -21,12 +21,6 @@
 
 load_lib gcc-defs.exp
 
-# disable for non-profile targets explitly, rather than
-# rely on check-effective target.  We're explicitly trying to check
-# profiling works, and if it doesn't check-effective-target will
-# simply skip the tests, rather than have this test shout at us.
-if [ istarget "nvptx-*-*" ] { return 0 }
-
 # These tests don't run runtest_file_p consistently if it
 # doesn't return the same values, so disable parallelization
 # of this *.exp file.  The first parallel runtest to reach
@@ -73,7 +67,9 @@ proc check_for_all_options {language gcc_options 
compiler_pattern as_pattern ld_
 pass $test
 }
 
-check_for_all_options c {--coverage} {-fprofile-arcs -ftest-coverage} {} 
{-lgcov}
+if { [check_profiling_available "-fprofile-arcs"] } {
+check_for_all_options c {--coverage} {-fprofile-arcs -ftest-coverage} {} 
{-lgcov}
+}
 
 proc get_dump_flags {} {
 set res [list]


[gcc r15-4101] nvptx: Re-enable all variants of 'c-c++-common/torture/complex-sign-mixed-add.c', 'c-c++-common/tort

2024-10-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:8095cb55255eca1bb2fb833637a4a927bc34e63f

commit r15-4101-g8095cb55255eca1bb2fb833637a4a927bc34e63f
Author: Thomas Schwinge 
Date:   Mon Nov 28 10:37:26 2022 +0100

nvptx: Re-enable all variants of 
'c-c++-common/torture/complex-sign-mixed-add.c', 
'c-c++-common/torture/complex-sign-mixed-sub.c'

PASS with:

$ ptxas --version
ptxas: NVIDIA (R) Ptx optimizing assembler
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sun_Sep__9_21:06:46_CDT_2018
Cuda compilation tools, release 10.0, V10.0.145

..., and execution with 'Driver Version: 361.93.02'.

gcc/testsuite/
* c-c++-common/torture/complex-sign-mixed-add.c: Re-enable all
variants for nvptx.
* c-c++-common/torture/complex-sign-mixed-sub.c: Likewise.

Diff:
---
 gcc/testsuite/c-c++-common/torture/complex-sign-mixed-add.c | 1 -
 gcc/testsuite/c-c++-common/torture/complex-sign-mixed-sub.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-add.c 
b/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-add.c
index 36d305baf534..c12ab6f1d535 100644
--- a/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-add.c
+++ b/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-add.c
@@ -2,7 +2,6 @@
addition.  */
 /* { dg-do run } */
 /* { dg-options "-std=gnu99" { target c } } */
-/* { dg-skip-if "ptx can elide zero additions" { "nvptx-*-*" } { "-O0" } { "" 
} } */
 /* { dg-skip-if "double support is incomplete" { "avr-*-*" } } */
 
 #include "complex-sign.h"
diff --git a/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-sub.c 
b/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-sub.c
index 63c75dfdff28..dee2aadb65e8 100644
--- a/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-sub.c
+++ b/gcc/testsuite/c-c++-common/torture/complex-sign-mixed-sub.c
@@ -2,7 +2,6 @@
subtraction.  */
 /* { dg-do run } */
 /* { dg-options "-std=gnu99" { target c } } */
-/* { dg-skip-if "ptx can elide zero additions" { "nvptx-*-*" } { "-O0" } { "" 
} } */
 /* { dg-skip-if "double support is incomplete" { "avr-*-*" } } */
 
 #include "complex-sign.h"


[gcc r15-4100] nvptx: Re-enable 'gcc.dg/special/weak-2.c'

2024-10-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:81dcca1c24835c6c9e06e6aa917c40e0f4b1fdd5

commit r15-4100-g81dcca1c24835c6c9e06e6aa917c40e0f4b1fdd5
Author: Thomas Schwinge 
Date:   Mon Nov 28 10:37:26 2022 +0100

nvptx: Re-enable 'gcc.dg/special/weak-2.c'

PASSes with:

$ ptxas --version
ptxas: NVIDIA (R) Ptx optimizing assembler
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sun_Sep__9_21:06:46_CDT_2018
Cuda compilation tools, release 10.0, V10.0.145

..., and execution with 'Driver Version: 361.93.02'.

gcc/testsuite/
* gcc.dg/special/weak-2.c: Re-enable for nvptx.

Diff:
---
 gcc/testsuite/gcc.dg/special/weak-2.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/special/weak-2.c 
b/gcc/testsuite/gcc.dg/special/weak-2.c
index b8133e2d7d95..b93a8ef9a529 100644
--- a/gcc/testsuite/gcc.dg/special/weak-2.c
+++ b/gcc/testsuite/gcc.dg/special/weak-2.c
@@ -2,10 +2,6 @@
 /* { dg-require-weak "" } */
 /* { dg-additional-sources "weak-2a.c weak-2b.c" } */
 
-/* NVPTX's implementation of weak is broken when a strong symbol is in
-   a later object file than the weak definition.   */
-/* { dg-skip-if "" { "nvptx-*-*" } } */
-
 #include 
 
 extern int foo(void);


[gcc r15-4099] nvptx: Re-enable all variants of 'gcc.c-torture/execute/20020529-1.c'

2024-10-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:dcae798b26864d12e43840f3cae75c01eaa11eae

commit r15-4099-gdcae798b26864d12e43840f3cae75c01eaa11eae
Author: Thomas Schwinge 
Date:   Mon Nov 28 10:37:26 2022 +0100

nvptx: Re-enable all variants of 'gcc.c-torture/execute/20020529-1.c'

Generally PASSes with:

$ ptxas --version
ptxas: NVIDIA (R) Ptx optimizing assembler
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sun_Sep__9_21:06:46_CDT_2018
Cuda compilation tools, release 10.0, V10.0.145

..., and execution with 'Driver Version: 361.93.02'.

Only the '-O1' execution test FAILs (pre-existing; to be analyzed later):

nvptx-run: error getting kernel result: an illegal memory access was 
encountered (CUDA_ERROR_ILLEGAL_ADDRESS, 700)

gcc/testsuite/
* gcc.c-torture/execute/20020529-1.c: Re-enable all variants for
nvptx.

Diff:
---
 gcc/testsuite/gcc.c-torture/execute/20020529-1.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/gcc/testsuite/gcc.c-torture/execute/20020529-1.c 
b/gcc/testsuite/gcc.c-torture/execute/20020529-1.c
index d34fec160fab..545f4709638e 100644
--- a/gcc/testsuite/gcc.c-torture/execute/20020529-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20020529-1.c
@@ -12,10 +12,6 @@
forced a splitter through the output pattern "#", but there was no
matching splitter.  */
 
-/* The ptx assembler appears to clobber 'b' inside foo during the f1 call.
-   Reported to nvidia 2016-05-18.  */
-/* { dg-skip-if "PTX assembler bug" { nvptx-*-* } { "-O0" } { "" } } */
-
 void abort (void);
 void exit (int);


[gcc r15-4098] nvptx: Disable effective-target 'freestanding'

2024-10-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:65c7616c251a6697134b2a3ac7fe6460d308d2ed

commit r15-4098-g65c7616c251a6697134b2a3ac7fe6460d308d2ed
Author: Thomas Schwinge 
Date:   Mon Nov 28 13:49:06 2022 +0100

nvptx: Disable effective-target 'freestanding'

After 2014's commit 157e859ffe3b5d43db1e19475711c1a3d21ab57a "remove 
picochip",
the effective-target 'freestanding' (later) was only ever used for nvptx.
However, the relevant I/O library functions have long been implemented in 
nvptx
newlib.

These test cases generally PASS, just a few need to get XFAILed; see

,
and then supposedly
 
for
description of the non-standard PTX 'vprintf' return value:

> Unlike the C-standard 'printf()', which returns the number of characters
> printed, CUDA's 'printf()' returns the number of arguments parsed. If no
> arguments follow the format string, 0 is returned. If the format string is
> NULL, -1 is returned. If an internal error occurs, -2 is returned.

(I've tried a few variants to confirm that PTX 'vprintf' -- which 
supposedly is
underlying the CUDA 'printf' -- is what's implementing this behavior.)
Probably, we ought to fix that up in nvptx newlib.

gcc/testsuite/
* gcc.c-torture/execute/printf-1.c: XFAIL for nvptx.
* gcc.c-torture/execute/printf-chk-1.c: Likewise.
* gcc.c-torture/execute/vprintf-1.c: Likewise.
* gcc.c-torture/execute/vprintf-chk-1.c: Likewise.
* lib/target-supports.exp (check_effective_target_freestanding):
Disable for nvptx.

Diff:
---
 gcc/testsuite/gcc.c-torture/execute/printf-1.c  | 1 +
 gcc/testsuite/gcc.c-torture/execute/printf-chk-1.c  | 1 +
 gcc/testsuite/gcc.c-torture/execute/vprintf-1.c | 1 +
 gcc/testsuite/gcc.c-torture/execute/vprintf-chk-1.c | 1 +
 gcc/testsuite/lib/target-supports.exp   | 3 ---
 5 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/gcc.c-torture/execute/printf-1.c 
b/gcc/testsuite/gcc.c-torture/execute/printf-1.c
index 654e62766a85..e1201365c1f5 100644
--- a/gcc/testsuite/gcc.c-torture/execute/printf-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/printf-1.c
@@ -1,4 +1,5 @@
 /* { dg-skip-if "requires io" { freestanding } }  */
+/* { dg-xfail-run-if {unexpected PTX 'vprintf' return value} { nvptx-*-* } } */
 
 #include 
 #include 
diff --git a/gcc/testsuite/gcc.c-torture/execute/printf-chk-1.c 
b/gcc/testsuite/gcc.c-torture/execute/printf-chk-1.c
index aab43062baef..6418957edae4 100644
--- a/gcc/testsuite/gcc.c-torture/execute/printf-chk-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/printf-chk-1.c
@@ -1,4 +1,5 @@
 /* { dg-skip-if "requires io" { freestanding } }  */
+/* { dg-xfail-run-if {unexpected PTX 'vprintf' return value} { nvptx-*-* } } */
 
 #include 
 #include 
diff --git a/gcc/testsuite/gcc.c-torture/execute/vprintf-1.c 
b/gcc/testsuite/gcc.c-torture/execute/vprintf-1.c
index 259397ebda39..0fb1ade94e0b 100644
--- a/gcc/testsuite/gcc.c-torture/execute/vprintf-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/vprintf-1.c
@@ -1,4 +1,5 @@
 /* { dg-skip-if "requires io" { freestanding } }  */
+/* { dg-xfail-run-if {unexpected PTX 'vprintf' return value} { nvptx-*-* } } */
 
 #ifndef test
 #include 
diff --git a/gcc/testsuite/gcc.c-torture/execute/vprintf-chk-1.c 
b/gcc/testsuite/gcc.c-torture/execute/vprintf-chk-1.c
index 04ecc4df4d93..7ea3617e184c 100644
--- a/gcc/testsuite/gcc.c-torture/execute/vprintf-chk-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/vprintf-chk-1.c
@@ -1,4 +1,5 @@
 /* { dg-skip-if "requires io" { freestanding } }  */
+/* { dg-xfail-run-if {unexpected PTX 'vprintf' return value} { nvptx-*-* } } */
 
 #ifndef test
 #include 
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 459af8e58c66..1c9bbf64817a 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -859,9 +859,6 @@ proc check_profiling_available { test_what } {
 # in Section 4 of C99 standard. Effectively, it is a target which supports no
 # extra headers or libraries other than what is considered essential.
 proc check_effective_target_freestanding { } {
-if { [istarget nvptx-*-*] } {
-   return 1
-}
 return 0
 }


[gcc r15-4097] nvptx: Re-enable "ptxas times out" test cases

2024-10-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:cb633e5cbd422d5a5d98b17d435abad976a9d9ca

commit r15-4097-gcb633e5cbd422d5a5d98b17d435abad976a9d9ca
Author: Thomas Schwinge 
Date:   Mon Nov 28 10:05:06 2022 +0100

nvptx: Re-enable "ptxas times out" test cases

These are all quick to compile and generally PASS with:

$ ptxas --version
ptxas: NVIDIA (R) Ptx optimizing assembler
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sun_Sep__9_21:06:46_CDT_2018
Cuda compilation tools, release 10.0, V10.0.145

Only 'gcc.c-torture/compile/limits-fndefn.c' at '-O0' still has an issue, as
indicated.  Working around that with '-Wa,--no-verify', for now.

gcc/testsuite/
* gcc.c-torture/compile/920501-4.c: Re-enable nvptx
"ptxas times out" variants.
* gcc.c-torture/compile/921011-1.c: Likewise.
* gcc.c-torture/compile/pr34334.c: Likewise.
* gcc.c-torture/compile/pr37056.c: Likewise.
* gcc.c-torture/compile/pr39423-1.c: Likewise.
* gcc.c-torture/compile/pr49049.c: Likewise.
* gcc.c-torture/compile/pr59417.c: Likewise.
* gcc.c-torture/compile/limits-fndefn.c: Likewise.
Specify '-Wa,--no-verify' for nvptx '-O0'.

Diff:
---
 gcc/testsuite/gcc.c-torture/compile/920501-4.c  | 1 -
 gcc/testsuite/gcc.c-torture/compile/921011-1.c  | 2 --
 gcc/testsuite/gcc.c-torture/compile/limits-fndefn.c | 6 +-
 gcc/testsuite/gcc.c-torture/compile/pr34334.c   | 1 -
 gcc/testsuite/gcc.c-torture/compile/pr37056.c   | 1 -
 gcc/testsuite/gcc.c-torture/compile/pr39423-1.c | 1 -
 gcc/testsuite/gcc.c-torture/compile/pr49049.c   | 2 --
 gcc/testsuite/gcc.c-torture/compile/pr59417.c   | 1 -
 8 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/gcc/testsuite/gcc.c-torture/compile/920501-4.c 
b/gcc/testsuite/gcc.c-torture/compile/920501-4.c
index 1924a708d098..cc6e6820af53 100644
--- a/gcc/testsuite/gcc.c-torture/compile/920501-4.c
+++ b/gcc/testsuite/gcc.c-torture/compile/920501-4.c
@@ -1,5 +1,4 @@
 /* { dg-do assemble } */
-/* { dg-skip-if "ptxas times out" { nvptx-*-* } { "-O1" } { "" } } */
 /* { dg-skip-if "Array too big" { "pdp11-*-*" } { "-mint32" } } */
 /* { dg-require-stack-size "8196*4" } */
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/921011-1.c 
b/gcc/testsuite/gcc.c-torture/compile/921011-1.c
index 5955b4c527dc..6cc707dc74c6 100644
--- a/gcc/testsuite/gcc.c-torture/compile/921011-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/921011-1.c
@@ -1,5 +1,3 @@
-/* { dg-skip-if "ptxas times out" { nvptx-*-* } { "-O1" } { "" } } */
-
 void
 fun (nb)
  int nb;
diff --git a/gcc/testsuite/gcc.c-torture/compile/limits-fndefn.c 
b/gcc/testsuite/gcc.c-torture/compile/limits-fndefn.c
index 532047354938..5d2c41d05a26 100644
--- a/gcc/testsuite/gcc.c-torture/compile/limits-fndefn.c
+++ b/gcc/testsuite/gcc.c-torture/compile/limits-fndefn.c
@@ -1,6 +1,10 @@
 /* { dg-skip-if "too complex for avr" { avr-*-* } } */
-/* { dg-skip-if "ptxas times out" { nvptx-*-* } } */
 /* { dg-skip-if "no chance for bpf" { bpf-*-* } } */
+/* { dg-additional-options -Wa,--no-verify { target { nvptx-*-* && { ! 
__OPTIMIZE__ } } } }
+   For the very long list of formal parameters, the nvptx back end generates
+   very much boilerplate code.  Without optimizations enabled, that doesn't get
+   cleaned up, and 'ptxas' runs into timeout or gets OOM-killed after a few
+   minutes.  */
 /* { dg-timeout-factor 4.0 } */
 #define LIM1(x) x##0, x##1, x##2, x##3, x##4, x##5, x##6, x##7, x##8, x##9,
 #define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr34334.c 
b/gcc/testsuite/gcc.c-torture/compile/pr34334.c
index b9337e995ede..37f9f6b6a8ba 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr34334.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr34334.c
@@ -1,4 +1,3 @@
-/* { dg-skip-if "ptxas times out" { nvptx-*-* } { "*" } { "-O0" } } */
 __extension__ typedef __SIZE_TYPE__ size_t;
 __extension__ typedef long long int __quad_t;
 __extension__ typedef unsigned int __mode_t;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37056.c 
b/gcc/testsuite/gcc.c-torture/compile/pr37056.c
index e709fdc1ffb2..f9285e2c7843 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr37056.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr37056.c
@@ -1,4 +1,3 @@
-/* { dg-skip-if "ptxas times out" { nvptx-*-* } { "-O2" "-Os" } { "" } } */
 extern void abort (void);
 
 static union {
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39423-1.c 
b/gcc/testsuite/gcc.c-torture/compile/pr39423-1.c
index c604738b9cb6..34ebb66381a1 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr39423-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr39423-1.c
@@ -1,5 +1,4 @@
 /* PR target/39423 */
-/* { dg-skip-if "ptxas times out" { nvptx-*-* } { "-O2" } { "" } } */
 
 int
 foo (const char *name, int nmlen, char *flags)
diff --git a/gcc/testsuite/gc

[gcc r15-4096] nvptx: Re-enable 'gcc.c-torture/compile/20080721-1.c'

2024-10-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:b0677101d40e384a13eec14ee270f457bfe5ac05

commit r15-4096-gb0677101d40e384a13eec14ee270f457bfe5ac05
Author: Thomas Schwinge 
Date:   Mon Nov 28 10:37:26 2022 +0100

nvptx: Re-enable 'gcc.c-torture/compile/20080721-1.c'

PASSes with:

$ ptxas --version
ptxas: NVIDIA (R) Ptx optimizing assembler
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sun_Sep__9_21:06:46_CDT_2018
Cuda compilation tools, release 10.0, V10.0.145

gcc/testsuite/
* gcc.c-torture/compile/20080721-1.c: Re-enable for nvptx.

Diff:
---
 gcc/testsuite/gcc.c-torture/compile/20080721-1.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/gcc/testsuite/gcc.c-torture/compile/20080721-1.c 
b/gcc/testsuite/gcc.c-torture/compile/20080721-1.c
index 6c928f55ca10..35ef352bc6da 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20080721-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20080721-1.c
@@ -1,4 +1,3 @@
-/* { dg-skip-if "can't read function data" { nvptx-*-* } } */
 void foo(void);
 void bar(void);


[gcc r15-3541] Match: Fix ordered and nonequal: Fix 'gcc.dg/opt-ordered-and-nonequal-1.c' re 'LOGICAL_OP_NON_SHORT_

2024-09-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:00b35424cbdd0985e87e6de2c381ee3c3f7fdc21

commit r15-3541-g00b35424cbdd0985e87e6de2c381ee3c3f7fdc21
Author: Thomas Schwinge 
Date:   Mon Sep 9 08:39:10 2024 +0200

Match: Fix ordered and nonequal: Fix 'gcc.dg/opt-ordered-and-nonequal-1.c' 
re 'LOGICAL_OP_NON_SHORT_CIRCUIT' [PR116635]

Fix up to make 'gcc.dg/opt-ordered-and-nonequal-1.c' of
commit 91421e21e8f0f05f440174b8de7a43a311700e08
"Match: Fix ordered and nonequal" work for default
'LOGICAL_OP_NON_SHORT_CIRCUIT == false' configurations.

PR testsuite/116635
gcc/testsuite/
* gcc.dg/opt-ordered-and-nonequal-1.c: Fix re
'LOGICAL_OP_NON_SHORT_CIRCUIT'.

Diff:
---
 gcc/testsuite/gcc.dg/opt-ordered-and-nonequal-1.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/opt-ordered-and-nonequal-1.c 
b/gcc/testsuite/gcc.dg/opt-ordered-and-nonequal-1.c
index 6d102c2bd0c8..d61c3322214b 100644
--- a/gcc/testsuite/gcc.dg/opt-ordered-and-nonequal-1.c
+++ b/gcc/testsuite/gcc.dg/opt-ordered-and-nonequal-1.c
@@ -1,5 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -fdump-tree-forwprop1-details" } */
+/* Make this work for default 'LOGICAL_OP_NON_SHORT_CIRCUIT == false' 
configurations:
+   { dg-additional-options "--param logical-op-non-short-circuit=1" } */
 
 int is_ordered_and_nonequal_sh_1 (float a, float b)
 {


[gcc r15-3486] Add 'g++.target/nvptx/alias-g++.dg_init_dtor2-1.C'

2024-09-05 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:a1865fd33897bc6c6e0109df0a12ee73ce386315

commit r15-3486-ga1865fd33897bc6c6e0109df0a12ee73ce386315
Author: Thomas Schwinge 
Date:   Wed Jul 17 18:02:50 2024 +0200

Add 'g++.target/nvptx/alias-g++.dg_init_dtor2-1.C'

... as one minimized example for the issue that with nvptx '-malias' enabled
(as implemented in commit f8b15e177155960017ac0c5daef8780d1127f91c
"[nvptx] Use .alias directive for mptx >= 6.3"), there are hundreds of
instances of link-time 'unresolved symbol [alias]' across the C++ test 
suite,
which are regressions compared to a test run with (default) '-mno-alias'.

PR target/104957
gcc/testsuite/
* g++.target/nvptx/alias-g++.dg_init_dtor2-1.C: Add.

Diff:
---
 .../g++.target/nvptx/alias-g++.dg_init_dtor2-1.C   | 33 ++
 1 file changed, 33 insertions(+)

diff --git a/gcc/testsuite/g++.target/nvptx/alias-g++.dg_init_dtor2-1.C 
b/gcc/testsuite/g++.target/nvptx/alias-g++.dg_init_dtor2-1.C
new file mode 100644
index 000..747656d51d6
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/alias-g++.dg_init_dtor2-1.C
@@ -0,0 +1,33 @@
+/* Reduced from 'g++.dg/init/dtor2.C'.  */
+
+/* { dg-do compile } */
+/* { dg-add-options nvptx_alias_ptx } */
+/* { dg-additional-options -save-temps } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+
+struct B
+{
+  ~B();
+};
+
+B::~B () {
+}
+
+int main()
+{
+  B b;
+  return 0;
+}
+
+/* { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DECL: 
_ZN1BD2Ev$} 1 } }
+   { dg-final { scan-assembler-times {(?n)^\.visible \.func _ZN1BD2Ev 
\(\.param\.u64 %in_ar0\);$} 1 } }
+   { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DEF: 
_ZN1BD2Ev$} 1 } }
+   { dg-final { scan-assembler-times {(?n)^\.visible \.func _ZN1BD2Ev 
\(\.param\.u64 %in_ar0\)$} 1 } } */
+
+/* { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DECL: 
_ZN1BD1Ev$} 1 } }
+   { dg-final { scan-assembler-times {(?n)^\.visible \.func _ZN1BD1Ev 
\(\.param\.u64 %in_ar0\);$} 1 } }
+   { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DEF: 
_ZN1BD1Ev$} 1 { xfail *-*-* } } }
+   { dg-final { scan-assembler-times {(?n)^\.alias _ZN1BD1Ev,_ZN1BD2Ev;$} 1 } 
} */
+
+/* { dg-final { scan-assembler-times {(?n)\tcall _ZN1BD1Ev, \(} 1 } }
+   { dg-final { scan-assembler-times {(?n)\tcall _ZN1BD2Ev, \(} 0 } } */


[gcc r15-3487] nvptx: Emit DECL and DEF linker markers for aliases [PR104957]

2024-09-05 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:8f5aade15e595b288a2c4ec60ddde8dc80df1a80

commit r15-3487-g8f5aade15e595b288a2c4ec60ddde8dc80df1a80
Author: Thomas Schwinge 
Date:   Wed Jul 17 23:56:25 2024 +0200

nvptx: Emit DECL and DEF linker markers for aliases [PR104957]

With nvptx '-malias' enabled (as implemented in
commit f8b15e177155960017ac0c5daef8780d1127f91c
"[nvptx] Use .alias directive for mptx >= 6.3"), the C++ front end in 
certain
cases does 'write_fn_proto' before an eventual 'alias' attribute has been
added.  In that case, we do emit (via 'write_fn_marker') a DECL linker 
marker,
but then never emit a corresponding DEF linker marker for the alias.  This
causes hundreds of instances of link-time 'unresolved symbol [alias]' across
the C++ test suite, which are regressions compared to a test run with 
(default)
'-mno-alias' (in which case the respective functions get duplicated).

PR target/104957
gcc/
* config/nvptx/nvptx.cc (write_fn_proto_1): Revert 2022-03-22
change; 'write_fn_marker' also for alias DECL.
(nvptx_asm_output_def_from_decls): 'write_fn_marker' for alias
DEF.
gcc/testsuite/
* g++.target/nvptx/alias-g++.dg_init_dtor2-1.C: Un-XFAIL.
* gcc.target/nvptx/alias-1.c: Likewise.
* gcc.target/nvptx/alias-3.c: Likewise.
* gcc.target/nvptx/alias-to-alias-1.c: Likewise.

Diff:
---
 gcc/config/nvptx/nvptx.cc  | 6 --
 gcc/testsuite/g++.target/nvptx/alias-g++.dg_init_dtor2-1.C | 4 ++--
 gcc/testsuite/gcc.target/nvptx/alias-1.c   | 4 ++--
 gcc/testsuite/gcc.target/nvptx/alias-3.c   | 4 ++--
 gcc/testsuite/gcc.target/nvptx/alias-to-alias-1.c  | 8 
 5 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 144b8d0c874..4a7c64f05eb 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -997,8 +997,7 @@ static void
 write_fn_proto_1 (std::stringstream &s, bool is_defn,
  const char *name, const_tree decl, bool force_public)
 {
-  if (lookup_attribute ("alias", DECL_ATTRIBUTES (decl)) == NULL)
-write_fn_marker (s, is_defn, TREE_PUBLIC (decl) || force_public, name);
+  write_fn_marker (s, is_defn, TREE_PUBLIC (decl) || force_public, name);
 
   /* PTX declaration.  */
   if (DECL_EXTERNAL (decl))
@@ -7627,6 +7626,9 @@ nvptx_asm_output_def_from_decls (FILE *stream, tree name, 
tree value)
   fputs (s.str ().c_str (), stream);
 
   tree id = DECL_ASSEMBLER_NAME (name);
+  std::stringstream s_def;
+  write_fn_marker (s_def, true, TREE_PUBLIC (name), IDENTIFIER_POINTER (id));
+  fputs (s_def.str ().c_str (), stream);
   NVPTX_ASM_OUTPUT_DEF (stream, IDENTIFIER_POINTER (id),
IDENTIFIER_POINTER (value));
 }
diff --git a/gcc/testsuite/g++.target/nvptx/alias-g++.dg_init_dtor2-1.C 
b/gcc/testsuite/g++.target/nvptx/alias-g++.dg_init_dtor2-1.C
index 747656d51d6..a30f99af308 100644
--- a/gcc/testsuite/g++.target/nvptx/alias-g++.dg_init_dtor2-1.C
+++ b/gcc/testsuite/g++.target/nvptx/alias-g++.dg_init_dtor2-1.C
@@ -1,6 +1,6 @@
 /* Reduced from 'g++.dg/init/dtor2.C'.  */
 
-/* { dg-do compile } */
+/* { dg-do link } */
 /* { dg-add-options nvptx_alias_ptx } */
 /* { dg-additional-options -save-temps } */
 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
@@ -26,7 +26,7 @@ int main()
 
 /* { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DECL: 
_ZN1BD1Ev$} 1 } }
{ dg-final { scan-assembler-times {(?n)^\.visible \.func _ZN1BD1Ev 
\(\.param\.u64 %in_ar0\);$} 1 } }
-   { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DEF: 
_ZN1BD1Ev$} 1 { xfail *-*-* } } }
+   { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DEF: 
_ZN1BD1Ev$} 1 } }
{ dg-final { scan-assembler-times {(?n)^\.alias _ZN1BD1Ev,_ZN1BD2Ev;$} 1 } 
} */
 
 /* { dg-final { scan-assembler-times {(?n)\tcall _ZN1BD1Ev, \(} 1 } }
diff --git a/gcc/testsuite/gcc.target/nvptx/alias-1.c 
b/gcc/testsuite/gcc.target/nvptx/alias-1.c
index 0fb06495f67..f2aeff36e69 100644
--- a/gcc/testsuite/gcc.target/nvptx/alias-1.c
+++ b/gcc/testsuite/gcc.target/nvptx/alias-1.c
@@ -28,9 +28,9 @@ main (void)
{ dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DEF: __f$} 
1 } }
{ dg-final { scan-assembler-times {(?n)^\.visible \.func __f$} 1 } } */
 
-/* { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DECL: f$} 
1 { xfail *-*-* } } }
+/* { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DECL: f$} 
1 } }
{ dg-final { scan-assembler-times {(?n)^\.visible \.func f;$} 1 } }
-   { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DEF: f$} 1 
{ xfail *-*-* } } }
+   { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DEF: f$} 1 
} }
{

[gcc r15-3485] Enhance 'gcc.target/nvptx/alias-*.c' assembler scanning

2024-09-05 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:d0f02538494ded78cac12c63f5708a53f5a77bda

commit r15-3485-gd0f02538494ded78cac12c63f5708a53f5a77bda
Author: Thomas Schwinge 
Date:   Wed Jul 17 15:27:51 2024 +0200

Enhance 'gcc.target/nvptx/alias-*.c' assembler scanning

... in order to demonstrate unexpected behavior (XFAILed here).

PR target/104957
gcc/testsuite/
* gcc.target/nvptx/alias-1.c: Enhance assembler scanning.
* gcc.target/nvptx/alias-2.c: Likewise.
* gcc.target/nvptx/alias-3.c: Likewise.
* gcc.target/nvptx/alias-4.c: Likewise.
* gcc.target/nvptx/alias-to-alias-1.c: Likewise.

Diff:
---
 gcc/testsuite/gcc.target/nvptx/alias-1.c  | 15 ---
 gcc/testsuite/gcc.target/nvptx/alias-2.c  | 16 
 gcc/testsuite/gcc.target/nvptx/alias-3.c  | 15 ---
 gcc/testsuite/gcc.target/nvptx/alias-4.c  | 17 +
 gcc/testsuite/gcc.target/nvptx/alias-to-alias-1.c | 22 +-
 5 files changed, 66 insertions(+), 19 deletions(-)

diff --git a/gcc/testsuite/gcc.target/nvptx/alias-1.c 
b/gcc/testsuite/gcc.target/nvptx/alias-1.c
index 1c0642b14d9..0fb06495f67 100644
--- a/gcc/testsuite/gcc.target/nvptx/alias-1.c
+++ b/gcc/testsuite/gcc.target/nvptx/alias-1.c
@@ -23,6 +23,15 @@ main (void)
   return 0;
 }
 
-/* { dg-final { scan-assembler-times "\\.alias f,__f;" 1 } } */
-/* { dg-final { scan-assembler-times "\\.visible \\.func __f;" 1 } } */
-/* { dg-final { scan-assembler-times "\\.visible \\.func f;" 1 } } */
+/* { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DECL: 
__f$} 1 } }
+   { dg-final { scan-assembler-times {(?n)^\.visible \.func __f;$} 1 } }
+   { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DEF: __f$} 
1 } }
+   { dg-final { scan-assembler-times {(?n)^\.visible \.func __f$} 1 } } */
+
+/* { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DECL: f$} 
1 { xfail *-*-* } } }
+   { dg-final { scan-assembler-times {(?n)^\.visible \.func f;$} 1 } }
+   { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DEF: f$} 1 
{ xfail *-*-* } } }
+   { dg-final { scan-assembler-times {(?n)^\.alias f,__f;$} 1 } } */
+
+/* { dg-final { scan-assembler-times {(?n)\tcall __f;$} 0 } }
+   { dg-final { scan-assembler-times {(?n)\tcall f;$} 1 } } */
diff --git a/gcc/testsuite/gcc.target/nvptx/alias-2.c 
b/gcc/testsuite/gcc.target/nvptx/alias-2.c
index 7a88b6f4f6f..8ae8b5cfaed 100644
--- a/gcc/testsuite/gcc.target/nvptx/alias-2.c
+++ b/gcc/testsuite/gcc.target/nvptx/alias-2.c
@@ -5,10 +5,18 @@
 
 #include "alias-1.c"
 
+/* Note extern and inlined, so still there.  */
+/* { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DECL: 
__f$} 1 } }
+   { dg-final { scan-assembler-times {(?n)^\.visible \.func __f;$} 1 } }
+   { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DEF: __f$} 
1 } }
+   { dg-final { scan-assembler-times {(?n)^\.visible \.func __f$} 1 } } */
+
 /* Inlined, so no alias.  */
-/* { dg-final { scan-assembler-not "\\.alias.*;" } } */
-/* { dg-final { scan-assembler-not "\\.visible \\.func f;" } } */
 
-/* Note extern and inlined, so still there.  */
-/* { dg-final { scan-assembler-times "\\.visible \\.func __f;" 1 } } */
+/* { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DECL: f$} 
0 } }
+   { dg-final { scan-assembler-times {(?n)^\.visible \.func f;$} 0 } }
+   { dg-final { scan-assembler-times {(?n)^// BEGIN GLOBAL FUNCTION DEF: f$} 0 
} }
+   { dg-final { scan-assembler-times {(?n)^\.alias f,__f;$} 0 } } */
 
+/* { dg-final { scan-assembler-times {(?n)\tcall __f;$} 0 } }
+   { dg-final { scan-assembler-times {(?n)\tcall f;$} 0 } } */
diff --git a/gcc/testsuite/gcc.target/nvptx/alias-3.c 
b/gcc/testsuite/gcc.target/nvptx/alias-3.c
index b55ff26269e..1906607f95f 100644
--- a/gcc/testsuite/gcc.target/nvptx/alias-3.c
+++ b/gcc/testsuite/gcc.target/nvptx/alias-3.c
@@ -25,6 +25,15 @@ main (void)
   return 0;
 }
 
-/* { dg-final { scan-assembler-times "\\.alias f,__f;" 1 } } */
-/* { dg-final { scan-assembler-times "\\.func __f;" 1 } } */
-/* { dg-final { scan-assembler-times "\\.func f;" 1 } } */
+/* { dg-final { scan-assembler-times {(?n)^// BEGIN FUNCTION DECL: __f$} 1 } }
+   { dg-final { scan-assembler-times {(?n)^\.func __f;$} 1 } }
+   { dg-final { scan-assembler-times {(?n)^// BEGIN FUNCTION DEF: __f$} 1 } }
+   { dg-final { scan-assembler-times {(?n)^\.func __f$} 1 } } */
+
+/* { dg-final { scan-assembler-times {(?n)^// BEGIN FUNCTION DECL: f$} 1 { 
xfail *-*-* } } }
+   { dg-final { scan-assembler-times {(?n)^\.func f;$} 1 } }
+   { dg-final { scan-assembler-times {(?n)^// BEGIN FUNCTION DEF: f$} 1 { 
xfail *-*-* } } }
+   { dg-final { scan-assembler-times {(?n)^\.alias f,__f;$} 1 } } */
+
+/* { dg-final { scan-assembler-times {(?n)\tcall __f;$} 0 } }
+   { dg-final { scan-assembler-times {(?n)\tcall f;$} 1 } } */
diff --git a/gcc/testsuite/gcc.

[gcc r15-3484] Fix 'gcc.target/nvptx/alias-2.c' comment

2024-09-05 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:973c1bf51fb0f58fbfe43651bb0a61e1d124b35d

commit r15-3484-g973c1bf51fb0f58fbfe43651bb0a61e1d124b35d
Author: Thomas Schwinge 
Date:   Mon Sep 18 22:41:56 2023 +0200

Fix 'gcc.target/nvptx/alias-2.c' comment

PR target/104957
gcc/testsuite/
* gcc.target/nvptx/alias-2.c: Fix comment.

Diff:
---
 gcc/testsuite/gcc.target/nvptx/alias-2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/nvptx/alias-2.c 
b/gcc/testsuite/gcc.target/nvptx/alias-2.c
index 5c4b9c787e1..7a88b6f4f6f 100644
--- a/gcc/testsuite/gcc.target/nvptx/alias-2.c
+++ b/gcc/testsuite/gcc.target/nvptx/alias-2.c
@@ -9,6 +9,6 @@
 /* { dg-final { scan-assembler-not "\\.alias.*;" } } */
 /* { dg-final { scan-assembler-not "\\.visible \\.func f;" } } */
 
-/* Note static and inlined, so still there.  */
+/* Note extern and inlined, so still there.  */
 /* { dg-final { scan-assembler-times "\\.visible \\.func __f;" 1 } } */


[gcc r15-3483] Move from 'gcc.target/nvptx/nvptx.exp' into 'target-supports.exp' additions for nvptx target

2024-09-05 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:a121af90fe9244258c8620901dd6fa22537767bb

commit r15-3483-ga121af90fe9244258c8620901dd6fa22537767bb
Author: Thomas Schwinge 
Date:   Mon Jul 22 14:40:34 2024 +0200

Move from 'gcc.target/nvptx/nvptx.exp' into 'target-supports.exp' additions 
for nvptx target

gcc/testsuite/
* gcc.target/nvptx/nvptx.exp
(check_effective_target_default_ptx_isa_version_at_least)
(check_effective_target_default_ptx_isa_version_at_least_6_0)
(check_effective_target_runtime_ptx_isa_version_at_least)
(check_effective_target_runtime_ptx_alias)
(add_options_for_ptx_alias): Move...
* lib/target-supports.exp
(check_nvptx_default_ptx_isa_version_at_least)
(check_effective_target_nvptx_default_ptx_isa_version_at_least_6_0)
(check_nvptx_runtime_ptx_isa_version_at_least)
(check_effective_target_nvptx_runtime_alias_ptx)
(add_options_for_nvptx_alias_ptx): ... here.
* gcc.target/nvptx/alias-1.c: Adjust.
* gcc.target/nvptx/alias-2.c: Likewise.
* gcc.target/nvptx/alias-3.c: Likewise.
* gcc.target/nvptx/alias-4.c: Likewise.
* gcc.target/nvptx/alias-to-alias-1.c: Likewise.
* gcc.target/nvptx/alias-weak-1.c: Likewise.
* gcc.target/nvptx/uniform-simt-5.c: Likewise.
gcc/
* doc/sourcebuild.texi (Effective-Target Keywords): Document
'nvptx_default_ptx_isa_version_at_least_6_0',
'nvptx_runtime_alias_ptx'.
(Add Options): Document 'nvptx_alias_ptx'.

Diff:
---
 gcc/doc/sourcebuild.texi  | 14 +
 gcc/testsuite/gcc.target/nvptx/alias-1.c  |  4 +-
 gcc/testsuite/gcc.target/nvptx/alias-2.c  |  4 +-
 gcc/testsuite/gcc.target/nvptx/alias-3.c  |  4 +-
 gcc/testsuite/gcc.target/nvptx/alias-4.c  |  4 +-
 gcc/testsuite/gcc.target/nvptx/alias-to-alias-1.c |  2 +-
 gcc/testsuite/gcc.target/nvptx/alias-weak-1.c |  2 +-
 gcc/testsuite/gcc.target/nvptx/nvptx.exp  | 66 -
 gcc/testsuite/gcc.target/nvptx/uniform-simt-5.c   |  4 +-
 gcc/testsuite/lib/target-supports.exp | 72 +++
 10 files changed, 98 insertions(+), 78 deletions(-)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 7c7094dc5a9..6ba72fd44a2 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2424,6 +2424,17 @@ MSP430 target has the small memory model enabled 
(@code{-msmall}).
 MSP430 target has the large memory model enabled (@code{-mlarge}).
 @end table
 
+@subsubsection nvptx-specific attributes
+
+@table @code
+@item nvptx_default_ptx_isa_version_at_least_6_0
+nvptx code by default compiles for at least PTX ISA version 6.0.
+
+@item nvptx_runtime_alias_ptx
+The nvptx runtime environment supports the PTX ISA directive
+@code{.alias}.
+@end table
+
 @subsubsection PowerPC-specific attributes
 
 @table @code
@@ -3302,6 +3313,9 @@ compliance mode.
 @code{mips16} function attributes.
 Only MIPS targets support this feature, and only then in certain modes.
 
+@item nvptx_alias_ptx
+Enable using the PTX ISA directive @code{.alias} on nvptx targets.
+
 @item riscv_a
 Add the 'A' extension to the -march string on RISC-V targets.
 
diff --git a/gcc/testsuite/gcc.target/nvptx/alias-1.c 
b/gcc/testsuite/gcc.target/nvptx/alias-1.c
index d251eee6e42..1c0642b14d9 100644
--- a/gcc/testsuite/gcc.target/nvptx/alias-1.c
+++ b/gcc/testsuite/gcc.target/nvptx/alias-1.c
@@ -1,7 +1,7 @@
 /* { dg-do link } */
-/* { dg-do run { target runtime_ptx_alias } } */
+/* { dg-do run { target nvptx_runtime_alias_ptx } } */
 /* { dg-options "-save-temps" } */
-/* { dg-add-options ptx_alias } */
+/* { dg-add-options nvptx_alias_ptx } */
 
 int v;
 
diff --git a/gcc/testsuite/gcc.target/nvptx/alias-2.c 
b/gcc/testsuite/gcc.target/nvptx/alias-2.c
index 96cb7e2c1ef..5c4b9c787e1 100644
--- a/gcc/testsuite/gcc.target/nvptx/alias-2.c
+++ b/gcc/testsuite/gcc.target/nvptx/alias-2.c
@@ -1,7 +1,7 @@
 /* { dg-do link } */
-/* { dg-do run { target runtime_ptx_alias } } */
+/* { dg-do run { target nvptx_runtime_alias_ptx } } */
 /* { dg-options "-save-temps -O2" } */
-/* { dg-add-options ptx_alias } */
+/* { dg-add-options nvptx_alias_ptx } */
 
 #include "alias-1.c"
 
diff --git a/gcc/testsuite/gcc.target/nvptx/alias-3.c 
b/gcc/testsuite/gcc.target/nvptx/alias-3.c
index 39649e30b91..b55ff26269e 100644
--- a/gcc/testsuite/gcc.target/nvptx/alias-3.c
+++ b/gcc/testsuite/gcc.target/nvptx/alias-3.c
@@ -1,7 +1,7 @@
 /* { dg-do link } */
-/* { dg-do run { target runtime_ptx_alias } } */
+/* { dg-do run { target nvptx_runtime_alias_ptx } } */
 /* { dg-options "-save-temps" } */
-/* { dg-add-options ptx_alias } */
+/* { dg-add-options nvptx_alias_ptx } */
 
 /* Copy of alias-1.c, with static __f and f.  */
 
diff --git a/gcc/testsuite/gcc.target/nvptx/alias-4.c 
b/gcc/tests

[gcc r15-3466] Handle 'NUM' in 'PUSH_INSERT_PASSES_WITHIN'

2024-09-04 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:22af50a48d2b4371ee6d805d95f56212fbe611b1

commit r15-3466-g22af50a48d2b4371ee6d805d95f56212fbe611b1
Author: Thomas Schwinge 
Date:   Fri Jun 28 12:10:12 2024 +0200

Handle 'NUM' in 'PUSH_INSERT_PASSES_WITHIN'

..., such that also for repeated 'NEXT_PASS', 'PUSH_INSERT_PASSES_WITHIN' 
for a
given 'PASS', the 'PUSH_INSERT_PASSES_WITHIN' applies to the preceeding
'NEXT_PASS', and not unconditionally applies to the first 'NEXT_PASS'.

gcc/
* gen-pass-instances.awk: Handle 'PUSH_INSERT_PASSES_WITHIN'.
* pass_manager.h (PUSH_INSERT_PASSES_WITHIN): Adjust.
* passes.cc (PUSH_INSERT_PASSES_WITHIN): Likewise.

Diff:
---
 gcc/gen-pass-instances.awk | 28 +---
 gcc/pass_manager.h |  2 +-
 gcc/passes.cc  |  6 +++---
 3 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/gcc/gen-pass-instances.awk b/gcc/gen-pass-instances.awk
index 449889663f7..871ac0cdb52 100644
--- a/gcc/gen-pass-instances.awk
+++ b/gcc/gen-pass-instances.awk
@@ -16,7 +16,7 @@
 
 # This Awk script takes passes.def and writes pass-instances.def,
 # counting the instances of each kind of pass, adding an instance number
-# to everywhere that NEXT_PASS is used.
+# to everywhere that NEXT_PASS or PUSH_INSERT_PASSES_WITHIN are used.
 # Also handle INSERT_PASS_AFTER, INSERT_PASS_BEFORE and REPLACE_PASS
 # directives.
 #
@@ -222,9 +222,31 @@ END {
  if (with_arg)
printf ",%s", with_arg;
  printf ")%s\n", postfix;
+
+ continue;
}
-  else
-   print lines[i];
+
+  ret = parse_line(lines[i], "PUSH_INSERT_PASSES_WITHIN");
+  if (ret)
+   {
+ pass_name = args[1];
+
+ pass_num = pass_final_counts[pass_name];
+ if (!pass_num)
+   {
+ print "ERROR: Can't locate instance of the pass mentioned in " 
pass_name;
+ exit 1;
+   }
+
+ printf "%s", prefix;
+ printf "PUSH_INSERT_PASSES_WITHIN";
+ printf " (%s, %s", pass_name, pass_num;
+ printf ")%s\n", postfix;
+
+ continue;
+   }
+
+  print lines[i];
 }
 }
 
diff --git a/gcc/pass_manager.h b/gcc/pass_manager.h
index be324d5dff7..edd775e9a9c 100644
--- a/gcc/pass_manager.h
+++ b/gcc/pass_manager.h
@@ -126,7 +126,7 @@ private:
 opt_pass *pass_copy_prop_8;  */
 
 #define INSERT_PASSES_AFTER(PASS)
-#define PUSH_INSERT_PASSES_WITHIN(PASS)
+#define PUSH_INSERT_PASSES_WITHIN(PASS, NUM)
 #define POP_INSERT_PASSES()
 #define NEXT_PASS(PASS, NUM) opt_pass *PASS ## _ ## NUM
 #define NEXT_PASS_WITH_ARG(PASS, NUM, ARG) NEXT_PASS (PASS, NUM)
diff --git a/gcc/passes.cc b/gcc/passes.cc
index e2a07ebedf5..775c3e46302 100644
--- a/gcc/passes.cc
+++ b/gcc/passes.cc
@@ -1585,7 +1585,7 @@ pass_manager::pass_manager (context *ctxt)
 
   /* Zero-initialize pass members.  */
 #define INSERT_PASSES_AFTER(PASS)
-#define PUSH_INSERT_PASSES_WITHIN(PASS)
+#define PUSH_INSERT_PASSES_WITHIN(PASS, NUM)
 #define POP_INSERT_PASSES()
 #define NEXT_PASS(PASS, NUM) PASS ## _ ## NUM = NULL
 #define NEXT_PASS_WITH_ARG(PASS, NUM, ARG) NEXT_PASS (PASS, NUM)
@@ -1615,9 +1615,9 @@ pass_manager::pass_manager (context *ctxt)
 *p = NULL; \
   }
 
-#define PUSH_INSERT_PASSES_WITHIN(PASS) \
+#define PUSH_INSERT_PASSES_WITHIN(PASS, NUM) \
   { \
-opt_pass **p = &(PASS ## _1)->sub;
+opt_pass **p = &(PASS ## _ ## NUM)->sub;
 
 #define POP_INSERT_PASSES() \
   }


[gcc r15-3450] nvptx: Use 'enum ptx_version', 'enum ptx_isa' instead of 'int'

2024-09-04 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:fee2fbedbb43ad7a017a33ed2b820be79b75e7e5

commit r15-3450-gfee2fbedbb43ad7a017a33ed2b820be79b75e7e5
Author: Thomas Schwinge 
Date:   Mon Jul 22 10:49:16 2024 +0200

nvptx: Use 'enum ptx_version', 'enum ptx_isa' instead of 'int'

This allows getting rid of the respective type casts.  No change in behavior
intended.

gcc/
* config/nvptx/gen-opt.sh: Use 'enum ptx_isa' instead of 'int'.
* config/nvptx/nvptx-gen.opt: Regenerate.
* config/nvptx/nvptx.opt: Use 'enum ptx_version' instead of 'int'.
* config/nvptx/nvptx-opts.h (enum ptx_isa): Add 'PTX_ISA_unset'.
(enum ptx_version): Add 'PTX_VERSION_unset'.
* config/nvptx/nvptx-c.cc (nvptx_cpu_cpp_builtins): Adjust.
* config/nvptx/nvptx.cc (default_ptx_version_option)
(handle_ptx_version_option, nvptx_option_override)
(nvptx_file_start): Likewise.

Diff:
---
 gcc/config/nvptx/gen-opt.sh| 14 +-
 gcc/config/nvptx/nvptx-c.cc|  6 ++
 gcc/config/nvptx/nvptx-gen.opt |  2 +-
 gcc/config/nvptx/nvptx-opts.h  |  4 +++-
 gcc/config/nvptx/nvptx.cc  | 24 
 gcc/config/nvptx/nvptx.opt |  9 ++---
 6 files changed, 37 insertions(+), 22 deletions(-)

diff --git a/gcc/config/nvptx/gen-opt.sh b/gcc/config/nvptx/gen-opt.sh
index 3f7838251d2..6022f51f897 100644
--- a/gcc/config/nvptx/gen-opt.sh
+++ b/gcc/config/nvptx/gen-opt.sh
@@ -38,12 +38,24 @@ echo
 
 . $gen_copyright_sh opt
 
+# Not emitting the following here (in addition to having it in 'nvptx.opt'), as
+# we'll otherwise run into:
+# 
+# gtyp-input.list:10: file [...]/gcc/config/nvptx/nvptx-opts.h specified 
more than once for language (all)
+# make[2]: *** [Makefile:2981: s-gtype] Error 1
+: ||
+cat .
 
 Enum
-Name(ptx_isa) Type(int)
+Name(ptx_isa) Type(enum ptx_isa)
 Known PTX ISA target architectures (for use with the -misa= option):
 
 EnumValue
diff --git a/gcc/config/nvptx/nvptx-opts.h b/gcc/config/nvptx/nvptx-opts.h
index f8975327223..fb5147c143e 100644
--- a/gcc/config/nvptx/nvptx-opts.h
+++ b/gcc/config/nvptx/nvptx-opts.h
@@ -22,6 +22,7 @@
 
 enum ptx_isa
 {
+  PTX_ISA_unset,
 #define NVPTX_SM(XX, SEP) PTX_ISA_SM ## XX SEP
 #define NVPTX_SM_SEP ,
 #include "nvptx-sm.def"
@@ -31,7 +32,8 @@ enum ptx_isa
 
 enum ptx_version
 {
-  PTX_VERSION_default,
+  PTX_VERSION_unset,
+  PTX_VERSION_default = PTX_VERSION_unset,
   PTX_VERSION_3_0,
   PTX_VERSION_3_1,
   PTX_VERSION_4_2,
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 2a8f713c680..144b8d0c874 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -231,8 +231,7 @@ first_ptx_version_supporting_sm (enum ptx_isa sm)
 static enum ptx_version
 default_ptx_version_option (void)
 {
-  enum ptx_version first
-= first_ptx_version_supporting_sm ((enum ptx_isa) ptx_isa_option);
+  enum ptx_version first = first_ptx_version_supporting_sm (ptx_isa_option);
 
   /* Pick a version that supports the sm.  */
   enum ptx_version res = first;
@@ -311,20 +310,21 @@ sm_version_to_string (enum ptx_isa sm)
 static void
 handle_ptx_version_option (void)
 {
-  if (!OPTION_SET_P (ptx_version_option)
-  || ptx_version_option == PTX_VERSION_default)
+  if (!OPTION_SET_P (ptx_version_option))
+gcc_checking_assert (ptx_version_option == PTX_VERSION_default);
+
+  if (ptx_version_option == PTX_VERSION_default)
 {
   ptx_version_option = default_ptx_version_option ();
   return;
 }
 
-  enum ptx_version first
-= first_ptx_version_supporting_sm ((enum ptx_isa) ptx_isa_option);
+  enum ptx_version first = first_ptx_version_supporting_sm (ptx_isa_option);
 
   if (ptx_version_option < first)
 error ("PTX version (%<-mptx%>) needs to be at least %s to support 
selected"
   " %<-misa%> (sm_%s)", ptx_version_to_string (first),
-  sm_version_to_string ((enum ptx_isa)ptx_isa_option));
+  sm_version_to_string (ptx_isa_option));
 }
 
 /* Implement TARGET_OPTION_OVERRIDE.  */
@@ -336,7 +336,9 @@ nvptx_option_override (void)
 
   /* Via nvptx 'OPTION_DEFAULT_SPECS', '-misa' always appears on the command
  line; but handle the case that the compiler is not run via the driver.  */
-  if (!OPTION_SET_P (ptx_isa_option))
+  gcc_checking_assert ((ptx_isa_option == PTX_ISA_unset)
+  == (!OPTION_SET_P (ptx_isa_option)));
+  if (ptx_isa_option == PTX_ISA_unset)
 fatal_error (UNKNOWN_LOCATION, "%<-march=%> must be specified");
 
   handle_ptx_version_option ();
@@ -5953,13 +5955,11 @@ nvptx_file_start (void)
   fputs ("// BEGIN PREAMBLE\n", asm_out_file);
 
   fputs ("\t.version\t", asm_out_file);
-  fputs (ptx_version_to_string ((enum ptx_version)ptx_version_option),
-asm_out_file);
+  fputs (ptx_version_to_string (ptx_version_option), asm_out_file);
   fputs ("\n", asm_out_file);
 
   fputs ("\t.target\tsm_", asm_out_file);
-  fp

[gcc r15-3449] Fix branch prediction dump message

2024-09-04 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:35e4414bac06927387fb7a6fe10b373e766da1c1

commit r15-3449-g35e4414bac06927387fb7a6fe10b373e766da1c1
Author: Frederik Harwath 
Date:   Tue Nov 16 16:13:51 2021 +0100

Fix branch prediction dump message

Instead of, for instance, "Loop got predicted 1 to iterate 10 times"
the message should be "Loop 1 got predicted to iterate 10 times".

gcc/ChangeLog:

* predict.cc (pass_profile::execute): Fix dump message.

Co-authored-by: Thomas Schwinge 

Diff:
---
 gcc/predict.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/predict.cc b/gcc/predict.cc
index 43e3694cb42..f611161f4aa 100644
--- a/gcc/predict.cc
+++ b/gcc/predict.cc
@@ -4210,7 +4210,7 @@ pass_profile::execute (function *fun)
  sreal iterations;
  for (auto loop : loops_list (cfun, LI_FROM_INNERMOST))
if (expected_loop_iterations_by_profile (loop, &iterations))
-fprintf (dump_file, "Loop got predicted %d to iterate %f times.\n",
+fprintf (dump_file, "Loop %d got predicted to iterate %f times.\n",
   loop->num, iterations.to_double ());
}
   return 0;


[gcc r15-3448] Fix gimple_debug_cfg declaration

2024-09-04 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:347a953d855c6b246b1604bdf4728f615cb471b6

commit r15-3448-g347a953d855c6b246b1604bdf4728f615cb471b6
Author: Frederik Harwath 
Date:   Tue Nov 16 16:08:40 2021 +0100

Fix gimple_debug_cfg declaration

Silence a warning. The argument type did not match the definition.

gcc/ChangeLog:

* tree-cfg.h (gimple_debug_cfg): Change argument type from int
to dump_flags_t.

Diff:
---
 gcc/tree-cfg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/tree-cfg.h b/gcc/tree-cfg.h
index 0564b79b4ab..e55991740e8 100644
--- a/gcc/tree-cfg.h
+++ b/gcc/tree-cfg.h
@@ -45,7 +45,7 @@ extern void clear_special_calls (void);
 extern edge find_taken_edge (basic_block, tree);
 extern void gimple_debug_bb (basic_block);
 extern basic_block gimple_debug_bb_n (int);
-extern void gimple_debug_cfg (int);
+extern void gimple_debug_cfg (dump_flags_t);
 extern void gimple_dump_cfg (FILE *, dump_flags_t);
 extern void dump_cfg_stats (FILE *);
 extern void debug_cfg_stats (void);


[gcc r15-3447] Document 'pass_postreload' vs. 'pass_late_compilation'

2024-09-04 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:438381ef759ee8b5b04c5723a8334354ba2a30e5

commit r15-3447-g438381ef759ee8b5b04c5723a8334354ba2a30e5
Author: Thomas Schwinge 
Date:   Fri Jun 28 16:04:18 2024 +0200

Document 'pass_postreload' vs. 'pass_late_compilation'

See Subversion r217124 (Git commit 433e4164339f18d0b8798968444a56b681b5232c)
"Reorganize post-ra pipeline for targets without register allocation".

gcc/
* passes.cc: Document 'pass_postreload' vs. 'pass_late_compilation'.
* passes.def: Likewise.

Diff:
---
 gcc/passes.cc  | 14 +-
 gcc/passes.def |  3 +++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/gcc/passes.cc b/gcc/passes.cc
index 057850f4dec..e2a07ebedf5 100644
--- a/gcc/passes.cc
+++ b/gcc/passes.cc
@@ -660,6 +660,10 @@ make_pass_rest_of_compilation (gcc::context *ctxt)
 
 namespace {
 
+/* A container pass (only) for '!targetm.no_register_allocation' targets, for
+   passes to run if reload completed (..., but not run them if it failed, for
+   example for an invalid 'asm').  See also 'pass_late_compilation'.  */
+
 const pass_data pass_data_postreload =
 {
   RTL_PASS, /* type */
@@ -681,7 +685,12 @@ public:
   {}
 
   /* opt_pass methods: */
-  bool gate (function *) final override { return reload_completed; }
+  bool gate (function *) final override
+  {
+if (reload_completed)
+  gcc_checking_assert (!targetm.no_register_allocation);
+return reload_completed;
+  }
 
 }; // class pass_postreload
 
@@ -695,6 +704,9 @@ make_pass_postreload (gcc::context *ctxt)
 
 namespace {
 
+/* A container pass like 'pass_postreload', but for passes to run also for
+   'targetm.no_register_allocation' targets.  */
+
 const pass_data pass_data_late_compilation =
 {
   RTL_PASS, /* type */
diff --git a/gcc/passes.def b/gcc/passes.def
index b06d6d45f63..6d98c3c9282 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -509,6 +509,9 @@ along with GCC; see the file COPYING3.  If not see
   NEXT_PASS (pass_early_remat);
   NEXT_PASS (pass_ira);
   NEXT_PASS (pass_reload);
+  /* In the following, some passes are tied to 'pass_postreload' and others
+to 'pass_late_compilation'.  The difference is that the latter also
+run for 'targetm.no_register_allocation' targets.  */
   NEXT_PASS (pass_postreload);
   PUSH_INSERT_PASSES_WITHIN (pass_postreload)
  NEXT_PASS (pass_postreload_cse);


[gcc r15-3446] nvptx: Specify '-mno-alias' for 'gcc.dg/pr60797.c' [PR60797, PR104957]

2024-09-04 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:b9be3113a9365e8380397abb23abc71f049cf4f1

commit r15-3446-gb9be3113a9365e8380397abb23abc71f049cf4f1
Author: Thomas Schwinge 
Date:   Sun Jul 21 22:23:40 2024 +0200

nvptx: Specify '-mno-alias' for 'gcc.dg/pr60797.c' [PR60797, PR104957]

2014 Subversion r209299 (Git commit 
8330537b5b58bd0532a0a49f9cbd59bf526a7847)
"Fix PR60797" added this test case, which we now amend so that it's able to
test its thing also in '--target=nvptx-none' configurations with symbol 
alias
support enabled (..., and test nvptx '-mno-alias').

PR middle-end/60797
PR target/104957
gcc/testsuite/
* gcc.dg/pr60797.c: For nvptx, specify '-mno-alias'.

Diff:
---
 gcc/testsuite/gcc.dg/pr60797.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/pr60797.c b/gcc/testsuite/gcc.dg/pr60797.c
index 45090bae502..0485b2de172 100644
--- a/gcc/testsuite/gcc.dg/pr60797.c
+++ b/gcc/testsuite/gcc.dg/pr60797.c
@@ -1,5 +1,7 @@
-/* { dg-do compile } */
-/* { dg-skip-if "" { alias } } */
+/* If there's support for symbol aliases, have to 'dg-skip-if' -- unless
+   there's a way to disable this support.
+   { dg-additional-options -mno-alias { target nvptx-*-* } }
+   { dg-skip-if "" { { ! nvptx-*-* } && alias } } */
 
 extern int foo __attribute__((alias("bar"))); /* { dg-error "supported" } */
 int main()


[gcc r15-3445] Add 'gcc.target/nvptx/alias-to-alias-1.c'

2024-09-04 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:a89321c890b96c583671b73fc802e87545e4a2b1

commit r15-3445-ga89321c890b96c583671b73fc802e87545e4a2b1
Author: Thomas Schwinge 
Date:   Wed Sep 4 09:44:33 2024 +0200

Add 'gcc.target/nvptx/alias-to-alias-1.c'

... similar to alias to alias usage in 'libgomp.c-c++-common/pr96390.c'.

PR target/104957
gcc/testsuite/
* gcc.target/nvptx/alias-to-alias-1.c: New.

Diff:
---
 gcc/testsuite/gcc.target/nvptx/alias-to-alias-1.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/gcc/testsuite/gcc.target/nvptx/alias-to-alias-1.c 
b/gcc/testsuite/gcc.target/nvptx/alias-to-alias-1.c
new file mode 100644
index 000..3db79d1fc0b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/alias-to-alias-1.c
@@ -0,0 +1,27 @@
+/* Alias to alias; 'libgomp.c-c++-common/pr96390.c'.  */
+
+/* { dg-do compile } */
+/* { dg-add-options ptx_alias } */
+
+int v;
+
+void foo () { v = 42; }
+void bar () __attribute__((alias ("foo")));
+void baz () __attribute__((alias ("bar")));
+
+int
+main (void)
+{
+  baz ();
+  if (v != 42)
+__builtin_abort ();
+
+  return 0;
+}
+
+/* { dg-final { scan-assembler-times "\\.alias bar,foo;" 1 } } */
+/* { dg-final { scan-assembler-times "\\.visible \\.func foo;" 1 } } */
+/* { dg-final { scan-assembler-times "\\.visible \\.func bar;" 1 } } */
+
+/* { dg-final { scan-assembler-times "\\.alias baz,bar;" 1 } } */
+/* { dg-final { scan-assembler-times "\\.visible \\.func baz;" 1 } } */


[gcc r15-3444] Add 'gcc.target/nvptx/alias-weak-1.c'

2024-09-04 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:2267d254eb6ad782cef7b462f2bb2128bc8ace30

commit r15-3444-g2267d254eb6ad782cef7b462f2bb2128bc8ace30
Author: Thomas Schwinge 
Date:   Wed Sep 4 09:58:32 2024 +0200

Add 'gcc.target/nvptx/alias-weak-1.c'

... testing for the GCC/nvptx "weak alias definitions not supported" error
diagnostic (limitation of PTX).

gcc/testsuite/
* gcc.target/nvptx/alias-weak-1.c: New.

Diff:
---
 gcc/testsuite/gcc.target/nvptx/alias-weak-1.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/gcc/testsuite/gcc.target/nvptx/alias-weak-1.c 
b/gcc/testsuite/gcc.target/nvptx/alias-weak-1.c
new file mode 100644
index 000..37d9543fc7f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/alias-weak-1.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-add-options ptx_alias } */
+
+void __f ()
+{
+}
+
+void f () __attribute__ ((weak, alias ("__f")));
+/* { dg-error {weak alias definitions not supported} {} { target *-*-* } .-1 }
+   (limitation of PTX).  */


[gcc r15-3214] Un-XFAIL 'gcc.dg/signbit-5.c' for GCN

2024-08-27 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:2daf6187c7289d012365419e10995042139cf8f5

commit r15-3214-g2daf6187c7289d012365419e10995042139cf8f5
Author: Thomas Schwinge 
Date:   Tue Aug 27 12:37:29 2024 +0200

Un-XFAIL 'gcc.dg/signbit-5.c' for GCN

It XPASSes after recent commit 5a3387938d4d95717cac29eecd0ba53e0ef9094d
"testsuite: Add -fwrapv to signbit-5.c".

gcc/testsuite/
* gcc.dg/signbit-5.c: Un-XFAIL for GCN.

Diff:
---
 gcc/testsuite/gcc.dg/signbit-5.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/signbit-5.c b/gcc/testsuite/gcc.dg/signbit-5.c
index e65c8910c825..57e29e3ca63e 100644
--- a/gcc/testsuite/gcc.dg/signbit-5.c
+++ b/gcc/testsuite/gcc.dg/signbit-5.c
@@ -3,7 +3,6 @@
 
 /* This test does not work when the truth type does not match vector type.  */
 /* { dg-additional-options "-march=armv8-a" { target aarch64_sve } } */
-/* { dg-xfail-run-if "truth type does not match vector type" { amdgcn-*-* } } 
*/
 
 
 #include 


[gcc r15-2845] OpenMP: Constructors and destructors for "declare target" static aggregates: Fix effective-target ke

2024-08-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:9f5d22e3e2b8e4532896a4f3837cb86006d5930c

commit r15-2845-g9f5d22e3e2b8e4532896a4f3837cb86006d5930c
Author: Thomas Schwinge 
Date:   Fri Aug 9 11:23:15 2024 +0200

OpenMP: Constructors and destructors for "declare target" static 
aggregates: Fix effective-target keyword in test cases

(Most of) the tests added in commit f1bfba3a9b3f31e3e06bfd1911c9f223869ea03f
"OpenMP: Constructors and destructors for "declare target" static 
aggregates"
had a mismatch between dump file production and its scanning; the former 
needs
to use 'offload_target_nvptx' (like 'offload_target_amdgcn'), not
'offload_device_nvptx'.

libgomp/
* testsuite/libgomp.c++/static-aggr-constructor-destructor-1.C:
Fix effective-target keyword.
* testsuite/libgomp.c++/static-aggr-constructor-destructor-2.C:
Likewise.
* testsuite/libgomp.c-c++-common/target-is-initial-host-2.c:
Likewise.
* testsuite/libgomp.c-c++-common/target-is-initial-host.c:
Likewise.
* testsuite/libgomp.fortran/target-is-initial-host-2.f90:
Likewise.
* testsuite/libgomp.fortran/target-is-initial-host.f: Likewise.
* testsuite/libgomp.fortran/target-is-initial-host.f90: Likewise.

Diff:
---
 libgomp/testsuite/libgomp.c++/static-aggr-constructor-destructor-1.C | 2 +-
 libgomp/testsuite/libgomp.c++/static-aggr-constructor-destructor-2.C | 2 +-
 libgomp/testsuite/libgomp.c-c++-common/target-is-initial-host-2.c| 2 +-
 libgomp/testsuite/libgomp.c-c++-common/target-is-initial-host.c  | 2 +-
 libgomp/testsuite/libgomp.fortran/target-is-initial-host-2.f90   | 2 +-
 libgomp/testsuite/libgomp.fortran/target-is-initial-host.f   | 2 +-
 libgomp/testsuite/libgomp.fortran/target-is-initial-host.f90 | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git 
a/libgomp/testsuite/libgomp.c++/static-aggr-constructor-destructor-1.C 
b/libgomp/testsuite/libgomp.c++/static-aggr-constructor-destructor-1.C
index b5aafc8cabc2..a704e39411da 100644
--- a/libgomp/testsuite/libgomp.c++/static-aggr-constructor-destructor-1.C
+++ b/libgomp/testsuite/libgomp.c++/static-aggr-constructor-destructor-1.C
@@ -1,6 +1,6 @@
 // { dg-do run }
 // { dg-additional-options "-fdump-tree-gimple -fdump-tree-optimized" }
-// { dg-additional-options -foffload-options=-fdump-tree-optimized { target { 
offload_device_nvptx || offload_target_amdgcn } } }
+// { dg-additional-options -foffload-options=-fdump-tree-optimized { target { 
offload_target_nvptx || offload_target_amdgcn } } }
 
 // { dg-final { scan-tree-dump-times "omp_is_initial_device" 1 "gimple" } }
 // { dg-final { scan-tree-dump-times "_GLOBAL__off_I_v1" 1 "gimple" } }
diff --git 
a/libgomp/testsuite/libgomp.c++/static-aggr-constructor-destructor-2.C 
b/libgomp/testsuite/libgomp.c++/static-aggr-constructor-destructor-2.C
index 9652a721bbe2..de481aadd34e 100644
--- a/libgomp/testsuite/libgomp.c++/static-aggr-constructor-destructor-2.C
+++ b/libgomp/testsuite/libgomp.c++/static-aggr-constructor-destructor-2.C
@@ -1,6 +1,6 @@
 // { dg-do run }
 // { dg-additional-options "-fdump-tree-gimple -fdump-tree-optimized" }
-// { dg-additional-options -foffload-options=-fdump-tree-optimized { target { 
offload_device_nvptx || offload_target_amdgcn } } }
+// { dg-additional-options -foffload-options=-fdump-tree-optimized { target { 
offload_target_nvptx || offload_target_amdgcn } } }
 
 // { dg-final { scan-tree-dump-times "omp_is_initial_device" 1 "gimple" } }
 // { dg-final { scan-tree-dump-times "_GLOBAL__off_I_v1" 1 "gimple" } }
diff --git a/libgomp/testsuite/libgomp.c-c++-common/target-is-initial-host-2.c 
b/libgomp/testsuite/libgomp.c-c++-common/target-is-initial-host-2.c
index 313d188a871a..eabc394c8cf8 100644
--- a/libgomp/testsuite/libgomp.c-c++-common/target-is-initial-host-2.c
+++ b/libgomp/testsuite/libgomp.c-c++-common/target-is-initial-host-2.c
@@ -4,7 +4,7 @@
 /* Check whether 'omp_is_initial_device()' is NOT compile-time optimized. */
 
 /* { dg-additional-options "-fdump-tree-gimple -fdump-tree-optimized" }  */
-/* { dg-additional-options -foffload-options=-fdump-tree-optimized { target { 
offload_device_nvptx || offload_target_amdgcn } } }  */
+/* { dg-additional-options -foffload-options=-fdump-tree-optimized { target { 
offload_target_nvptx || offload_target_amdgcn } } }  */
 
 /* { dg-final { scan-tree-dump-times "omp_is_initial_device" 1 "gimple" } }  */
 
diff --git a/libgomp/testsuite/libgomp.c-c++-common/target-is-initial-host.c 
b/libgomp/testsuite/libgomp.c-c++-common/target-is-initial-host.c
index 423727ce55f0..3b1283a59798 100644
--- a/libgomp/testsuite/libgomp.c-c++-common/target-is-initial-host.c
+++ b/libgomp/testsuite/libgomp.c-c++-common/target-is-initial-host.c
@@ -3,7 +3,7 @@
 /* Check whether 'omp_is_initial_device()' is properly compile-time optimized. 
*/
 
 /* { dg-additional-options "-fdump-

[gcc r15-2717] Inline 'gcc/rust/Make-lang.in:RUST_LIBDEPS'

2024-08-05 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:aab9f33ed1f1b92444a82eb3ea5cab1048593791

commit r15-2717-gaab9f33ed1f1b92444a82eb3ea5cab1048593791
Author: Thomas Schwinge 
Date:   Wed Feb 28 23:06:25 2024 +0100

Inline 'gcc/rust/Make-lang.in:RUST_LIBDEPS'

..., also fixing up an apparently mis-merged
commit 2340894554334a310b891a1d9e9d5e3f502357ac
"gccrs: Add 'gcc/rust/Make-lang.in:LIBFORMAT_PARSER'", which was adding a 
bogus
second definition of 'RUST_LIBDEPS'.

gcc/rust/
* Make-lang.in (RUST_LIBDEPS): Inline into all users.

Diff:
---
 gcc/rust/Make-lang.in | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index c3be5f9d81b5..aed9a998c80a 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -226,13 +226,8 @@ rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o
 LIBPROC_MACRO_INTERNAL = 
../libgrust/libproc_macro_internal/libproc_macro_internal.a
 LIBFORMAT_PARSER = ../libgrust/libformat_parser/debug/liblibformat_parser.a
 
-RUST_LIBDEPS = $(LIBDEPS) $(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER)
-
-
-RUST_LIBDEPS = $(LIBDEPS) $(LIBPROC_MACRO_INTERNAL)
-
 # The compiler itself is called crab1
-crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(RUST_LIBDEPS) 
$(rust.prev)
+crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS) 
$(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) $(rust.prev)
@$(call LINK_PROGRESS,$(INDEX.rust),start)
+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
  $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) $(CRAB1_LIBS) 
$(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) $(BACKENDLIBS)


[gcc r15-2716] Don't override 'LIBS' if '--enable-languages=rust'; use 'CRAB1_LIBS'

2024-08-05 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:816c4de4d062c89f5b7a68f68f29b2b033f5b136

commit r15-2716-g816c4de4d062c89f5b7a68f68f29b2b033f5b136
Author: Thomas Schwinge 
Date:   Mon Aug 5 10:06:05 2024 +0200

Don't override 'LIBS' if '--enable-languages=rust'; use 'CRAB1_LIBS'

Recent commit 6fef4d6ffcab0fec8518adcb05458cba5dbeac25
"gccrs: libgrust: Add format_parser library", added a general override of
'LIBS += -ldl -lpthread' if '--enable-languages=rust'.  This is wrong
conceptually, and will make the build fail on systems not providing such
libraries.  Instead, 'CRAB1_LIBS', added a while ago in
commit 75299e4fe50aa8d9b3ff529e48db4ed246083e64
"rust: Do not link with libdl and libpthread unconditionally", should be 
used,
and not generally, but for 'crab1' only.

gcc/rust/
* Make-lang.in (LIBS): Don't override.
(crab1$(exeext):): Use 'CRAB1_LIBS'.

Diff:
---
 gcc/rust/Make-lang.in | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index 24229c02770d..c3be5f9d81b5 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -54,8 +54,6 @@ GCCRS_D_OBJS = \
rust/rustspec.o \
$(END)
 
-LIBS += -ldl -lpthread
-
 gccrs$(exeext): $(GCCRS_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
  $(GCCRS_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
@@ -237,7 +235,7 @@ RUST_LIBDEPS = $(LIBDEPS) $(LIBPROC_MACRO_INTERNAL)
 crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(RUST_LIBDEPS) 
$(rust.prev)
@$(call LINK_PROGRESS,$(INDEX.rust),start)
+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
- $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) 
$(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) $(BACKENDLIBS)
+ $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) $(CRAB1_LIBS) 
$(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) $(BACKENDLIBS)
@$(call LINK_PROGRESS,$(INDEX.rust),end)
 
 # Build hooks.


[gcc r15-2389] Polish libstdc++ 'dg-final' action 'file-io-diff'

2024-07-29 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:0544db1a4f8f250edb7f25eb0fa4dcfd569ec805

commit r15-2389-g0544db1a4f8f250edb7f25eb0fa4dcfd569ec805
Author: Thomas Schwinge 
Date:   Mon Jul 29 13:32:36 2024 +0200

Polish libstdc++ 'dg-final' action 'file-io-diff'

Follow-up to recent commit 515da03a838db05443ebcc4c543a405bed764188
"libstdc++: Add file-io-diff to replace @diff@ markup in I/O tests".

Currently, if a 'dg-final' action 'file-io-diff' passes, we print nothing
(should: 'PASS: [...]'), but if it fails, we just print: 'FAIL: files 
differ',
for example ('*.log' file):

[...]
FAIL: 27_io/basic_ostream/inserters_other/wchar_t/2.cc  -std=gnu++17 
(test for excess errors)
[...]
UNRESOLVED: 27_io/basic_ostream/inserters_other/wchar_t/2.cc  
-std=gnu++17 compilation failed to produce executable
diff: wostream_inserter_other_in.txt: No such file or directory
diff: wostream_inserter_other_out.txt: No such file or directory
FAIL: files differ
diff: wostream_inserter_other_in.txt: No such file or directory
diff: wostream_inserter_other_out.txt: No such file or directory

When later the '*.sum' files get sorted, these 'FAIL: files differ' 
instances
aren't grouped anymore with the other test cases' results, but they appear 
en
bloc, lexically sorted between ('e[...]' and 's[...]'), for example:

[...]
PASS: ext/vstring/types/23767.cc  -std=gnu++17 (test for excess errors)
FAIL: files differ
FAIL: files differ
FAIL: files differ
PASS: special_functions/01_assoc_laguerre/check_nan.cc  -std=gnu++17 
(test for excess errors)
[...]

Also, we shouldn't emit the actual 'diff' into the '*.sum' file, but just 
into
the '*.log* file, and there's no need for 'spawn'/'expect', as we're not
matching any specific messages.

libstdc++-v3/
* testsuite/lib/libstdc++.exp (file-io-diff): Polish.

Diff:
---
 libstdc++-v3/testsuite/lib/libstdc++.exp | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp 
b/libstdc++-v3/testsuite/lib/libstdc++.exp
index c11e752ecfb1..18331c80bc27 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1671,6 +1671,8 @@ if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \
 
 }
 
+# Utility functions, invoked via dg-final.
+
 # Compare output file written by test to expected result.
 # With two arguments the comparison is done via 'diff arg1 arg2'.
 # With one argument the comparison is done via 'diff arg1.tst arg1.txt'.
@@ -1682,6 +1684,10 @@ proc file-io-diff { args } {
 if { $nargs > 2 } {
error "too many arguments to file-io-diff"
 }
+
+set testcase [testname-for-summary]
+set description "$testcase file-io-diff $args"
+
 if { $nargs == 1 } {
set file1 [lindex $args 0]
set file2 "${file1}.txt"
@@ -1691,14 +1697,11 @@ proc file-io-diff { args } {
set file2 [lindex $args 1]
 }
 
-spawn -noecho diff -u $file1 $file2
-expect {
-  -re ".+" {
-   set msg "files differ\n"
-   append msg $expect_out(0,string)
-   fail $msg
-   exp_continue
-  }
+if { [catch { exec diff -u $file1 $file2 } msg] } {
+   fail $description
+   verbose -log "'diff':\n$msg"
+} else {
+   pass $description
 }
 return
 }


[gcc/devel/omp/gcc-14] Revert "[og10] vect: Add target hook to prefer gather/scatter instructions"

2024-07-19 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:8678fc697046fba1014f1db6321ee670538b0881

commit 8678fc697046fba1014f1db6321ee670538b0881
Author: Thomas Schwinge 
Date:   Wed Jul 3 12:20:17 2024 +0200

Revert "[og10] vect: Add target hook to prefer gather/scatter instructions"

Testing current OG14 commit 735bbbfc6eaf58522c3ebb0946b66f33958ea134 for
'--target=amdgcn-amdhsa' (I've tested '-march=gfx908', '-march=gfx1100'),
this change has been identified to be causing ~100 instances of execution
test PASS -> FAIL, thus wrong-code generation.  It's possible that we've
had the same misbehavior also on OG13 and earlier, but just nobody ever
tested that.  And/or, that at some point in time, the original patch fell
out of sync, wasn't updated for relevant upstream vectorizer changes.
Until someone gets to analyze that (and upstream these changes here), we
shall revert this commit on OG14.

gcc/
* doc/tm.texi.in (TARGET_VECTORIZE_PREFER_GATHER_SCATTER): Remove
documentation hook.
* doc/tm.texi: Regenerate.
* target.def (prefer_gather_scatter): Remove target hook under
vectorizer.
* tree-vect-stmts.cc (get_group_load_store_type): Remove code to
optionally prefer gather/scatter instructions to
scalar/elementwise fallback.
* config/gcn/gcn.cc (TARGET_VECTORIZE_PREFER_GATHER_SCATTER):
Remove hook definition.

This reverts OG14 commit 4abc54b6d6c3129cf4233e49231b1255b236c2be.

Diff:
---
 gcc/ChangeLog.omp  | 13 +
 gcc/config/gcn/gcn.cc  |  2 --
 gcc/doc/tm.texi|  5 -
 gcc/doc/tm.texi.in |  2 --
 gcc/target.def |  8 
 gcc/tree-vect-stmts.cc |  9 ++---
 6 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index ac4a30e81c8c..3dd5bd03dc99 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,16 @@
+2024-07-03  Thomas Schwinge  
+
+   * doc/tm.texi.in (TARGET_VECTORIZE_PREFER_GATHER_SCATTER): Remove
+   documentation hook.
+   * doc/tm.texi: Regenerate.
+   * target.def (prefer_gather_scatter): Remove target hook under
+   vectorizer.
+   * tree-vect-stmts.cc (get_group_load_store_type): Remove code to
+   optionally prefer gather/scatter instructions to
+   scalar/elementwise fallback.
+   * config/gcn/gcn.cc (TARGET_VECTORIZE_PREFER_GATHER_SCATTER):
+   Remove hook definition.
+
 2024-05-19  Roger Sayle  
 
* config/nvptx/nvptx.md (popcount2): Split into...
diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc
index a247eecd8e8a..d6531f55190c 100644
--- a/gcc/config/gcn/gcn.cc
+++ b/gcc/config/gcn/gcn.cc
@@ -8059,8 +8059,6 @@ gcn_dwarf_register_span (rtx rtl)
   gcn_vector_alignment_reachable
 #undef  TARGET_VECTOR_MODE_SUPPORTED_P
 #define TARGET_VECTOR_MODE_SUPPORTED_P gcn_vector_mode_supported_p
-#undef  TARGET_VECTORIZE_PREFER_GATHER_SCATTER
-#define TARGET_VECTORIZE_PREFER_GATHER_SCATTER true
 
 struct gcc_target targetm = TARGET_INITIALIZER;
 
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index e64c7541f605..c8b8b126b242 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -6482,11 +6482,6 @@ The default is @code{NULL_TREE} which means to not 
vectorize scatter
 stores.
 @end deftypefn
 
-@deftypevr {Target Hook} bool TARGET_VECTORIZE_PREFER_GATHER_SCATTER
-This hook is set to TRUE if gather loads or scatter stores are cheaper on
-this target than a sequence of elementwise loads or stores.
-@end deftypevr
-
 @deftypefn {Target Hook} int TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN 
(struct cgraph_node *@var{}, struct cgraph_simd_clone *@var{}, @var{tree}, 
@var{int}, @var{bool})
 This hook should set @var{vecsize_mangle}, @var{vecsize_int}, 
@var{vecsize_float}
 fields in @var{simd_clone} structure pointed by @var{clone_info} argument and 
also
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 645950b12d78..658e1e63371e 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -4309,8 +4309,6 @@ address;  but often a machine-dependent strategy can 
generate better code.
 
 @hook TARGET_VECTORIZE_BUILTIN_SCATTER
 
-@hook TARGET_VECTORIZE_PREFER_GATHER_SCATTER
-
 @hook TARGET_SIMD_CLONE_COMPUTE_VECSIZE_AND_SIMDLEN
 
 @hook TARGET_SIMD_CLONE_ADJUST
diff --git a/gcc/target.def b/gcc/target.def
index e4b26a7df3ee..fdad7bbc93e2 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -2044,14 +2044,6 @@ all zeros.  GCC can then try to branch around the 
instruction instead.",
  (unsigned ifn),
  default_empty_mask_is_expensive)
 
-/* Prefer gather/scatter loads/stores to e.g. elementwise accesses if\n\
-we cannot use a contiguous access.  */
-DEFHOOKPOD
-(prefer_gather_scatter,
- "This hook is set to TRUE if gather loads or scatter stores are cheaper on\n\
-this target than a sequence of elementwise loads or stores.",
- bool, false)
-
 /* Target builtin that implements vector gather opera

[gcc/devel/omp/gcc-14] Fortran/OpenMP: Support mapping of DT with allocatable components: disable 'generate_callback_wrappe

2024-07-19 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:47fa5cf9ec10bf3b82e211a1b67ab925f8af3178

commit 47fa5cf9ec10bf3b82e211a1b67ab925f8af3178
Author: Thomas Schwinge 
Date:   Wed Jul 3 22:09:39 2024 +0200

Fortran/OpenMP: Support mapping of DT with allocatable components: disable 
'generate_callback_wrapper' for nvptx target

This is, obviously, not the final fix for this issue.

gcc/fortran/
* class.cc (generate_callback_wrapper) [GCC_NVPTX_H]: Disable.

Diff:
---
 gcc/fortran/ChangeLog.omp |  4 
 gcc/fortran/class.cc  | 25 +
 2 files changed, 29 insertions(+)

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index 65b918f4ed76..917fad1de90a 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,7 @@
+2024-07-03  Thomas Schwinge  
+
+   * class.cc (generate_callback_wrapper) [GCC_NVPTX_H]: Disable.
+
 2024-05-15  Jakub Jelinek  
 
* openmp.cc (resolve_omp_clauses): Diagnose grainsize
diff --git a/gcc/fortran/class.cc b/gcc/fortran/class.cc
index 15aacd98fd8a..2c062204e5a4 100644
--- a/gcc/fortran/class.cc
+++ b/gcc/fortran/class.cc
@@ -64,6 +64,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gfortran.h"
 #include "constructor.h"
 #include "target-memory.h"
+#include "tm.h" //TODO
 
 /* Inserts a derived type component reference in a data reference chain.
 TS: base type of the ref chain so far, in which we will pick the component
@@ -2420,6 +2421,30 @@ generate_callback_wrapper (gfc_symbol *vtab, gfc_symbol 
*derived,
   gfc_namespace *ns, const char *tname,
   gfc_component *vtab_cb)
 {
+  //TODO
+#ifdef GCC_NVPTX_H
+  /* Code generated here appears not relevant for nvptx target (completely
+ unused?), but results in erroneous PTX code generated:
+
+ ptxas /tmp/ccAMr7D9.o, line 63; error   : Illegal operand type to 
instruction 'st'
+ ptxas /tmp/ccAMr7D9.o, line 63; error   : Unknown symbol '%stack'
+ ptxas fatal   : Ptx assembly aborted due to errors
+ nvptx-as: ptxas returned 255 exit status
+ compiler exited with status 1
+
+ Note that also outside of OG14 (that is, in GCC 14 as well as GCC trunk),
+ we have a number of instances of this 'ptxas' error, all over the Fortran
+ test suite (only).  The current theory therefore is that there is some
+ latent issue, which is just greatly exacerbated by this code here.
+
+ This could be the Fortran front end generating incorrect GIMPLE, or the
+ middle end or (more likely?) nvptx back end not correctly handling
+ something that only comes into existance via the Fortran front end.
+
+ Until that is resolved, just skip this.  */
+  return;
+#endif
+
   gfc_namespace *sub_ns;
   gfc_code *last_code, *block;
   gfc_symbol *callback, *cb, *token, *this_ptr, *scalar, *flag, *result;


[gcc/devel/omp/gcc-14] libgomp: Document 'GOMP_teams4'

2024-07-19 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:b2de4da92951c56cc17e5ec26bc2a9459b27

commit b2de4da92951c56cc17e5ec26bc2a9459b27
Author: Thomas Schwinge 
Date:   Tue Jul 16 17:09:38 2024 +0200

libgomp: Document 'GOMP_teams4'

For reference:

  -  "[PATCH] 
openmp: Honor OpenMP 5.1 num_teams lower bound"
  -  "[PATCH] 
libgomp, nvptx: Honor OpenMP 5.1 num_teams lower bound"

libgomp/
* config/gcn/target.c (GOMP_teams4): Document.
* config/nvptx/target.c (GOMP_teams4): Likewise.
* target.c (GOMP_teams4): Likewise.

(cherry picked from commit a95c1911d8e8fd0c76fc67232ebc1176162ec8d7)

Diff:
---
 libgomp/ChangeLog.omp | 7 +++
 libgomp/config/gcn/target.c   | 8 
 libgomp/config/nvptx/target.c | 8 
 libgomp/target.c  | 9 +
 4 files changed, 32 insertions(+)

diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 37be690a7b7a..469c6c1f1887 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -3,6 +3,13 @@
Backported from trunk:
2024-07-19  Thomas Schwinge  
 
+   * config/gcn/target.c (GOMP_teams4): Document.
+   * config/nvptx/target.c (GOMP_teams4): Likewise.
+   * target.c (GOMP_teams4): Likewise.
+
+   Backported from trunk:
+   2024-07-19  Thomas Schwinge  
+
* config/gcn/libgomp-gcn.h (GOMP_TEAM_NUM): Inject.
* config/gcn/target.c (GOMP_teams4): Handle.
* config/gcn/team.c (gomp_gcn_enter_kernel): Initialize.
diff --git a/libgomp/config/gcn/target.c b/libgomp/config/gcn/target.c
index 2d8bde625d81..f648866b13bb 100644
--- a/libgomp/config/gcn/target.c
+++ b/libgomp/config/gcn/target.c
@@ -29,6 +29,14 @@
 
 extern volatile struct gomp_offload_icvs GOMP_ADDITIONAL_ICVS;
 
+/* Implement OpenMP 'teams' construct.
+
+   Initialize upon FIRST call.  Return whether this invocation is active.
+   Depending on whether NUM_TEAMS_LOWER asks for more teams than are provided
+   in hardware, we may need to loop multiple times; in that case make sure to
+   update the team-level variable used by 'omp_get_team_num', as we then can't
+   just use '__builtin_gcn_dim_pos (0)'.  */
+
 bool
 GOMP_teams4 (unsigned int num_teams_lower, unsigned int num_teams_upper,
 unsigned int thread_limit, bool first)
diff --git a/libgomp/config/nvptx/target.c b/libgomp/config/nvptx/target.c
index 3db29d4af311..b5c270f3c9cf 100644
--- a/libgomp/config/nvptx/target.c
+++ b/libgomp/config/nvptx/target.c
@@ -31,6 +31,14 @@ extern int __gomp_team_num __attribute__((shared));
 extern volatile struct gomp_offload_icvs GOMP_ADDITIONAL_ICVS;
 volatile struct rev_offload *GOMP_REV_OFFLOAD_VAR;
 
+/* Implement OpenMP 'teams' construct.
+
+   Initialize upon FIRST call.  Return whether this invocation is active.
+   Depending on whether NUM_TEAMS_LOWER asks for more teams than are provided
+   in hardware, we may need to loop multiple times; in that case make sure to
+   update the team-level variable used by 'omp_get_team_num', as we then can't
+   just use '%ctaid.x'.  */
+
 bool
 GOMP_teams4 (unsigned int num_teams_lower, unsigned int num_teams_upper,
 unsigned int thread_limit, bool first)
diff --git a/libgomp/target.c b/libgomp/target.c
index d381a1315391..caa501c27acb 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -4692,6 +4692,8 @@ gomp_target_task_fn (void *data)
   return false;
 }
 
+/* Implement OpenMP 'teams' construct, legacy entry point.  */
+
 void
 GOMP_teams (unsigned int num_teams, unsigned int thread_limit)
 {
@@ -4704,6 +4706,13 @@ GOMP_teams (unsigned int num_teams, unsigned int 
thread_limit)
   (void) num_teams;
 }
 
+/* Implement OpenMP 'teams' construct.
+
+   Initialize upon FIRST call.  Return whether this invocation is active.
+   Depending on whether NUM_TEAMS_LOW asks for more teams than are provided
+   in hardware, we may need to loop multiple times; in that case make sure to
+   update the team-level variable used by 'omp_get_team_num'.  */
+
 bool
 GOMP_teams4 (unsigned int num_teams_low, unsigned int num_teams_high,
 unsigned int thread_limit, bool first)


[gcc/devel/omp/gcc-14] GCN: Honor OpenMP 5.1 'num_teams' lower bound

2024-07-19 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:2432a022ad84aabd4e0d3725a1fe148599096926

commit 2432a022ad84aabd4e0d3725a1fe148599096926
Author: Thomas Schwinge 
Date:   Mon Jul 15 11:19:28 2024 +0200

GCN: Honor OpenMP 5.1 'num_teams' lower bound

Corresponding to commit 9fa72756d90e0d9edadf6e6f5f56476029925788
"libgomp, nvptx: Honor OpenMP 5.1 num_teams lower bound", these are the
GCN offloading changes to fix:

PASS: libgomp.c/../libgomp.c-c++-common/teams-2.c (test for excess 
errors)
[-FAIL:-]{+PASS:+} libgomp.c/../libgomp.c-c++-common/teams-2.c 
execution test

PASS: libgomp.c++/../libgomp.c-c++-common/teams-2.c (test for excess 
errors)
[-FAIL:-]{+PASS:+} libgomp.c++/../libgomp.c-c++-common/teams-2.c 
execution test

..., and omptests' 't-critical' test case.  I've cross checked that those 
test
cases are the ones that regress for nvptx offloading, if I locally revert 
the
"libgomp, nvptx: Honor OpenMP 5.1 num_teams lower bound" changes.

libgomp/
* config/gcn/libgomp-gcn.h (GOMP_TEAM_NUM): Inject.
* config/gcn/target.c (GOMP_teams4): Handle.
* config/gcn/team.c (gomp_gcn_enter_kernel): Initialize.
* config/gcn/teams.c (omp_get_team_num): Adjust.

(cherry picked from commit f9119948cedefa07a667e8beacbd5317a4d8ec1b)

Diff:
---
 libgomp/ChangeLog.omp| 10 ++
 libgomp/config/gcn/libgomp-gcn.h |  9 +
 libgomp/config/gcn/target.c  | 29 -
 libgomp/config/gcn/team.c|  3 +++
 libgomp/config/gcn/teams.c   |  5 +++--
 5 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 614c63346667..37be690a7b7a 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,13 @@
+2024-07-19  Thomas Schwinge  
+
+   Backported from trunk:
+   2024-07-19  Thomas Schwinge  
+
+   * config/gcn/libgomp-gcn.h (GOMP_TEAM_NUM): Inject.
+   * config/gcn/target.c (GOMP_teams4): Handle.
+   * config/gcn/team.c (gomp_gcn_enter_kernel): Initialize.
+   * config/gcn/teams.c (omp_get_team_num): Adjust.
+
 2024-04-16  Andrew Pinski  
 
* gfortran.dg/gomp/atomic-21.f90: Update testcase for the removal of 
`;`.
diff --git a/libgomp/config/gcn/libgomp-gcn.h b/libgomp/config/gcn/libgomp-gcn.h
index e94f0c7ae689..48a3741b04dd 100644
--- a/libgomp/config/gcn/libgomp-gcn.h
+++ b/libgomp/config/gcn/libgomp-gcn.h
@@ -34,10 +34,11 @@
 #define DEFAULT_TEAM_ARENA_SIZE (64*1024)
 
 /* These define the LDS location of data needed by OpenMP.  */
-#define TEAM_ARENA_START 16  /* LDS offset of free pointer.  */
-#define TEAM_ARENA_FREE  24  /* LDS offset of free pointer.  */
-#define TEAM_ARENA_END   32  /* LDS offset of end pointer.  */
-#define GCN_LOWLAT_HEAP  40  /* LDS offset of the OpenMP low-latency heap.  */
+#define GOMP_TEAM_NUM16
+#define TEAM_ARENA_START 24  /* LDS offset of free pointer.  */
+#define TEAM_ARENA_FREE  32  /* LDS offset of free pointer.  */
+#define TEAM_ARENA_END   40  /* LDS offset of end pointer.  */
+#define GCN_LOWLAT_HEAP  48  /* LDS offset of the OpenMP low-latency heap.  */
 
 struct heap
 {
diff --git a/libgomp/config/gcn/target.c b/libgomp/config/gcn/target.c
index cc043c7b23ac..2d8bde625d81 100644
--- a/libgomp/config/gcn/target.c
+++ b/libgomp/config/gcn/target.c
@@ -33,26 +33,37 @@ bool
 GOMP_teams4 (unsigned int num_teams_lower, unsigned int num_teams_upper,
 unsigned int thread_limit, bool first)
 {
+  int __lds *gomp_team_num = (int __lds *) GOMP_TEAM_NUM;
+  unsigned int num_workgroups = __builtin_gcn_dim_size (0);
   if (!first)
-return false;
+{
+  unsigned int team_num;
+  if (num_workgroups > gomp_num_teams_var)
+   return false;
+  team_num = *gomp_team_num;
+  if (team_num > gomp_num_teams_var - num_workgroups)
+   return false;
+  *gomp_team_num = team_num + num_workgroups;
+  return true;
+}
   if (thread_limit)
 {
   struct gomp_task_icv *icv = gomp_icv (true);
   icv->thread_limit_var
= thread_limit > INT_MAX ? UINT_MAX : thread_limit;
 }
-  unsigned int num_workgroups, workgroup_id;
-  num_workgroups = __builtin_gcn_dim_size (0);
-  workgroup_id = __builtin_gcn_dim_pos (0);
-  /* FIXME: If num_teams_lower > num_workgroups, we want to loop
- multiple times at least for some workgroups.  */
-  (void) num_teams_lower;
-  if (!num_teams_upper || num_teams_upper >= num_workgroups)
+  if (!num_teams_upper)
 num_teams_upper = ((GOMP_ADDITIONAL_ICVS.nteams > 0
&& num_workgroups > GOMP_ADDITIONAL_ICVS.nteams)
   ? GOMP_ADDITIONAL_ICVS.nteams : num_workgroups);
-  else if (workgroup_id >= num_teams_upper)
+  else if (num_workgroups < num_teams_lower)
+num_teams_upper = num_teams_lower;
+  else if (num_workgroups < num_teams_upper)
+num_teams_upper = num_workgroups;
+  unsign

[gcc r15-2164] libgomp: Document 'GOMP_teams4'

2024-07-19 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:a95c1911d8e8fd0c76fc67232ebc1176162ec8d7

commit r15-2164-ga95c1911d8e8fd0c76fc67232ebc1176162ec8d7
Author: Thomas Schwinge 
Date:   Tue Jul 16 17:09:38 2024 +0200

libgomp: Document 'GOMP_teams4'

For reference:

  -  "[PATCH] 
openmp: Honor OpenMP 5.1 num_teams lower bound"
  -  "[PATCH] 
libgomp, nvptx: Honor OpenMP 5.1 num_teams lower bound"

libgomp/
* config/gcn/target.c (GOMP_teams4): Document.
* config/nvptx/target.c (GOMP_teams4): Likewise.
* target.c (GOMP_teams4): Likewise.

Diff:
---
 libgomp/config/gcn/target.c   | 8 
 libgomp/config/nvptx/target.c | 8 
 libgomp/target.c  | 9 +
 3 files changed, 25 insertions(+)

diff --git a/libgomp/config/gcn/target.c b/libgomp/config/gcn/target.c
index e57d2e5f93f1..9cafea4e2cc7 100644
--- a/libgomp/config/gcn/target.c
+++ b/libgomp/config/gcn/target.c
@@ -29,6 +29,14 @@
 
 extern volatile struct gomp_offload_icvs GOMP_ADDITIONAL_ICVS;
 
+/* Implement OpenMP 'teams' construct.
+
+   Initialize upon FIRST call.  Return whether this invocation is active.
+   Depending on whether NUM_TEAMS_LOWER asks for more teams than are provided
+   in hardware, we may need to loop multiple times; in that case make sure to
+   update the team-level variable used by 'omp_get_team_num', as we then can't
+   just use '__builtin_gcn_dim_pos (0)'.  */
+
 bool
 GOMP_teams4 (unsigned int num_teams_lower, unsigned int num_teams_upper,
 unsigned int thread_limit, bool first)
diff --git a/libgomp/config/nvptx/target.c b/libgomp/config/nvptx/target.c
index f14dcfc8ff6a..8d4dc5f661a2 100644
--- a/libgomp/config/nvptx/target.c
+++ b/libgomp/config/nvptx/target.c
@@ -31,6 +31,14 @@ extern int __gomp_team_num __attribute__((shared));
 extern volatile struct gomp_offload_icvs GOMP_ADDITIONAL_ICVS;
 volatile struct rev_offload *GOMP_REV_OFFLOAD_VAR;
 
+/* Implement OpenMP 'teams' construct.
+
+   Initialize upon FIRST call.  Return whether this invocation is active.
+   Depending on whether NUM_TEAMS_LOWER asks for more teams than are provided
+   in hardware, we may need to loop multiple times; in that case make sure to
+   update the team-level variable used by 'omp_get_team_num', as we then can't
+   just use '%ctaid.x'.  */
+
 bool
 GOMP_teams4 (unsigned int num_teams_lower, unsigned int num_teams_upper,
 unsigned int thread_limit, bool first)
diff --git a/libgomp/target.c b/libgomp/target.c
index 48689920d4a3..aa01c1367b98 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -4352,6 +4352,8 @@ gomp_target_task_fn (void *data)
   return false;
 }
 
+/* Implement OpenMP 'teams' construct, legacy entry point.  */
+
 void
 GOMP_teams (unsigned int num_teams, unsigned int thread_limit)
 {
@@ -4364,6 +4366,13 @@ GOMP_teams (unsigned int num_teams, unsigned int 
thread_limit)
   (void) num_teams;
 }
 
+/* Implement OpenMP 'teams' construct.
+
+   Initialize upon FIRST call.  Return whether this invocation is active.
+   Depending on whether NUM_TEAMS_LOW asks for more teams than are provided
+   in hardware, we may need to loop multiple times; in that case make sure to
+   update the team-level variable used by 'omp_get_team_num'.  */
+
 bool
 GOMP_teams4 (unsigned int num_teams_low, unsigned int num_teams_high,
 unsigned int thread_limit, bool first)


[gcc r15-2163] GCN: Honor OpenMP 5.1 'num_teams' lower bound

2024-07-19 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:f9119948cedefa07a667e8beacbd5317a4d8ec1b

commit r15-2163-gf9119948cedefa07a667e8beacbd5317a4d8ec1b
Author: Thomas Schwinge 
Date:   Mon Jul 15 11:19:28 2024 +0200

GCN: Honor OpenMP 5.1 'num_teams' lower bound

Corresponding to commit 9fa72756d90e0d9edadf6e6f5f56476029925788
"libgomp, nvptx: Honor OpenMP 5.1 num_teams lower bound", these are the
GCN offloading changes to fix:

PASS: libgomp.c/../libgomp.c-c++-common/teams-2.c (test for excess 
errors)
[-FAIL:-]{+PASS:+} libgomp.c/../libgomp.c-c++-common/teams-2.c 
execution test

PASS: libgomp.c++/../libgomp.c-c++-common/teams-2.c (test for excess 
errors)
[-FAIL:-]{+PASS:+} libgomp.c++/../libgomp.c-c++-common/teams-2.c 
execution test

..., and omptests' 't-critical' test case.  I've cross checked that those 
test
cases are the ones that regress for nvptx offloading, if I locally revert 
the
"libgomp, nvptx: Honor OpenMP 5.1 num_teams lower bound" changes.

libgomp/
* config/gcn/libgomp-gcn.h (GOMP_TEAM_NUM): Inject.
* config/gcn/target.c (GOMP_teams4): Handle.
* config/gcn/team.c (gomp_gcn_enter_kernel): Initialize.
* config/gcn/teams.c (omp_get_team_num): Adjust.

Diff:
---
 libgomp/config/gcn/libgomp-gcn.h |  9 +
 libgomp/config/gcn/target.c  | 29 -
 libgomp/config/gcn/team.c|  3 +++
 libgomp/config/gcn/teams.c   |  5 +++--
 4 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/libgomp/config/gcn/libgomp-gcn.h b/libgomp/config/gcn/libgomp-gcn.h
index e94f0c7ae689..48a3741b04dd 100644
--- a/libgomp/config/gcn/libgomp-gcn.h
+++ b/libgomp/config/gcn/libgomp-gcn.h
@@ -34,10 +34,11 @@
 #define DEFAULT_TEAM_ARENA_SIZE (64*1024)
 
 /* These define the LDS location of data needed by OpenMP.  */
-#define TEAM_ARENA_START 16  /* LDS offset of free pointer.  */
-#define TEAM_ARENA_FREE  24  /* LDS offset of free pointer.  */
-#define TEAM_ARENA_END   32  /* LDS offset of end pointer.  */
-#define GCN_LOWLAT_HEAP  40  /* LDS offset of the OpenMP low-latency heap.  */
+#define GOMP_TEAM_NUM16
+#define TEAM_ARENA_START 24  /* LDS offset of free pointer.  */
+#define TEAM_ARENA_FREE  32  /* LDS offset of free pointer.  */
+#define TEAM_ARENA_END   40  /* LDS offset of end pointer.  */
+#define GCN_LOWLAT_HEAP  48  /* LDS offset of the OpenMP low-latency heap.  */
 
 struct heap
 {
diff --git a/libgomp/config/gcn/target.c b/libgomp/config/gcn/target.c
index 1d4a23cb8d20..e57d2e5f93f1 100644
--- a/libgomp/config/gcn/target.c
+++ b/libgomp/config/gcn/target.c
@@ -33,26 +33,37 @@ bool
 GOMP_teams4 (unsigned int num_teams_lower, unsigned int num_teams_upper,
 unsigned int thread_limit, bool first)
 {
+  int __lds *gomp_team_num = (int __lds *) GOMP_TEAM_NUM;
+  unsigned int num_workgroups = __builtin_gcn_dim_size (0);
   if (!first)
-return false;
+{
+  unsigned int team_num;
+  if (num_workgroups > gomp_num_teams_var)
+   return false;
+  team_num = *gomp_team_num;
+  if (team_num > gomp_num_teams_var - num_workgroups)
+   return false;
+  *gomp_team_num = team_num + num_workgroups;
+  return true;
+}
   if (thread_limit)
 {
   struct gomp_task_icv *icv = gomp_icv (true);
   icv->thread_limit_var
= thread_limit > INT_MAX ? UINT_MAX : thread_limit;
 }
-  unsigned int num_workgroups, workgroup_id;
-  num_workgroups = __builtin_gcn_dim_size (0);
-  workgroup_id = __builtin_gcn_dim_pos (0);
-  /* FIXME: If num_teams_lower > num_workgroups, we want to loop
- multiple times at least for some workgroups.  */
-  (void) num_teams_lower;
-  if (!num_teams_upper || num_teams_upper >= num_workgroups)
+  if (!num_teams_upper)
 num_teams_upper = ((GOMP_ADDITIONAL_ICVS.nteams > 0
&& num_workgroups > GOMP_ADDITIONAL_ICVS.nteams)
   ? GOMP_ADDITIONAL_ICVS.nteams : num_workgroups);
-  else if (workgroup_id >= num_teams_upper)
+  else if (num_workgroups < num_teams_lower)
+num_teams_upper = num_teams_lower;
+  else if (num_workgroups < num_teams_upper)
+num_teams_upper = num_workgroups;
+  unsigned int workgroup_id = __builtin_gcn_dim_pos (0);
+  if (workgroup_id >= num_teams_upper)
 return false;
+  *gomp_team_num = workgroup_id;
   gomp_num_teams_var = num_teams_upper - 1;
   return true;
 }
diff --git a/libgomp/config/gcn/team.c b/libgomp/config/gcn/team.c
index bd3df448b522..aa68b3abe0b3 100644
--- a/libgomp/config/gcn/team.c
+++ b/libgomp/config/gcn/team.c
@@ -68,6 +68,9 @@ gomp_gcn_enter_kernel (void)
   /* Starting additional threads is not supported.  */
   gomp_global_icv.dyn_var = true;
 
+  int __lds *gomp_team_num = (int __lds *) GOMP_TEAM_NUM;
+  *gomp_team_num = 0;
+
   /* Initialize the team arena for optimized memory allocation.
  The arena has been allocated on the host side, an

[gcc r15-2162] Rewrite usage comment at the top of 'gcc/passes.def'

2024-07-19 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:385004846dc6437bab9b3b7d8b071ce1c3418384

commit r15-2162-g385004846dc6437bab9b3b7d8b071ce1c3418384
Author: Thomas Schwinge 
Date:   Fri Jun 28 14:05:04 2024 +0200

Rewrite usage comment at the top of 'gcc/passes.def'

Since Subversion r201359 (Git commit 
a167b052dfe9a8509bb23c374ffaeee953df0917)
"Introduce gen-pass-instances.awk and pass-instances.def", the usage 
comment at
the top of 'gcc/passes.def' no longer is accurate (even if that latter file
does continue to use the 'NEXT_PASS' form without 'NUM') -- and, worse, the
'NEXT_PASS' etc. in that usage comment are processed by the
'gcc/gen-pass-instances.awk' script:

--- source-gcc/gcc/passes.def   2024-06-24 18:55:15.132561641 +0200
+++ build-gcc/gcc/pass-instances.def2024-06-24 18:55:27.768562714 
+0200
[...]
@@ -20,546 +22,578 @@
 /*
  Macros that should be defined when using this file:
INSERT_PASSES_AFTER (PASS)
PUSH_INSERT_PASSES_WITHIN (PASS)
POP_INSERT_PASSES ()
-   NEXT_PASS (PASS)
+   NEXT_PASS (PASS, 1)
TERMINATE_PASS_LIST (PASS)
  */
[...]

(That is, this is 'NEXT_PASS' for the first instance of pass 'PASS'.)
That's benign so far, but with another thing that I'll be extending, I'd
then run into an error while the script handles this comment block.  ;-\

gcc/
* passes.def: Rewrite usage comment at the top.

Diff:
---
 gcc/passes.def | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/gcc/passes.def b/gcc/passes.def
index 5e7f9395d84f..b06d6d45f631 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -17,14 +17,11 @@ You should have received a copy of the GNU General Public 
License
 along with GCC; see the file COPYING3.  If not see
 .  */
 
-/*
- Macros that should be defined when using this file:
-   INSERT_PASSES_AFTER (PASS)
-   PUSH_INSERT_PASSES_WITHIN (PASS)
-   POP_INSERT_PASSES ()
-   NEXT_PASS (PASS)
-   TERMINATE_PASS_LIST (PASS)
- */
+/* Note that this file is processed by a simple parser:
+   'gen-pass-instances.awk', so carefully verify the generated
+   'pass-instances.def' if you deviate from the syntax otherwise used in
+   here.  */
+
 
  /* All passes needed to lower the function into shape optimizers can
 operate on.  These passes are always run first on the function, but


[gcc r15-1607] rs6000: Properly default-disable late-combine passes [PR106594, PR115622, PR115633]

2024-06-25 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:70480055636c2ca79761cb4440e930daa16bb7aa

commit r15-1607-g70480055636c2ca79761cb4440e930daa16bb7aa
Author: Thomas Schwinge 
Date:   Tue Jun 25 10:55:41 2024 +0200

rs6000: Properly default-disable late-combine passes [PR106594, PR115622, 
PR115633]

..., so that it also works for '__attribute__ ((optimize("[...]")))' etc.

PR target/106594
PR target/115622
PR target/115633
gcc/
* config/rs6000/rs6000.cc (rs6000_option_override_internal): Move
default-disable of late-combine passes from here...
(rs6000_override_options_after_change): ... to here.

Diff:
---
 gcc/config/rs6000/rs6000.cc | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index cd14e5a34ed..71fe31297cf 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -3434,6 +3434,14 @@ rs6000_override_options_after_change (void)
   /* If we are inserting ROP-protect instructions, disable shrink wrap.  */
   if (rs6000_rop_protect)
 flag_shrink_wrap = 0;
+
+  /* One of the late-combine passes runs after register allocation
+ and can match define_insn_and_splits that were previously used
+ only before register allocation.  Some of those define_insn_and_splits
+ use gen_reg_rtx unconditionally.  Disable late-combine by default
+ until the define_insn_and_splits are fixed.  */
+  if (!OPTION_SET_P (flag_late_combine_instructions))
+flag_late_combine_instructions = 0;
 }
 
 #ifdef TARGET_USES_LINUX64_OPT
@@ -4771,14 +4779,6 @@ rs6000_option_override_internal (bool global_init_p)
targetm.expand_builtin_va_start = NULL;
 }
 
-  /* One of the late-combine passes runs after register allocation
- and can match define_insn_and_splits that were previously used
- only before register allocation.  Some of those define_insn_and_splits
- use gen_reg_rtx unconditionally.  Disable late-combine by default
- until the define_insn_and_splits are fixed.  */
-  if (!OPTION_SET_P (flag_late_combine_instructions))
-flag_late_combine_instructions = 0;
-
   rs6000_override_options_after_change ();
 
   /* If not explicitly specified via option, decide whether to generate indexed


[gcc r15-1068] nvptx, libgcc: Stub unwinding implementation

2024-06-06 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:a29c5852a606588175d11844db84da0881227100

commit r15-1068-ga29c5852a606588175d11844db84da0881227100
Author: Thomas Schwinge 
Date:   Wed Jun 5 13:11:04 2024 +0200

nvptx, libgcc: Stub unwinding implementation

Adding stub '_Unwind_Backtrace', '_Unwind_GetIPInfo' functions is necessary
for linking libbacktrace, as a normal (non-'LIBGFOR_MINIMAL') configuration
of libgfortran wants to do, for example.

The file 'libgcc/config/nvptx/unwind-nvptx.c' is copied from
'libgcc/config/gcn/unwind-gcn.c'.

libgcc/ChangeLog:

* config/nvptx/t-nvptx: Add unwind-nvptx.c.
* config/nvptx/unwind-nvptx.c: New file.

Co-authored-by: Andrew Stubbs 

Diff:
---
 libgcc/config/nvptx/t-nvptx|  3 ++-
 libgcc/config/nvptx/unwind-nvptx.c | 37 +
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/libgcc/config/nvptx/t-nvptx b/libgcc/config/nvptx/t-nvptx
index 260ed6334db..1ff574c2982 100644
--- a/libgcc/config/nvptx/t-nvptx
+++ b/libgcc/config/nvptx/t-nvptx
@@ -1,6 +1,7 @@
 LIB2ADD=$(srcdir)/config/nvptx/reduction.c \
$(srcdir)/config/nvptx/mgomp.c \
-   $(srcdir)/config/nvptx/atomic.c
+   $(srcdir)/config/nvptx/atomic.c \
+   $(srcdir)/config/nvptx/unwind-nvptx.c
 
 # Until we have libstdc++-v3/libsupc++ proper.
 LIB2ADD += $(srcdir)/c++-minimal/guard.c
diff --git a/libgcc/config/nvptx/unwind-nvptx.c 
b/libgcc/config/nvptx/unwind-nvptx.c
new file mode 100644
index 000..d08ba266be1
--- /dev/null
+++ b/libgcc/config/nvptx/unwind-nvptx.c
@@ -0,0 +1,37 @@
+/* Stub unwinding implementation.
+
+   Copyright (C) 2019-2024 Free Software Foundation, Inc.
+   Contributed by Mentor Graphics
+
+   This file is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 3, or (at your option) any
+   later version.
+
+   This file is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   .  */
+
+#include "unwind.h"
+
+_Unwind_Reason_Code
+_Unwind_Backtrace(_Unwind_Trace_Fn trace, void * trace_argument)
+{
+  return 0;
+}
+
+_Unwind_Ptr
+_Unwind_GetIPInfo (struct _Unwind_Context *c, int *ip_before_insn)
+{
+  return 0;
+}


[gcc r15-1069] nvptx offloading: 'GOMP_NVPTX_NATIVE_GPU_THREAD_STACK_SIZE' environment variable [PR97384, PR105274]

2024-06-06 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:0d25989d60d15866ef4737d66e02432f50717255

commit r15-1069-g0d25989d60d15866ef4737d66e02432f50717255
Author: Thomas Schwinge 
Date:   Fri May 31 17:04:39 2024 +0200

nvptx offloading: 'GOMP_NVPTX_NATIVE_GPU_THREAD_STACK_SIZE' environment 
variable [PR97384, PR105274]

... as a means to manually set the "native" GPU thread stack size.

PR libgomp/97384
PR libgomp/105274
libgomp/
* plugin/cuda-lib.def (cuCtxSetLimit): Add.
* plugin/plugin-nvptx.c (nvptx_open_device): Handle
'GOMP_NVPTX_NATIVE_GPU_THREAD_STACK_SIZE' environment variable.

Diff:
---
 libgomp/plugin/cuda-lib.def   |  1 +
 libgomp/plugin/plugin-nvptx.c | 45 +++
 2 files changed, 46 insertions(+)

diff --git a/libgomp/plugin/cuda-lib.def b/libgomp/plugin/cuda-lib.def
index 007c6e0f4df..9255c1cff68 100644
--- a/libgomp/plugin/cuda-lib.def
+++ b/libgomp/plugin/cuda-lib.def
@@ -4,6 +4,7 @@ CUDA_ONE_CALL (cuCtxGetCurrent)
 CUDA_ONE_CALL (cuCtxGetDevice)
 CUDA_ONE_CALL (cuCtxPopCurrent)
 CUDA_ONE_CALL (cuCtxPushCurrent)
+CUDA_ONE_CALL (cuCtxSetLimit)
 CUDA_ONE_CALL (cuCtxSynchronize)
 CUDA_ONE_CALL (cuDeviceGet)
 CUDA_ONE_CALL (cuDeviceGetAttribute)
diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index 0f3a3be1898..99cbcb699b3 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -150,6 +150,8 @@ init_cuda_lib (void)
 
 #include "secure_getenv.h"
 
+static void notify_var (const char *, const char *);
+
 #undef MIN
 #undef MAX
 #define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
@@ -341,6 +343,9 @@ struct ptx_device
 
 static struct ptx_device **ptx_devices;
 
+/* "Native" GPU thread stack size.  */
+static unsigned native_gpu_thread_stack_size = 0;
+
 /* OpenMP kernels reserve a small amount of ".shared" space for use by
omp_alloc.  The size is configured using GOMP_NVPTX_LOWLAT_POOL, but the
default is set here.  */
@@ -555,6 +560,46 @@ nvptx_open_device (int n)
   ptx_dev->free_blocks = NULL;
   pthread_mutex_init (&ptx_dev->free_blocks_lock, NULL);
 
+  /* "Native" GPU thread stack size.  */
+  {
+/* This is intentionally undocumented, until we work out a proper, common
+   scheme (as much as makes sense) between all offload plugins as well
+   as between nvptx offloading use of "native" stacks for OpenACC vs.
+   OpenMP "soft stacks" vs. OpenMP '-msoft-stack-reserve-local=[...]'.
+
+   GCN offloading has a 'GCN_STACK_SIZE' environment variable (without
+   'GOMP_' prefix): documented; presumably used for all things OpenACC and
+   OpenMP?  Based on GCN command-line option '-mstack-size=[...]' (marked
+   "obsolete"), that one may be set via a GCN 'mkoffload'-synthesized
+   'constructor' function.  */
+const char *var_name = "GOMP_NVPTX_NATIVE_GPU_THREAD_STACK_SIZE";
+const char *env_var = secure_getenv (var_name);
+notify_var (var_name, env_var);
+
+if (env_var != NULL)
+  {
+   char *endptr;
+   unsigned long val = strtoul (env_var, &endptr, 10);
+   if (endptr == NULL || *endptr != '\0'
+   || errno == ERANGE || errno == EINVAL
+   || val > UINT_MAX)
+ GOMP_PLUGIN_error ("Error parsing %s", var_name);
+   else
+ native_gpu_thread_stack_size = val;
+  }
+  }
+  if (native_gpu_thread_stack_size == 0)
+; /* Zero means use default.  */
+  else
+{
+  GOMP_PLUGIN_debug (0, "Setting \"native\" GPU thread stack size"
+" ('CU_LIMIT_STACK_SIZE') to %u bytes\n",
+native_gpu_thread_stack_size);
+  CUDA_CALL (cuCtxSetLimit,
+CU_LIMIT_STACK_SIZE, (size_t) native_gpu_thread_stack_size);
+}
+
+  /* OpenMP "soft stacks".  */
   ptx_dev->omp_stacks.ptr = 0;
   ptx_dev->omp_stacks.size = 0;
   pthread_mutex_init (&ptx_dev->omp_stacks.lock, NULL);


[gcc r15-1070] nvptx, libgfortran: Switch out of "minimal" mode

2024-06-06 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:3a4775d4403f2e88b589e88a9937cc1fd45a0e87

commit r15-1070-g3a4775d4403f2e88b589e88a9937cc1fd45a0e87
Author: Thomas Schwinge 
Date:   Wed Jun 5 13:13:24 2024 +0200

nvptx, libgfortran: Switch out of "minimal" mode

..., in order to enable (portions of) Fortran I/O, for example.

libgfortran/
* configure.ac: No longer set 'LIBGFOR_MINIMAL' for nvptx.
* configure: Regenerate.
libgomp/
* libgomp.texi (nvptx): Update.
* testsuite/libgomp.fortran/target-print-1-nvptx.f90: Remove.
* testsuite/libgomp.fortran/target-print-1.f90: Adjust.
* testsuite/libgomp.oacc-fortran/error_stop-2-nvptx.f: New.
* testsuite/libgomp.oacc-fortran/error_stop-2.f: Adjust.
* testsuite/libgomp.oacc-fortran/print-1-nvptx.f90: Adjust.
* testsuite/libgomp.oacc-fortran/print-1.f90: Adjust.
* testsuite/libgomp.oacc-fortran/stop-2-nvptx.f: New.
* testsuite/libgomp.oacc-fortran/stop-2.f: Adjust.

Co-authored-by: Andrew Stubbs 

Diff:
---
 libgfortran/configure  | 21 +---
 libgfortran/configure.ac   | 17 -
 libgomp/libgomp.texi   | 10 +++---
 .../libgomp.fortran/target-print-1-nvptx.f90   | 11 --
 .../testsuite/libgomp.fortran/target-print-1.f90   |  3 --
 .../libgomp.oacc-fortran/error_stop-2-nvptx.f  | 39 +
 .../testsuite/libgomp.oacc-fortran/error_stop-2.f  |  3 +-
 .../libgomp.oacc-fortran/print-1-nvptx.f90 | 40 ++
 libgomp/testsuite/libgomp.oacc-fortran/print-1.f90 |  4 +--
 .../testsuite/libgomp.oacc-fortran/stop-2-nvptx.f  | 36 +++
 libgomp/testsuite/libgomp.oacc-fortran/stop-2.f|  3 +-
 11 files changed, 134 insertions(+), 53 deletions(-)

diff --git a/libgfortran/configure b/libgfortran/configure
index 774dd52fc95..11a1bc5f070 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -6207,17 +6207,12 @@ else
 fi
 
 
-# For GPU offloading, not everything in libfortran can be supported.
-# Currently, the only target that has this problem is nvptx.  The
-# following is a (partial) list of features that are unsupportable on
-# this particular target:
-# * Constructors
-# * alloca
-# * C library support for I/O, with printf as the one notable exception
-# * C library support for other features such as signal, environment
-#   variables, time functions
-
- if test "x${target_cpu}" = xnvptx; then
+# "Minimal" mode is for targets that cannot (yet) support all features of
+# libgfortran.  It avoids the need for working constructors, alloca, and C
+# library support for I/O, signals, environment variables, time functions, etc.
+# At present there are no targets that require this mode.
+
+ if false; then
   LIBGFOR_MINIMAL_TRUE=
   LIBGFOR_MINIMAL_FALSE='#'
 else
@@ -12852,7 +12847,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12855 "configure"
+#line 12850 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12958,7 +12953,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12961 "configure"
+#line 12956 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index 46585a3ee14..cca1ea0ea97 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -209,17 +209,12 @@ AM_CONDITIONAL(LIBGFOR_USE_SYMVER, [test 
"x$gfortran_use_symver" != xno])
 AM_CONDITIONAL(LIBGFOR_USE_SYMVER_GNU, [test "x$gfortran_use_symver" = xgnu])
 AM_CONDITIONAL(LIBGFOR_USE_SYMVER_SUN, [test "x$gfortran_use_symver" = xsun])
 
-# For GPU offloading, not everything in libfortran can be supported.
-# Currently, the only target that has this problem is nvptx.  The
-# following is a (partial) list of features that are unsupportable on
-# this particular target:
-# * Constructors
-# * alloca
-# * C library support for I/O, with printf as the one notable exception
-# * C library support for other features such as signal, environment
-#   variables, time functions
-
-AM_CONDITIONAL(LIBGFOR_MINIMAL, [test "x${target_cpu}" = xnvptx])
+# "Minimal" mode is for targets that cannot (yet) support all features of
+# libgfortran.  It avoids the need for working constructors, alloca, and C
+# library support for I/O, signals, environment variables, time functions, etc.
+# At present there are no targets that require this mode.
+
+AM_CONDITIONAL(LIBGFOR_MINIMAL, false)
 
 # Some compiler target support may have limited support for integer
 # or floating point numbers – or may want to reduce the libgfortran size
diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index c52bb2672c6..eb608915938 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -

[gcc r15-1067] nvptx offloading: Global constructor, destructor support, via nvptx-tools 'ld'

2024-06-06 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:5bbe5350a0932c78d4ffce292ba4104a6fe6ef96

commit r15-1067-g5bbe5350a0932c78d4ffce292ba4104a6fe6ef96
Author: Thomas Schwinge 
Date:   Wed Jun 5 12:40:50 2024 +0200

nvptx offloading: Global constructor, destructor support, via nvptx-tools 
'ld'

This extends commit d9c90c82d900fdae95df4499bf5f0a4ecb903b53
"nvptx target: Global constructor, destructor support, via nvptx-tools 'ld'"
for offloading.

libgcc/
* config/nvptx/gbl-ctors.c ["mgomp"]
(__do_global_ctors__entry__mgomp)
(__do_global_dtors__entry__mgomp): New.
[!"mgomp"] (__do_global_ctors__entry, __do_global_dtors__entry):
New.
libgomp/
* plugin/plugin-nvptx.c (nvptx_do_global_cdtors): New.
(nvptx_close_device, GOMP_OFFLOAD_load_image)
(GOMP_OFFLOAD_unload_image): Call it.

Diff:
---
 libgcc/config/nvptx/gbl-ctors.c |  55 +++
 libgomp/plugin/plugin-nvptx.c   | 117 +++-
 2 files changed, 171 insertions(+), 1 deletion(-)

diff --git a/libgcc/config/nvptx/gbl-ctors.c b/libgcc/config/nvptx/gbl-ctors.c
index a2ca053e5e3..a56d64f8ef8 100644
--- a/libgcc/config/nvptx/gbl-ctors.c
+++ b/libgcc/config/nvptx/gbl-ctors.c
@@ -68,6 +68,61 @@ __gbl_ctors (void)
 }
 
 
+/* For nvptx offloading configurations, need '.entry' wrappers.  */
+
+# if defined(__nvptx_softstack__) && defined(__nvptx_unisimt__)
+
+/* OpenMP */
+
+/* See 'crt0.c', 'mgomp.c'.  */
+extern void *__nvptx_stacks[32] __attribute__((shared,nocommon));
+extern unsigned __nvptx_uni[32] __attribute__((shared,nocommon));
+
+__attribute__((kernel)) void __do_global_ctors__entry__mgomp (void *);
+
+void
+__do_global_ctors__entry__mgomp (void *nvptx_stacks_0)
+{
+  __nvptx_stacks[0] = nvptx_stacks_0;
+  __nvptx_uni[0] = 0;
+
+  __static_do_global_ctors ();
+}
+
+__attribute__((kernel)) void __do_global_dtors__entry__mgomp (void *);
+
+void
+__do_global_dtors__entry__mgomp (void *nvptx_stacks_0)
+{
+  __nvptx_stacks[0] = nvptx_stacks_0;
+  __nvptx_uni[0] = 0;
+
+  __static_do_global_dtors ();
+}
+
+# else
+
+/* OpenACC */
+
+__attribute__((kernel)) void __do_global_ctors__entry (void);
+
+void
+__do_global_ctors__entry (void)
+{
+  __static_do_global_ctors ();
+}
+
+__attribute__((kernel)) void __do_global_dtors__entry (void);
+
+void
+__do_global_dtors__entry (void)
+{
+  __static_do_global_dtors ();
+}
+
+# endif
+
+
 /* The following symbol just provides a means for the nvptx-tools 'ld' to
trigger linking in this file.  */
 
diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index 4cedc5390a3..0f3a3be1898 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -346,6 +346,11 @@ static struct ptx_device **ptx_devices;
default is set here.  */
 static unsigned lowlat_pool_size = 8 * 1024;
 
+static bool nvptx_do_global_cdtors (CUmodule, struct ptx_device *,
+   const char *);
+static size_t nvptx_stacks_size ();
+static void *nvptx_stacks_acquire (struct ptx_device *, size_t, int);
+
 static inline struct nvptx_thread *
 nvptx_thread (void)
 {
@@ -565,6 +570,18 @@ nvptx_close_device (struct ptx_device *ptx_dev)
   if (!ptx_dev)
 return true;
 
+  bool ret = true;
+
+  for (struct ptx_image_data *image = ptx_dev->images;
+   image != NULL;
+   image = image->next)
+{
+  if (!nvptx_do_global_cdtors (image->module, ptx_dev,
+  "__do_global_dtors__entry"
+  /* or "__do_global_dtors__entry__mgomp" */))
+   ret = false;
+}
+
   for (struct ptx_free_block *b = ptx_dev->free_blocks; b;)
 {
   struct ptx_free_block *b_next = b->next;
@@ -585,7 +602,8 @@ nvptx_close_device (struct ptx_device *ptx_dev)
 CUDA_CALL (cuCtxDestroy, ptx_dev->ctx);
 
   free (ptx_dev);
-  return true;
+
+  return ret;
 }
 
 static int
@@ -1317,6 +1335,93 @@ nvptx_set_clocktick (CUmodule module, struct ptx_device 
*dev)
 GOMP_PLUGIN_fatal ("cuMemcpyHtoD error: %s", cuda_error (r));
 }
 
+/* Invoke MODULE's global constructors/destructors.  */
+
+static bool
+nvptx_do_global_cdtors (CUmodule module, struct ptx_device *ptx_dev,
+   const char *funcname)
+{
+  bool ret = true;
+  char *funcname_mgomp = NULL;
+  CUresult r;
+  CUfunction funcptr;
+  r = CUDA_CALL_NOCHECK (cuModuleGetFunction,
+&funcptr, module, funcname);
+  GOMP_PLUGIN_debug (0, "cuModuleGetFunction (%s): %s\n",
+funcname, cuda_error (r));
+  if (r == CUDA_ERROR_NOT_FOUND)
+{
+  /* Try '[funcname]__mgomp'.  */
+
+  size_t funcname_len = strlen (funcname);
+  const char *mgomp_suffix = "__mgomp";
+  size_t mgomp_suffix_len = strlen (mgomp_suffix);
+  funcname_mgomp
+   = GOMP_PLUGIN_malloc (funcname_len + mgomp_suffix_len + 1);
+  memcpy (funcname_mgomp, funcname, funcname_len)

[gcc r15-1066] nvptx: Make 'nvptx_uniform_warp_check' fit for non-full-warp execution, via 'vote.all.pred'

2024-06-06 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:b4e68dd9084e48ee3e83c11d7f27548d8cca7066

commit r15-1066-gb4e68dd9084e48ee3e83c11d7f27548d8cca7066
Author: Thomas Schwinge 
Date:   Fri May 10 12:50:23 2024 +0200

nvptx: Make 'nvptx_uniform_warp_check' fit for non-full-warp execution, via 
'vote.all.pred'

For example, this allows for '-muniform-simt' code to be executed
single-threaded, which currently fails (device-side 'trap'): the 
'0x'
bitmask isn't correct if not all 32 threads of a warp are active.  The same
issue/fix, I suppose but have not verified, would apply if we were to allow 
for
OpenACC 'vector_length' smaller than 32, for example for OpenACC 'serial'.

We use 'nvptx_uniform_warp_check' only for PTX ISA version less than 6.0.
Otherwise we're using 'nvptx_warpsync', which emits 'bar.warp.sync 
0x',
which evidently appears to do the right thing.  (I've tested 
'-muniform-simt'
code executing single-threaded.)

The change that I proposed on 2022-12-15 was to emit PTX code to calculate
'(1 << %ntid.x) - 1' as the actual bitmask to use instead of '0x'.
This works, but the PTX JIT generates SASS code to do this computation.

In turn, this change now uses PTX 'vote.all.pred' -- which even simplifies 
upon
the original code a little bit, see the following examplary SASS 'diff' 
before
vs. after this change:

[...]
  /*[...]*/   SYNC  
  (*"BRANCH_TARGETS .L_x_332"*)}
  .L_x_332:
- /*[...]*/   VOTE.ANY R9, PT, PT ;
+ /*[...]*/   VOTE.ALL P1, PT ;
- /*[...]*/   ISETP.NE.U32.AND P1, PT, R9, 
-0x1, PT ;
- /*[...]*/  @!P1 BRA `(.L_x_333) ;
+ /*[...]*/   @P1 BRA `(.L_x_333) ;
  /*[...]*/   BPT.TRAP 0x1 ;
  .L_x_333:
- /*[...]*/   @P1 EXIT ;
+ /*[...]*/  @!P1 EXIT ;
[...]

gcc/
* config/nvptx/nvptx.md (nvptx_uniform_warp_check): Make fit for
non-full-warp execution, via 'vote.all.pred'.
gcc/testsuite/
* gcc.target/nvptx/nvptx.exp
(check_effective_target_default_ptx_isa_version_at_least_6_0):
New.
* gcc.target/nvptx/uniform-simt-2.c: Adjust.
* gcc.target/nvptx/uniform-simt-5.c: New.

Diff:
---
 gcc/config/nvptx/nvptx.md   | 13 +---
 gcc/testsuite/gcc.target/nvptx/nvptx.exp|  5 +
 gcc/testsuite/gcc.target/nvptx/uniform-simt-2.c |  2 +-
 gcc/testsuite/gcc.target/nvptx/uniform-simt-5.c | 28 +
 4 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md
index ef7e3fb00fa..7878a3b6f09 100644
--- a/gcc/config/nvptx/nvptx.md
+++ b/gcc/config/nvptx/nvptx.md
@@ -2316,14 +2316,11 @@
   {
 const char *insns[] = {
   "{",
-  "\\t"  ".reg.b32""\\t" "%%r_act;",
-  "%.\\t""vote.ballot.b32" "\\t" "%%r_act,1;",
-  "\\t"  ".reg.pred"   "\\t" "%%r_do_abort;",
-  "\\t"  "mov.pred""\\t" "%%r_do_abort,0;",
-  "%.\\t""setp.ne.b32" "\\t" "%%r_do_abort,%%r_act,"
- "0x;",
-  "@ %%r_do_abort\\t" "trap;",
-  "@ %%r_do_abort\\t" "exit;",
+  "\\t"".reg.pred" "\\t" "%%r_sync;",
+  "\\t""mov.pred"  "\\t" "%%r_sync, 1;",
+  "%.\\t"  "vote.all.pred" "\\t" "%%r_sync, 1;",
+  "@!%%r_sync\\t"  "trap;",
+  "@!%%r_sync\\t"  "exit;",
   "}",
   NULL
 };
diff --git a/gcc/testsuite/gcc.target/nvptx/nvptx.exp 
b/gcc/testsuite/gcc.target/nvptx/nvptx.exp
index 97aa7ae0852..3151381f51a 100644
--- a/gcc/testsuite/gcc.target/nvptx/nvptx.exp
+++ b/gcc/testsuite/gcc.target/nvptx/nvptx.exp
@@ -49,6 +49,11 @@ proc check_effective_target_default_ptx_isa_version_at_least 
{ major minor } {
 return $res
 }
 
+# Return 1 if code by default compiles for at least PTX ISA version 6.0.
+proc check_effective_target_default_ptx_isa_version_at_least_6_0 { } {
+return [check_effective_target_default_ptx_isa_version_at_least 6 0]
+}
+
 # Return 1 if code with PTX ISA version major.minor or higher can be run.
 proc check_effective_target_runtime_ptx_isa_version_at_least { major minor } {
 set name runtime_ptx_isa_version_${major}_${minor}
diff --git a/gcc/testsuite/gcc.target/nvptx/uniform-simt-2.c 
b/gcc/testsuite/gcc.target/nvptx/uniform-simt-2.c
index b1eee0d618f..1d83c49a44b 100644
--- a/gcc/testsuite/gcc.target/nvptx/uniform-simt-2.c
+++ b/gcc/testsuite/gcc.target/nvptx/uniform-simt-2.c
@@ -17,4 +17,4 @@ f (void)
 
 /* { dg-final { scan-assemble

[gcc r15-1065] Clean up after newlib "nvptx: In offloading execution, map '_exit' to 'abort' [GCC PR85463]"

2024-06-06 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:395ac0417a17ba6405873f891f895417d696b603

commit r15-1065-g395ac0417a17ba6405873f891f895417d696b603
Author: Thomas Schwinge 
Date:   Wed Jun 5 14:34:06 2024 +0200

Clean up after newlib "nvptx: In offloading execution, map '_exit' to 
'abort' [GCC PR85463]"

PR target/85463
libgfortran/
* runtime/minimal.c [__nvptx__] (exit): Don't override.
libgomp/
* config/nvptx/error.c (exit): Don't override.
* testsuite/libgomp.oacc-fortran/error_stop-1.f: Update.
* testsuite/libgomp.oacc-fortran/error_stop-2.f: Likewise.
* testsuite/libgomp.oacc-fortran/error_stop-3.f: Likewise.
* testsuite/libgomp.oacc-fortran/stop-1.f: Likewise.
* testsuite/libgomp.oacc-fortran/stop-2.f: Likewise.
* testsuite/libgomp.oacc-fortran/stop-3.f: Likewise.

Diff:
---
 libgfortran/runtime/minimal.c |  8 
 libgomp/config/nvptx/error.c  |  7 ---
 libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f |  8 +---
 libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f |  8 +---
 libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f |  8 +---
 libgomp/testsuite/libgomp.oacc-fortran/stop-1.f   | 13 +
 libgomp/testsuite/libgomp.oacc-fortran/stop-2.f   |  6 +-
 libgomp/testsuite/libgomp.oacc-fortran/stop-3.f   | 12 
 8 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/libgfortran/runtime/minimal.c b/libgfortran/runtime/minimal.c
index f13b3a4bf90..619f818c844 100644
--- a/libgfortran/runtime/minimal.c
+++ b/libgfortran/runtime/minimal.c
@@ -31,14 +31,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 #endif
 
 
-#if __nvptx__
-/* Map "exit" to "abort"; see PR85463 '[nvptx] "exit" in offloaded region
-   doesn't terminate process'.  */
-# undef exit
-# define exit(status) do { (void) (status); abort (); } while (0)
-#endif
-
-
 #if __nvptx__
 /* 'printf' is all we have.  */
 # undef estr_vprintf
diff --git a/libgomp/config/nvptx/error.c b/libgomp/config/nvptx/error.c
index 7e668276004..f7a2536c29b 100644
--- a/libgomp/config/nvptx/error.c
+++ b/libgomp/config/nvptx/error.c
@@ -58,11 +58,4 @@
 #endif
 
 
-/* The 'exit (EXIT_FAILURE);' of an Fortran (only, huh?) OpenMP 'error'
-   directive with 'severity (fatal)' causes a hang, so 'abort' instead of
-   'exit'.  */
-#undef exit
-#define exit(status) abort ()
-
-
 #include "../../error.c"
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f 
b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f
index de727749a53..3918d6853f6 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f
+++ b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f
@@ -16,14 +16,16 @@
   END PROGRAM MAIN
 
 ! { dg-output "CheCKpOInT(\n|\r\n|\r)+" }
+
 ! { dg-output "ERROR STOP (\n|\r\n|\r)+" }
 !
 ! In gfortran's main program, libfortran's set_options is called - which sets
 ! compiler_options.backtrace = 1 by default.  For an offload libgfortran, this
 ! is never called and, hence, "Error termination." is never printed.  Thus:
 ! { dg-output "Error termination.*" { target { ! { 
openacc_nvidia_accel_selected || openacc_radeon_accel_selected } } } }
-!
-! PR85463:
+
+! PR85463.  The 'exit' implementation used with nvptx
+! offloading is a little bit different.
 ! { dg-output "libgomp: cuStreamSynchronize error.*" { target 
openacc_nvidia_accel_selected } }
-!
+
 ! { dg-shouldfail "" }
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f 
b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f
index 475c9cb5850..5951e8cbe64 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f
+++ b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f
@@ -16,14 +16,16 @@
   END PROGRAM MAIN
 
 ! { dg-output "CheCKpOInT(\n|\r\n|\r)+" }
+
 ! { dg-output "ERROR STOP 35(\n|\r\n|\r)+" }
 !
 ! In gfortran's main program, libfortran's set_options is called - which sets
 ! compiler_options.backtrace = 1 by default.  For an offload libgfortran, this
 ! is never called and, hence, "Error termination." is never printed.  Thus:
 ! { dg-output "Error termination.*" { target { ! { 
openacc_nvidia_accel_selected || openacc_radeon_accel_selected } } } }
-!
-! PR85463:
+
+! PR85463.  The 'exit' implementation used with nvptx
+! offloading is a little bit different.
 ! { dg-output "libgomp: cuStreamSynchronize error.*" { target 
openacc_nvidia_accel_selected } }
-!
+
 ! { dg-shouldfail "" }
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f 
b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f
index ab63444ce34..15e02d8b744 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f
+++ b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f
@@ -16,14 +16,16 @@
   END PROGRAM MAIN
 
 ! { dg-output "CheCKpOInT(\n|\r\n|\r)+" }
+
 ! { dg-output "ERROR STOP SiGN(\n|\r\n|

[gcc r15-1027] Add 'c-c++-common/initpri1-split.c': 'c-c++-common/initpri1.c' split into separate translation units

2024-06-05 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:02e43e5596ee6a4d03eecaa48197280c4eb6a78f

commit r15-1027-g02e43e5596ee6a4d03eecaa48197280c4eb6a78f
Author: Thomas Schwinge 
Date:   Wed Apr 24 11:24:39 2024 +0200

Add 'c-c++-common/initpri1-split.c': 'c-c++-common/initpri1.c' split into 
separate translation units

gcc/testsuite/
* c-c++-common/initpri1.c: Split into...
* c-c++-common/initpri1_part_c1.c: ... this, and...
* c-c++-common/initpri1_part_c2.c: ... this, and...
* c-c++-common/initpri1_part_c3.c: ... this, and...
* c-c++-common/initpri1_part_cd4.c: ... this, and...
* c-c++-common/initpri1_part_d1.c: ... this, and...
* c-c++-common/initpri1_part_d2.c: ... this, and...
* c-c++-common/initpri1_part_d3.c: ... this, and...
* c-c++-common/initpri1_part_main.c: ... this part.
* c-c++-common/initpri1-split.c: New.

Diff:
---
 gcc/testsuite/c-c++-common/initpri1-split.c |  3 +
 gcc/testsuite/c-c++-common/initpri1.c   | 73 +
 gcc/testsuite/c-c++-common/initpri1_part_c1.c   | 11 
 gcc/testsuite/c-c++-common/initpri1_part_c2.c   | 11 
 gcc/testsuite/c-c++-common/initpri1_part_c3.c   | 11 
 gcc/testsuite/c-c++-common/initpri1_part_cd4.c  | 13 +
 gcc/testsuite/c-c++-common/initpri1_part_d1.c   | 11 
 gcc/testsuite/c-c++-common/initpri1_part_d2.c   | 11 
 gcc/testsuite/c-c++-common/initpri1_part_d3.c   | 14 +
 gcc/testsuite/c-c++-common/initpri1_part_main.c | 13 +
 10 files changed, 113 insertions(+), 58 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/initpri1-split.c 
b/gcc/testsuite/c-c++-common/initpri1-split.c
new file mode 100644
index 000..11755ee9f6a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/initpri1-split.c
@@ -0,0 +1,3 @@
+/* { dg-do run { target init_priority } } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-sources {initpri1_part_c1.c initpri1_part_c2.c 
initpri1_part_c3.c initpri1_part_d1.c initpri1_part_d2.c initpri1_part_d3.c 
initpri1_part_cd4.c initpri1_part_main.c} } */
diff --git a/gcc/testsuite/c-c++-common/initpri1.c 
b/gcc/testsuite/c-c++-common/initpri1.c
index 387f2a39658..f50137a489b 100644
--- a/gcc/testsuite/c-c++-common/initpri1.c
+++ b/gcc/testsuite/c-c++-common/initpri1.c
@@ -1,61 +1,18 @@
 /* { dg-do run { target init_priority } } */
 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
 
-int i;
-int j;
-
-void c1() __attribute__((constructor (500)));
-void c2() __attribute__((constructor (700)));
-void c3() __attribute__((constructor (600)));
-
-void c1() {
-  if (i++ != 0)
-__builtin_abort ();
-}
-
-void c2() {
-  if (i++ != 2)
-__builtin_abort ();
-}
-
-void c3() {
-  if (i++ != 1)
-__builtin_abort ();
-}
-
-void d1() __attribute__((destructor (500)));
-void d2() __attribute__((destructor (700)));
-void d3() __attribute__((destructor (600)));
-
-void d1() {
-  if (--i != 0)
-__builtin_abort ();
-}
-
-void d2() {
-  if (--i != 2)
-__builtin_abort ();
-}
-
-void d3() {
-  if (j != 2)
-__builtin_abort ();
-  if (--i != 1)
-__builtin_abort ();
-}
-
-void cd4() __attribute__((constructor (800), destructor (800)));
-
-void cd4() {
-  if (i != 3)
-__builtin_abort ();
-  ++j;
-}
-
-int main () {
-  if (i != 3)
-return 1;
-  if (j != 1)
-__builtin_abort ();
-  return 0;
-}
+#include "initpri1_part_c1.c"
+
+#include "initpri1_part_c2.c"
+
+#include "initpri1_part_c3.c"
+
+#include "initpri1_part_d1.c"
+
+#include "initpri1_part_d2.c"
+
+#include "initpri1_part_d3.c"
+
+#include "initpri1_part_cd4.c"
+
+#include "initpri1_part_main.c"
diff --git a/gcc/testsuite/c-c++-common/initpri1_part_c1.c 
b/gcc/testsuite/c-c++-common/initpri1_part_c1.c
new file mode 100644
index 000..0f85a2e6cb1
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/initpri1_part_c1.c
@@ -0,0 +1,11 @@
+/* { dg-skip-if part { *-*-* } } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+
+extern int i;
+
+void c1() __attribute__((constructor (500)));
+
+void c1() {
+  if (i++ != 0)
+__builtin_abort ();
+}
diff --git a/gcc/testsuite/c-c++-common/initpri1_part_c2.c 
b/gcc/testsuite/c-c++-common/initpri1_part_c2.c
new file mode 100644
index 000..e8c556aab17
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/initpri1_part_c2.c
@@ -0,0 +1,11 @@
+/* { dg-skip-if part { *-*-* } } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+
+extern int i;
+
+void c2() __attribute__((constructor (700)));
+
+void c2() {
+  if (i++ != 2)
+__builtin_abort ();
+}
diff --git a/gcc/testsuite/c-c++-common/initpri1_part_c3.c 
b/gcc/testsuite/c-c++-common/initpri1_part_c3.c
new file mode 100644
index 000..70880882ce3
--- /dev/null

[gcc r15-1028] Add 'c-c++-common/initpri1{, -lto, -split}-static.c' as internal linkage variants

2024-06-05 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:d5ccc21f17b5c7ff20cca81c96a11a68f61f287b

commit r15-1028-gd5ccc21f17b5c7ff20cca81c96a11a68f61f287b
Author: Thomas Schwinge 
Date:   Wed Apr 24 11:51:54 2024 +0200

Add 'c-c++-common/initpri1{,-lto,-split}-static.c' as internal linkage 
variants

gcc/testsuite/
* c-c++-common/initpri1_part_c1.c: Consider 'CDTOR_LINKAGE'.
* c-c++-common/initpri1_part_c2.c: Likewise.
* c-c++-common/initpri1_part_c3.c: Likewise.
* c-c++-common/initpri1_part_cd4.c: Likewise.
* c-c++-common/initpri1_part_d1.c: Likewise.
* c-c++-common/initpri1_part_d2.c: Likewise.
* c-c++-common/initpri1_part_d3.c: Likewise.
* c-c++-common/initpri1.c: Specify it.
* c-c++-common/initpri1-lto.c: Likewise.
* c-c++-common/initpri1-split.c: Likewise.
* c-c++-common/initpri1-static.c: New.
* c-c++-common/initpri1-lto-static.c: Likewise.
* c-c++-common/initpri1-split-static.c: Likewise.

Diff:
---
 gcc/testsuite/c-c++-common/initpri1-lto-static.c   | 7 +++
 gcc/testsuite/c-c++-common/initpri1-lto.c  | 1 +
 gcc/testsuite/c-c++-common/initpri1-split-static.c | 4 
 gcc/testsuite/c-c++-common/initpri1-split.c| 1 +
 gcc/testsuite/c-c++-common/initpri1-static.c   | 5 +
 gcc/testsuite/c-c++-common/initpri1.c  | 1 +
 gcc/testsuite/c-c++-common/initpri1_part_c1.c  | 2 ++
 gcc/testsuite/c-c++-common/initpri1_part_c2.c  | 2 ++
 gcc/testsuite/c-c++-common/initpri1_part_c3.c  | 2 ++
 gcc/testsuite/c-c++-common/initpri1_part_cd4.c | 2 ++
 gcc/testsuite/c-c++-common/initpri1_part_d1.c  | 2 ++
 gcc/testsuite/c-c++-common/initpri1_part_d2.c  | 2 ++
 gcc/testsuite/c-c++-common/initpri1_part_d3.c  | 2 ++
 13 files changed, 33 insertions(+)

diff --git a/gcc/testsuite/c-c++-common/initpri1-lto-static.c 
b/gcc/testsuite/c-c++-common/initpri1-lto-static.c
new file mode 100644
index 000..6393f7ec99b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/initpri1-lto-static.c
@@ -0,0 +1,7 @@
+/* { dg-do run { target init_priority } } */
+/* { dg-require-effective-target lto } */
+/* { dg-options "-flto -O3" } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -DCDTOR_LINKAGE=static } */
+
+#include "initpri1.c"
diff --git a/gcc/testsuite/c-c++-common/initpri1-lto.c 
b/gcc/testsuite/c-c++-common/initpri1-lto.c
index 433ef356c7e..7fb4bf1aa82 100644
--- a/gcc/testsuite/c-c++-common/initpri1-lto.c
+++ b/gcc/testsuite/c-c++-common/initpri1-lto.c
@@ -2,5 +2,6 @@
 /* { dg-require-effective-target lto } */
 /* { dg-options "-flto -O3" } */
 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -DCDTOR_LINKAGE= } */
 
 #include "initpri1.c"
diff --git a/gcc/testsuite/c-c++-common/initpri1-split-static.c 
b/gcc/testsuite/c-c++-common/initpri1-split-static.c
new file mode 100644
index 000..02d8b162e19
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/initpri1-split-static.c
@@ -0,0 +1,4 @@
+/* { dg-do run { target init_priority } } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-sources {initpri1_part_c1.c initpri1_part_c2.c 
initpri1_part_c3.c initpri1_part_d1.c initpri1_part_d2.c initpri1_part_d3.c 
initpri1_part_cd4.c initpri1_part_main.c} } */
+/* { dg-additional-options -DCDTOR_LINKAGE=static } */
diff --git a/gcc/testsuite/c-c++-common/initpri1-split.c 
b/gcc/testsuite/c-c++-common/initpri1-split.c
index 11755ee9f6a..f1482c7e0c1 100644
--- a/gcc/testsuite/c-c++-common/initpri1-split.c
+++ b/gcc/testsuite/c-c++-common/initpri1-split.c
@@ -1,3 +1,4 @@
 /* { dg-do run { target init_priority } } */
 /* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
 /* { dg-additional-sources {initpri1_part_c1.c initpri1_part_c2.c 
initpri1_part_c3.c initpri1_part_d1.c initpri1_part_d2.c initpri1_part_d3.c 
initpri1_part_cd4.c initpri1_part_main.c} } */
+/* { dg-additional-options -DCDTOR_LINKAGE= } */
diff --git a/gcc/testsuite/c-c++-common/initpri1-static.c 
b/gcc/testsuite/c-c++-common/initpri1-static.c
new file mode 100644
index 000..ac101ff63cb
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/initpri1-static.c
@@ -0,0 +1,5 @@
+/* { dg-do run { target init_priority } } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -DCDTOR_LINKAGE=static } */
+
+#include "initpri1.c"
diff --git a/gcc/testsuite/c-c++-common/initpri1.c 
b/gcc/testsuite/c-c++-common/initpri1.c
index f50137a489b..73579cdd06b 100644
--- a/gcc/testsuite/c-c++-common/initpri1.c
+++ b/gcc/testsuite/c-c++-common/initpri1.c
@@ -1,5 +1,6 @@
 /* { dg-do run { target i

[gcc r15-1026] Add C++ testing for 'gcc.dg/initpri1-lto.c': 'c-c++-common/initpri1-lto.c'

2024-06-05 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:08c7e87f0da24b701042110c3927ecdb3367c0b4

commit r15-1026-g08c7e87f0da24b701042110c3927ecdb3367c0b4
Author: Thomas Schwinge 
Date:   Wed Apr 24 09:26:39 2024 +0200

Add C++ testing for 'gcc.dg/initpri1-lto.c': 'c-c++-common/initpri1-lto.c'

Similar to commit a7d75773adadfcd536a5ded48ba215f18e8c5b3d
"Consolidate similar C/C++ test cases for 'constructor', 'destructor' 
function attributes with priority".

gcc/testsuite/
* gcc.dg/initpri1-lto.c: Integrate this...
* c-c++-common/initpri1-lto.c: ... here.

Diff:
---
 gcc/testsuite/c-c++-common/initpri1-lto.c | 6 ++
 gcc/testsuite/gcc.dg/initpri1-lto.c   | 5 -
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/initpri1-lto.c 
b/gcc/testsuite/c-c++-common/initpri1-lto.c
new file mode 100644
index 000..433ef356c7e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/initpri1-lto.c
@@ -0,0 +1,6 @@
+/* { dg-do run { target init_priority } } */
+/* { dg-require-effective-target lto } */
+/* { dg-options "-flto -O3" } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+
+#include "initpri1.c"
diff --git a/gcc/testsuite/gcc.dg/initpri1-lto.c 
b/gcc/testsuite/gcc.dg/initpri1-lto.c
deleted file mode 100644
index 0c97cf4b1c9..000
--- a/gcc/testsuite/gcc.dg/initpri1-lto.c
+++ /dev/null
@@ -1,5 +0,0 @@
-/* { dg-do run { target init_priority } } */
-/* { dg-require-effective-target lto } */
-/* { dg-options "-flto -O3" } */
-
-#include "../c-c++-common/initpri1.c"


[gcc r15-1025] Consolidate similar C/C++ test cases for 'constructor', 'destructor' function attributes with priori

2024-06-05 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:a7d75773adadfcd536a5ded48ba215f18e8c5b3d

commit r15-1025-ga7d75773adadfcd536a5ded48ba215f18e8c5b3d
Author: Thomas Schwinge 
Date:   Wed Apr 24 09:26:39 2024 +0200

Consolidate similar C/C++ test cases for 'constructor', 'destructor' 
function attributes with priority

gcc/testsuite/
* gcc.dg/initpri1.c: Integrate this...
* g++.dg/special/initpri1.C: ..., and this...
* c-c++-common/initpri1.c: ... here.
* gcc.dg/initpri1-lto.c: Adjust.
* gcc.dg/initpri2.c: Integrate this...
* g++.dg/special/initpri2.C: ..., and this...
* c-c++-common/initpri2.c: ... here.

Diff:
---
 gcc/testsuite/{gcc.dg => c-c++-common}/initpri1.c | 21 
 gcc/testsuite/{gcc.dg => c-c++-common}/initpri2.c |  1 +
 gcc/testsuite/g++.dg/special/initpri1.C   | 62 ---
 gcc/testsuite/g++.dg/special/initpri2.C   | 39 --
 gcc/testsuite/gcc.dg/initpri1-lto.c   |  2 +-
 5 files changed, 12 insertions(+), 113 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/initpri1.c 
b/gcc/testsuite/c-c++-common/initpri1.c
similarity index 68%
rename from gcc/testsuite/gcc.dg/initpri1.c
rename to gcc/testsuite/c-c++-common/initpri1.c
index b6afd7690de..387f2a39658 100644
--- a/gcc/testsuite/gcc.dg/initpri1.c
+++ b/gcc/testsuite/c-c++-common/initpri1.c
@@ -1,6 +1,5 @@
 /* { dg-do run { target init_priority } } */
-
-extern void abort (void);
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
 
 int i;
 int j;
@@ -11,17 +10,17 @@ void c3() __attribute__((constructor (600)));
 
 void c1() {
   if (i++ != 0)
-abort ();
+__builtin_abort ();
 }
 
 void c2() {
   if (i++ != 2)
-abort ();
+__builtin_abort ();
 }
 
 void c3() {
   if (i++ != 1)
-abort ();
+__builtin_abort ();
 }
 
 void d1() __attribute__((destructor (500)));
@@ -30,26 +29,26 @@ void d3() __attribute__((destructor (600)));
 
 void d1() {
   if (--i != 0)
-abort ();
+__builtin_abort ();
 }
 
 void d2() {
   if (--i != 2)
-abort ();
+__builtin_abort ();
 }
 
 void d3() {
   if (j != 2)
-abort ();
+__builtin_abort ();
   if (--i != 1)
-abort ();
+__builtin_abort ();
 }
 
 void cd4() __attribute__((constructor (800), destructor (800)));
 
 void cd4() {
   if (i != 3)
-abort ();
+__builtin_abort ();
   ++j;
 }
 
@@ -57,6 +56,6 @@ int main () {
   if (i != 3)
 return 1;
   if (j != 1)
-abort ();
+__builtin_abort ();
   return 0;
 }
diff --git a/gcc/testsuite/gcc.dg/initpri2.c 
b/gcc/testsuite/c-c++-common/initpri2.c
similarity index 92%
rename from gcc/testsuite/gcc.dg/initpri2.c
rename to gcc/testsuite/c-c++-common/initpri2.c
index fa9fda0d7f3..bda2a626c64 100644
--- a/gcc/testsuite/gcc.dg/initpri2.c
+++ b/gcc/testsuite/c-c++-common/initpri2.c
@@ -1,4 +1,5 @@
 /* { dg-do compile { target init_priority } } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
 
 /* Priorities must be in the range [0, 65535].  */
 void c1()
diff --git a/gcc/testsuite/g++.dg/special/initpri1.C 
b/gcc/testsuite/g++.dg/special/initpri1.C
deleted file mode 100644
index bd24961e46b..000
--- a/gcc/testsuite/g++.dg/special/initpri1.C
+++ /dev/null
@@ -1,62 +0,0 @@
-/* { dg-do run { target init_priority } } */
-
-extern "C" void abort ();
-
-int i;
-int j;
-
-void c1() __attribute__((constructor (500)));
-void c2() __attribute__((constructor (700)));
-void c3() __attribute__((constructor (600)));
-
-void c1() {
-  if (i++ != 0)
-abort ();
-}
-
-void c2() {
-  if (i++ != 2)
-abort ();
-}
-
-void c3() {
-  if (i++ != 1)
-abort ();
-}
-
-void d1() __attribute__((destructor (500)));
-void d2() __attribute__((destructor (700)));
-void d3() __attribute__((destructor (600)));
-
-void d1() {
-  if (--i != 0)
-abort ();
-}
-
-void d2() {
-  if (--i != 2)
-abort ();
-}
-
-void d3() {
-  if (j != 2)
-abort ();
-  if (--i != 1)
-abort ();
-}
-
-void cd4() __attribute__((constructor (800), destructor (800)));
-
-void cd4() {
-  if (i != 3)
-abort ();
-  ++j;
-}
-
-int main () {
-  if (i != 3)
-return 1;
-  if (j != 1)
-abort ();
-  return 0;
-}
diff --git a/gcc/testsuite/g++.dg/special/initpri2.C 
b/gcc/testsuite/g++.dg/special/initpri2.C
deleted file mode 100644
index fa9fda0d7f3..000
--- a/gcc/testsuite/g++.dg/special/initpri2.C
+++ /dev/null
@@ -1,39 +0,0 @@
-/* { dg-do compile { target init_priority } } */
-
-/* Priorities must be in the range [0, 65535].  */
-void c1()
- __attribute__((constructor (-1))); /* { dg-error "priorities" } */
-void c2() 
- __attribute__((constructor (65536))); /* { dg-error "priorities" } */
-void d1() 
- __attribute__((destructor (-1))); /* { dg-error "priorities" } */
-void d2() 
- __attribute__((destructor (65536))); /* { dg-error "priorities" } */
-
-/* Priorities 0-

[gcc r15-1024] Clarify that 'gcc.dg/initpri3.c' is a LTO variant of 'gcc.dg/initpri1.c': 'gcc.dg/initpri1-lto.c' [P

2024-06-05 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:38dd7419324490b386bbac06ddc5fafbfe8629d3

commit r15-1024-g38dd7419324490b386bbac06ddc5fafbfe8629d3
Author: Thomas Schwinge 
Date:   Wed Apr 24 10:11:02 2024 +0200

Clarify that 'gcc.dg/initpri3.c' is a LTO variant of 'gcc.dg/initpri1.c': 
'gcc.dg/initpri1-lto.c' [PR46083]

Added in commit 06c9eb5136fe0e778cc3a643131eba2a3dfb77a8 (Subversion 
r168642)
"re PR lto/46083 (gcc.dg/initpri1.c FAILs with -flto/-fwhopr (attribute 
constructor/destructor doesn't work))".

PR lto/46083
gcc/testsuite/
* gcc.dg/initpri3.c: Remove.
* gcc.dg/initpri1-lto.c: New.

Diff:
---
 gcc/testsuite/gcc.dg/initpri1-lto.c |  5 +++
 gcc/testsuite/gcc.dg/initpri3.c | 64 -
 2 files changed, 5 insertions(+), 64 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/initpri1-lto.c 
b/gcc/testsuite/gcc.dg/initpri1-lto.c
new file mode 100644
index 000..98a43c3ff0d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/initpri1-lto.c
@@ -0,0 +1,5 @@
+/* { dg-do run { target init_priority } } */
+/* { dg-require-effective-target lto } */
+/* { dg-options "-flto -O3" } */
+
+#include "initpri1.c"
diff --git a/gcc/testsuite/gcc.dg/initpri3.c b/gcc/testsuite/gcc.dg/initpri3.c
deleted file mode 100644
index 1633da0141f..000
--- a/gcc/testsuite/gcc.dg/initpri3.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* { dg-do run { target init_priority } } */
-/* { dg-require-effective-target lto } */
-/* { dg-options "-flto -O3" } */
-
-extern void abort ();
-
-int i;
-int j;
-
-void c1() __attribute__((constructor (500)));
-void c2() __attribute__((constructor (700)));
-void c3() __attribute__((constructor (600)));
-
-void c1() {
-  if (i++ != 0)
-abort ();
-}
-
-void c2() {
-  if (i++ != 2)
-abort ();
-}
-
-void c3() {
-  if (i++ != 1)
-abort ();
-}
-
-void d1() __attribute__((destructor (500)));
-void d2() __attribute__((destructor (700)));
-void d3() __attribute__((destructor (600)));
-
-void d1() {
-  if (--i != 0)
-abort ();
-}
-
-void d2() {
-  if (--i != 2)
-abort ();
-}
-
-void d3() {
-  if (j != 2)
-abort ();
-  if (--i != 1)
-abort ();
-}
-
-void cd4() __attribute__((constructor (800), destructor (800)));
-
-void cd4() {
-  if (i != 3)
-abort ();
-  ++j;
-}
-
-int main () {
-  if (i != 3)
-return 1;
-  if (j != 1)
-abort ();
-  return 0;
-}


[gcc r15-942] nvptx target: Global constructor, destructor support, via nvptx-tools 'ld'

2024-05-31 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:d9c90c82d900fdae95df4499bf5f0a4ecb903b53

commit r15-942-gd9c90c82d900fdae95df4499bf5f0a4ecb903b53
Author: Thomas Schwinge 
Date:   Tue May 28 23:20:29 2024 +0200

nvptx target: Global constructor, destructor support, via nvptx-tools 'ld'

The function attributes 'constructor', 'destructor', and 'init_priority' now
work, as do the C++ features making use of this.  Test cases with effective
target 'global_constructor' and 'init_priority' now generally work, and
'check-gcc-c++' test results greatly improve; no more
"sorry, unimplemented: global constructors not supported on this target".

For proper execution test results, this depends on


"ld: Global constructor/destructor support".

gcc/
* config/nvptx/nvptx.h: Configure global constructor, destructor
support.
gcc/testsuite/
* gcc.dg/no_profile_instrument_function-attr-1.c: GCC/nvptx is
'NO_DOT_IN_LABEL' but not 'NO_DOLLAR_IN_LABEL', so '$' may apper
in identifiers.
* lib/target-supports.exp
(check_effective_target_global_constructor): Enable for nvptx.
libgcc/
* config/nvptx/crt0.c (__gbl_ctors): New weak function.
(__main): Invoke it.
* config/nvptx/gbl-ctors.c: New.
* config/nvptx/t-nvptx: Configure global constructor, destructor
support.

Diff:
---
 gcc/config/nvptx/nvptx.h   | 14 +++-
 .../gcc.dg/no_profile_instrument_function-attr-1.c |  2 +-
 gcc/testsuite/lib/target-supports.exp  |  3 +-
 libgcc/config/nvptx/crt0.c | 12 
 libgcc/config/nvptx/gbl-ctors.c| 74 ++
 libgcc/config/nvptx/t-nvptx|  9 ++-
 6 files changed, 109 insertions(+), 5 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
index e282aad1b73..74f4a68924c 100644
--- a/gcc/config/nvptx/nvptx.h
+++ b/gcc/config/nvptx/nvptx.h
@@ -356,7 +356,19 @@ struct GTY(()) machine_function
 #define MOVE_MAX 8
 #define MOVE_RATIO(SPEED) 4
 #define FUNCTION_MODE QImode
-#define HAS_INIT_SECTION 1
+
+/* Implement global constructor, destructor support in a conceptually simpler
+   way than using 'collect2' (the program): implement the respective
+   functionality in the nvptx-tools 'ld'.  This however still requires the
+   compiler-side effects corresponding to 'USE_COLLECT2': the global
+   constructor, destructor support functions need to have external linkage, and
+   therefore names that are "unique across the whole link".  Use
+   '!targetm.have_ctors_dtors' to achieve this (..., and thus don't need to
+   provide 'targetm.asm_out.constructor', 'targetm.asm_out.destructor').  */
+#define TARGET_HAVE_CTORS_DTORS false
+
+/* See 'libgcc/config/nvptx/crt0.c' for wrapping of 'main'.  */
+#define HAS_INIT_SECTION
 
 /* The C++ front end insists to link against libstdc++ -- which we don't build.
Tell it to instead link against the innocuous libgcc.  */
diff --git a/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c 
b/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c
index 909f8a68479..5b4101cf596 100644
--- a/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c
+++ b/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c
@@ -18,7 +18,7 @@ int main ()
   return foo ();
 }
 
-/* { dg-final { scan-tree-dump-times "__gcov0\[._\]main.* = PROF_edge_counter" 
1 "optimized"} } */
+/* { dg-final { scan-tree-dump-times "__gcov0\[$._\]main.* = 
PROF_edge_counter" 1 "optimized"} } */
 /* { dg-final { scan-tree-dump-times "__gcov_indirect_call_profiler_v" 1 
"optimized" } } */
 /* { dg-final { scan-tree-dump-times "__gcov_time_profiler_counter = " 1 
"optimized" } } */
 /* { dg-final { scan-tree-dump-times "__gcov_init" 1 "optimized" } } */
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index f0f6da52275..a3992faab5e 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -942,8 +942,7 @@ proc check_effective_target_nonlocal_goto {} {
 # Return 1 if global constructors are supported, 0 otherwise.
 
 proc check_effective_target_global_constructor {} {
-if { [istarget nvptx-*-*]
-|| [istarget bpf-*-*] } {
+if { [istarget bpf-*-*] } {
return 0
 }
 return 1
diff --git a/libgcc/config/nvptx/crt0.c b/libgcc/config/nvptx/crt0.c
index e37a6fb40d3..47e8ec44c19 100644
--- a/libgcc/config/nvptx/crt0.c
+++ b/libgcc/config/nvptx/crt0.c
@@ -32,6 +32,16 @@ void *__nvptx_stacks[32] __attribute__((shared,nocommon));
 /* Likewise for -muniform-simt.  */
 unsigned __nvptx_uni[32] __attribute__((shared,nocommon));
 
+/* Global constructor/destructor support.  Dummy; if necessary, overridden 

[gcc/devel/rust/master] borrowck: Build Polonius automatically

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:ab8b4cc38806e1a7190a7426ce073951752d1a60

commit ab8b4cc38806e1a7190a7426ce073951752d1a60
Author: Jakub Dupak 
Date:   Wed Feb 28 00:08:01 2024 +0100

borrowck: Build Polonius automatically

This is minimalistic version to build Polonius with Cargo.

gcc/rust/ChangeLog:

* Make-lang.in: Build Polonius.

Signed-off-by: Jakub Dupak 

Diff:
---
 gcc/rust/Make-lang.in | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index 74663379487d..3275015b0466 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -266,6 +266,7 @@ rust.srcman:
 # Clean hooks.
 
 rust.mostlyclean:
+   rm -rf rust/ffi-polonius/release libffi_polonius.a
 #  cd $(srcdir)/rust; rm -f *.o y.tab.h y.tab.c lex.yy.c
 
 rust.clean: rust.mostlyclean
@@ -487,3 +488,9 @@ rust/%.o: rust/checks/errors/borrowck/%.cc
 rust/%.o: rust/metadata/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
+
+rust/libffi_polonius.a: \
+   rust/checks/errors/borrowck/ffi-polonius/Cargo.toml \
+   $(wildcard $(srcdir)/rust/checks/errors/borrowck/ffi-polonius/src/*)
+   cargo build --manifest-path 
$(srcdir)/rust/checks/errors/borrowck/ffi-polonius/Cargo.toml --release 
--target-dir rust/ffi-polonius
+   cp rust/ffi-polonius/release/libffi_polonius.a rust/libffi_polonius.a
\ No newline at end of file


[gcc/devel/rust/master] Pin macos CI to version 13

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:ba8ce7e66ca145004810f50246872902baf95ba0

commit ba8ce7e66ca145004810f50246872902baf95ba0
Author: Pierre-Emmanuel Patry 
Date:   Tue Apr 30 13:16:36 2024 +0200

Pin macos CI to version 13

Latest macos environment runs on arm and is thus
incompatible with gcc.

ChangeLog:

* .github/workflows/ccpp.yml: Pin macos runner
version.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 .github/workflows/ccpp.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml
index 1955a03ab094..3381ec80d689 100644
--- a/.github/workflows/ccpp.yml
+++ b/.github/workflows/ccpp.yml
@@ -253,7 +253,7 @@ jobs:
   CC: clang
   CXX: clang++
 
-runs-on: macos-latest
+runs-on: macos-13
 
 steps:
 - uses: actions/checkout@v3


[gcc/devel/rust/master] borrowck: Polonius error reporting

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:a926ad27cda683dd32fb3a6d2c809af13d418cce

commit a926ad27cda683dd32fb3a6d2c809af13d418cce
Author: Jakub Dupak 
Date:   Wed Feb 28 00:01:28 2024 +0100

borrowck: Polonius error reporting

gcc/rust/ChangeLog:

* checks/errors/borrowck/ffi-polonius/src/gccrs_ffi_generated.rs: 
Error reporting.
* checks/errors/borrowck/ffi-polonius/src/lib.rs: Error reporting.
* checks/errors/borrowck/polonius/rust-polonius-ffi.h (struct 
FactsView):
Error reporting.
(struct Output): Error reporting.
* checks/errors/borrowck/polonius/rust-polonius.h (struct Facts): 
Error reporting.
* checks/errors/borrowck/rust-borrow-checker.cc: Error reporting.

Signed-off-by: Jakub Dupak 

Diff:
---
 .../ffi-polonius/src/gccrs_ffi_generated.rs|   8 ++
 .../checks/errors/borrowck/ffi-polonius/src/lib.rs | 115 +++--
 .../errors/borrowck/polonius/rust-polonius-ffi.h   |   7 ++
 .../errors/borrowck/polonius/rust-polonius.h   |   3 +-
 .../checks/errors/borrowck/rust-borrow-checker.cc  |  21 +++-
 5 files changed, 117 insertions(+), 37 deletions(-)

diff --git 
a/gcc/rust/checks/errors/borrowck/ffi-polonius/src/gccrs_ffi_generated.rs 
b/gcc/rust/checks/errors/borrowck/ffi-polonius/src/gccrs_ffi_generated.rs
index 209081795289..db75a1d1509d 100644
--- a/gcc/rust/checks/errors/borrowck/ffi-polonius/src/gccrs_ffi_generated.rs
+++ b/gcc/rust/checks/errors/borrowck/ffi-polonius/src/gccrs_ffi_generated.rs
@@ -48,3 +48,11 @@ pub struct FactsView {
 pub known_placeholder_subset: Slice>,
 pub placeholder: Slice>,
 }
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct Output {
+pub loan_errors: bool,
+pub subset_errors: bool,
+pub move_errors: bool,
+}
diff --git a/gcc/rust/checks/errors/borrowck/ffi-polonius/src/lib.rs 
b/gcc/rust/checks/errors/borrowck/ffi-polonius/src/lib.rs
index 819c34a93749..085b6a0b5188 100644
--- a/gcc/rust/checks/errors/borrowck/ffi-polonius/src/lib.rs
+++ b/gcc/rust/checks/errors/borrowck/ffi-polonius/src/lib.rs
@@ -86,48 +86,95 @@ fn print_point(point: GccrsAtom) {
 let val: usize = point.into();
 let mid = val % 2 == 1;
 let bb = val >> 16;
-let stmt = (val >> 1) & 0x;
-print!("{}(bb{}[{}])", if mid { "Mid" } else { "Start" }, bb, stmt);
+let stmt = (val >> 1) & ((1 << 15) - 1);
+eprint!("{}(bb{}[{}])", if mid { "Mid" } else { "Start" }, bb, stmt);
 }
 
 /// Run the polonius analysis on the given facts (for a single function).
 /// Right now, results are only printed and not propagated back to the gccrs.
 #[no_mangle]
-pub unsafe extern "C" fn polonius_run(input: gccrs_ffi::FactsView, 
dump_enabled: bool) {
+pub unsafe extern "C" fn polonius_run(
+input: gccrs_ffi::FactsView,
+dump_enabled: bool,
+) -> gccrs_ffi::Output {
 let facts = AllFactsfrom(input);
-let output = Output::compute(&facts, polonius_engine::Algorithm::Naive, 
dump_enabled);
-
-// FIXME: Temporary output
-println!("Polonius analysis completed. Results:");
-println!("Errors: {:#?}", output.errors);
-println!("Subset error: {:#?}", output.subset_errors);
-println!("Move error: {:#?}", output.move_errors);
-
-println!("Subsets:");
-let mut subset_vec: Vec<_> = output.subset.iter().collect();
-subset_vec.sort_by_key(|&(point, _)| point);
-for (point, subsets) in subset_vec {
-print_point(*point);
-println!(": {{");
-for (&lhs, rhss) in subsets {
-for &rhs in rhss {
-println!("{} <= {}", usize::from(lhs), usize::from(rhs));
+let output = Output::compute(
+&facts,
+polonius_engine::Algorithm::DatafrogOpt,
+dump_enabled,
+);
+
+if dump_enabled {
+eprintln!("Subsets:");
+let mut subset_vec: Vec<_> = output.subset.iter().collect();
+subset_vec.sort_by_key(|&(point, _)| point);
+for (point, subsets) in subset_vec {
+print_point(*point);
+eprintln!(": {{");
+for (&lhs, rhss) in subsets {
+for &rhs in rhss {
+eprintln!("{} <= {}", usize::from(lhs), 
usize::from(rhs));
+}
 }
+eprintln!("}}");
 }
-println!("}}");
-}
-println!("Subset anywhere: {:#?}", output.subset_anywhere);
-
-// Print origin live on entry
-println!("Origin live on entry:");
-let mut origin_vec: Vec<_> = output.origin_live_on_entry.iter().collect();
-origin_vec.sort_by_key(|&(point, _)| point);
-for (point, origins) in origin_vec {
-print_point(*point);
-println!(": {{");
-for &origin in origins {
-println!("{}", usize::from(origin));
+
+// Print origin live on entry
+eprintln!("Origin live on entry:");
+let mut origin_vec: Vec<_> = 
output.origin_live_on_entry.iter().collect();
+origin_v

[gcc/devel/rust/master] Remove redundant macro definition

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:fa86c37a57696b9dba2d1553dbe9e913865f4209

commit fa86c37a57696b9dba2d1553dbe9e913865f4209
Author: zhanghe9702 
Date:   Sun Mar 24 16:48:56 2024 +0800

Remove redundant macro definition

gcc/rust/ChangeLog:
* backend/rust-tree.h: removing the CLASSTYPE_VBASECLASSES macro
which is duplicated three times.

Signed-off-by: Zhang He 

Diff:
---
 gcc/rust/backend/rust-tree.h | 12 
 1 file changed, 12 deletions(-)

diff --git a/gcc/rust/backend/rust-tree.h b/gcc/rust/backend/rust-tree.h
index 26c8b653ac64..2e231cad5e14 100644
--- a/gcc/rust/backend/rust-tree.h
+++ b/gcc/rust/backend/rust-tree.h
@@ -139,12 +139,6 @@
should be initialized.)  */
 #define CLASSTYPE_VBASECLASSES(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->vbases)
 
-/* A vector of BINFOs for the direct and indirect virtual base classes
-   that this type uses in a post-order depth-first left-to-right
-   order.  (In other words, these bases appear in the order that they
-   should be initialized.)  */
-#define CLASSTYPE_VBASECLASSES(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->vbases)
-
 /* We used to have a variant type for lang_type.  Keep the name of the
checking accessor for the sole survivor.  */
 #define LANG_TYPE_CLASS_CHECK(NODE) (TYPE_LANG_SPECIFIC (NODE))
@@ -783,12 +777,6 @@ extern GTY (()) tree cp_global_trees[CPTI_MAX];
 #define CLASSTYPE_PRIMARY_BINFO(NODE)  
\
   (LANG_TYPE_CLASS_CHECK (NODE)->primary_base)
 
-/* A vector of BINFOs for the direct and indirect virtual base classes
-   that this type uses in a post-order depth-first left-to-right
-   order.  (In other words, these bases appear in the order that they
-   should be initialized.)  */
-#define CLASSTYPE_VBASECLASSES(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->vbases)
-
 /* The type corresponding to NODE when NODE is used as a base class,
i.e., NODE without virtual base classes or tail padding.  */
 #define CLASSTYPE_AS_BASE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->as_base)


[gcc/devel/rust/master] chore: Fix Remark CI

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:a24871e1bdea1b1f9fff2a737820214db6528a14

commit a24871e1bdea1b1f9fff2a737820214db6528a14
Author: Arthur Cohen 
Date:   Fri Apr 12 17:10:40 2024 +0200

chore: Fix Remark CI

ChangeLog:

* CONTRIBUTING.md: Fix invalid line length.
* README.md: Likewise.

Diff:
---
 CONTRIBUTING.md | 6 --
 README.md   | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 75812a657a30..98cd8894ad68 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -4,7 +4,8 @@
 
 * **Ensure the bug was not already reported** by searching on GitHub under 
[Issues](https://github.com/Rust-GCC/gccrs/issues).
 
-* If you're unable to find an open issue addressing the problem, [open a new 
one](https://github.com/Rust-GCC/gccrs/issues/new).
+* If you're unable to find an open issue addressing the problem,
+  [open a new one](https://github.com/Rust-GCC/gccrs/issues/new).
   Be sure to include a **title and clear description**, as much relevant 
information as possible, and a **code sample**
   or an **executable test case** demonstrating the expected behavior that is 
not occurring.
 
@@ -15,7 +16,8 @@
 * Ensure the PR description clearly describes the problem and solution. 
Include the relevant issue number if applicable.
 
 * Before submitting, GCC development requires copyright assignment or the 
Developer's Certificate of Origin sign-off.
-   Please see the [Contributing to GCC](https://gcc.gnu.org/contribute.html) 
guide or [Developer's Certificate of Origin (DCO) 
Sign-off](https://gcc.gnu.org/dco.html) guide.
+   Please see the [Contributing to GCC](https://gcc.gnu.org/contribute.html) 
guide or
+  [Developer's Certificate of Origin (DCO) 
Sign-off](https://gcc.gnu.org/dco.html) guide.
 
 * Patches sent to the [`gcc-rust` mailing 
list](https://gcc.gnu.org/mailman/listinfo/gcc-rust) are likewise welcome.
 These will be imported into a GitHub PR to follow the normal review process,
diff --git a/README.md b/README.md
index 2ba59d3a6b24..bd79c4a713c1 100644
--- a/README.md
+++ b/README.md
@@ -217,7 +217,8 @@ If you want to contribute to GCC Rust, you can find more 
information in [CONTRIB
 
 Please be aware this project is designed to be pushed upstream to GCC when we 
reach some milestones,
 and this means we require copyright assignment or the Developer's Certificate 
of Origin sign-off.
-Please see the [Contributing to GCC](https://gcc.gnu.org/contribute.html) 
guide or [Developer's Certificate of Origin (DCO) 
Sign-off](https://gcc.gnu.org/dco.html) guide.
+Please see the [Contributing to GCC](https://gcc.gnu.org/contribute.html) 
guide or
+[Developer's Certificate of Origin (DCO) 
Sign-off](https://gcc.gnu.org/dco.html) guide.
 
 Not all contributions must be code; we would love to see new test cases or 
bugs and issues to be reported.
 Feel free to add any comments on open PRs


[gcc/devel/rust/master] borrowck: Use std::ignore

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:45d5c01fdba6e4c09a3ec4497b9be355bb2db106

commit 45d5c01fdba6e4c09a3ec4497b9be355bb2db106
Author: Jakub Dupak 
Date:   Wed Apr 24 14:32:48 2024 +0200

borrowck: Use std::ignore

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
(ExprStmtBuilder::visit): Use std::ignore.

Diff:
---
 .../checks/errors/borrowck/rust-bir-builder-expr-stmt.cc   | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc 
b/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
index d64641177d0e..81fa2ea7b043 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
@@ -237,7 +237,7 @@ ExprStmtBuilder::visit (HIR::ArrayIndexExpr &expr)
   auto lhs = visit_expr (*expr.get_array_expr ());
   auto rhs = visit_expr (*expr.get_index_expr ());
   // The index is not tracked in BIR.
-  (void) rhs;
+  std::ignore = rhs;
   return_place (
 ctx.place_db.lookup_or_add_path (Place::INDEX, lookup_type (expr), lhs));
 }
@@ -454,7 +454,7 @@ ExprStmtBuilder::visit (HIR::LoopExpr &expr)
 {
   auto loop = setup_loop (expr);
 
-  (void) visit_expr (*expr.get_loop_block ());
+  std::ignore = visit_expr (*expr.get_loop_block ());
   if (!ctx.get_current_bb ().is_terminated ())
 push_goto (loop.continue_bb);
 
@@ -471,7 +471,7 @@ ExprStmtBuilder::visit (HIR::WhileLoopExpr &expr)
   push_switch (cond_val, {body_bb, loop.break_bb});
 
   ctx.current_bb = body_bb;
-  (void) visit_expr (*expr.get_loop_block ());
+  std::ignore = visit_expr (*expr.get_loop_block ());
   push_goto (loop.continue_bb);
 
   ctx.current_bb = loop.break_bb;
@@ -497,7 +497,7 @@ ExprStmtBuilder::visit (HIR::IfExpr &expr)
 
   ctx.current_bb = new_bb ();
   BasicBlockId then_start_block = ctx.current_bb;
-  (void) visit_expr (*expr.get_if_block ());
+  std::ignore = visit_expr (*expr.get_if_block ());
   if (!ctx.get_current_bb ().is_terminated ())
 push_goto (INVALID_BB); // Resolved later.
   BasicBlockId then_end_block = ctx.current_bb;
@@ -525,14 +525,14 @@ ExprStmtBuilder::visit (HIR::IfExprConseqElse &expr)
 
   ctx.current_bb = new_bb ();
   BasicBlockId then_start_bb = ctx.current_bb;
-  (void) visit_expr (*expr.get_if_block (), result);
+  std::ignore = visit_expr (*expr.get_if_block (), result);
   if (!ctx.get_current_bb ().is_terminated ())
 push_goto (INVALID_BB); // Resolved later.
   BasicBlockId then_end_bb = ctx.current_bb;
 
   ctx.current_bb = new_bb ();
   BasicBlockId else_start_bb = ctx.current_bb;
-  (void) visit_expr (*expr.get_else_block (), result);
+  std::ignore = visit_expr (*expr.get_else_block (), result);
   if (!ctx.get_current_bb ().is_terminated ())
 push_goto (INVALID_BB); // Resolved later.
   BasicBlockId else_end_bb = ctx.current_bb;
@@ -658,7 +658,7 @@ ExprStmtBuilder::visit (HIR::LetStmt &stmt)
push_user_type_ascription (var, lookup_type (*stmt.get_type ()));
 
   if (stmt.has_init_expr ())
-   (void) visit_expr (*stmt.get_init_expr (), var);
+   std::ignore = visit_expr (*stmt.get_init_expr (), var);
 }
   else
 {


[gcc/devel/rust/master] borrowck: Polonius dump

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:509c286cb0665720550cb88a2628a98d35f1b37e

commit 509c286cb0665720550cb88a2628a98d35f1b37e
Author: Jakub Dupak 
Date:   Tue Feb 27 23:52:53 2024 +0100

borrowck: Polonius dump

gcc/rust/ChangeLog:

* checks/errors/borrowck/polonius/rust-polonius.h (struct 
FullPoint):
Polonius facts dump.
(struct Facts): Polonius facts dump.
* checks/errors/borrowck/rust-bir-dump.cc (Dump::go):
Polonius facts dump.
(Dump::visit): Polonius facts dump.
(Dump::visit_place): Polonius facts dump.
(Dump::visit_move_place): Polonius facts dump.
(Dump::visit_scope): Polonius facts dump.
* checks/errors/borrowck/rust-borrow-checker.cc 
(BorrowChecker::go): Polonius facts dump.

Signed-off-by: Jakub Dupak 

Diff:
---
 .../errors/borrowck/polonius/rust-polonius.h   |  2 +-
 gcc/rust/checks/errors/borrowck/rust-bir-dump.cc   | 25 ++--
 .../checks/errors/borrowck/rust-borrow-checker.cc  | 69 +-
 3 files changed, 88 insertions(+), 8 deletions(-)

diff --git a/gcc/rust/checks/errors/borrowck/polonius/rust-polonius.h 
b/gcc/rust/checks/errors/borrowck/polonius/rust-polonius.h
index 239cc3440117..1534260552b0 100644
--- a/gcc/rust/checks/errors/borrowck/polonius/rust-polonius.h
+++ b/gcc/rust/checks/errors/borrowck/polonius/rust-polonius.h
@@ -148,7 +148,7 @@ struct Facts
   void dump_var_used_at (std::ostream &os) const
   {
 for (auto &e : var_used_at)
-  os << e.first - 1 << " " << FullPoint (e.second) << "\n";
+  os << e.first << " " << FullPoint (e.second) << "\n";
   }
 
   void dump_var_defined_at (std::ostream &os) const
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc 
b/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
index d3398b6f405a..03e2b8ea404c 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
@@ -115,7 +115,7 @@ Dump::go (bool enable_simplify_cfg)
   if (enable_simplify_cfg)
 simplify_cfg (func, bb_fold_map);
 
-  renumber_places (func, place_map);
+  // renumber_places (func, place_map);
 
   stream << "fn " << name << "(";
   print_comma_separated (stream, func.arguments, [this] (PlaceId place_id) {
@@ -214,6 +214,8 @@ Dump::visit (const Statement &stmt)
   visit_place (stmt.get_place ());
   stream << ")";
   break;
+default:
+  rust_internal_error_at (UNKNOWN_LOCATION, "Unknown statement kind.");
 }
   statement_place = INVALID_PLACE;
 }
@@ -251,7 +253,8 @@ Dump::visit_place (PlaceId place_id)
   stream << "const " << get_tyty_name (place.tyty);
   break;
 case Place::INVALID:
-  stream << "_INVALID";
+  if (place_id == INVALID_PLACE)
+   stream << "_INVALID";
 }
 }
 
@@ -259,7 +262,7 @@ void
 Dump::visit_move_place (PlaceId place_id)
 {
   const Place &place = func.place_db[place_id];
-  if (!place.is_constant ())
+  if (place.should_be_moved ())
 stream << "move ";
   visit_place (place_id);
 }
@@ -267,7 +270,11 @@ Dump::visit_move_place (PlaceId place_id)
 void
 Dump::visit (const BorrowExpr &expr)
 {
-  stream << "&";
+  stream << "&"
+<< "'?" << expr.get_origin () << " ";
+  if (func.place_db.get_loans ()[expr.get_loan ()].mutability
+  == Mutability::Mut)
+stream << "mut ";
   visit_place (expr.get_place ());
 }
 
@@ -360,7 +367,15 @@ Dump::visit_scope (ScopeId id, size_t depth)
   indent (depth + 1) << "let _";
   stream << place_map[local] << ": "
 << get_tyty_name (func.place_db[local].tyty);
-  stream << ";\n";
+  stream << ";\t";
+
+  stream << "[";
+  print_comma_separated (stream,
+func.place_db[local].regions.get_regions (),
+[this] (FreeRegion region_id) {
+  stream << "'?" << region_id;
+});
+  stream << "]\n";
 }
   for (auto &child : scope.children)
 visit_scope (child, (id >= 1) ? depth + 1 : depth);
diff --git a/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc 
b/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc
index ae06aadaa5b1..a2351c57eb42 100644
--- a/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc
@@ -18,9 +18,10 @@
 
 #include "rust-borrow-checker.h"
 #include "rust-function-collector.h"
+#include "rust-bir-fact-collector.h"
 #include "rust-bir-builder.h"
 #include "rust-bir-dump.h"
-#include "rust-bir-fact-collector.h"
+#include "polonius/rust-polonius.h"
 
 namespace Rust {
 namespace HIR {
@@ -36,7 +37,7 @@ mkdir_wrapped (const std::string &dirname)
 #elif __APPLE__
   ret = mkdir (dirname.c_str (), 0775);
 #endif
-  (void) ret;
+  rust_assert (ret == 0 || errno == EEXIST);
 }
 
 void
@@ -68,6 +69,8 @@ BorrowChecker::go (HIR::Crate &crate)
= mappings->get_crate_name (crate.get_mappings ().get

[gcc/devel/rust/master] Inline 'gcc/rust/Make-lang.in:RUST_LIBDEPS'

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:e1c80b39a6421e7f68c7ffbed7b1f67a9c60cf93

commit e1c80b39a6421e7f68c7ffbed7b1f67a9c60cf93
Author: Thomas Schwinge 
Date:   Wed Feb 28 23:06:25 2024 +0100

Inline 'gcc/rust/Make-lang.in:RUST_LIBDEPS'

gcc/rust/
* Make-lang.in (RUST_LIBDEPS): Inline into all users.

Diff:
---
 gcc/rust/Make-lang.in | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index d2ab626d3939..862dbf6a8791 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -228,10 +228,8 @@ rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o
 LIBPROC_MACRO_INTERNAL = 
../libgrust/libproc_macro_internal/libproc_macro_internal.a
 LIBFORMAT_PARSER = rust/libformat_parser.a
 
-RUST_LIBDEPS = $(LIBDEPS) $(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER)
-
 # The compiler itself is called crab1
-crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(RUST_LIBDEPS) 
$(rust.prev)
+crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS) 
$(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) $(rust.prev)
@$(call LINK_PROGRESS,$(INDEX.rust),start)
+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
  $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) 
$(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) $(BACKENDLIBS)


[gcc/devel/rust/master] Remove unnecessary SIDE_EFFECTS/READONLY macros

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:3a31617b48a4840b0aa90726333e4e7dedf1493b

commit 3a31617b48a4840b0aa90726333e4e7dedf1493b
Author: Mael Cravero 
Date:   Tue Apr 30 12:04:50 2024 +0200

Remove unnecessary SIDE_EFFECTS/READONLY macros

Closes #2357

gcc/rust/ChangeLog:

* rust-gcc.cc: remove unnecessary TREE_SIDE_EFFECTS and 
TREE_READONLY
macros used in arithmetic overflow checks.

Signed-off-by: Mael Cravero 

Diff:
---
 gcc/rust/rust-gcc.cc | 17 -
 1 file changed, 17 deletions(-)

diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index f17e19a2dfcf..6f547ee7b9de 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -1149,15 +1149,6 @@ fetch_overflow_builtins (ArithmeticOrLogicalOperator op)
   rust_assert (abort);
   rust_assert (builtin);
 
-  // FIXME: ARTHUR: This is really ugly. The builtin context should take care 
of
-  // that
-  TREE_SIDE_EFFECTS (abort) = 1;
-  TREE_READONLY (abort) = 0;
-
-  // FIXME: ARTHUR: Same here. Remove these!
-  TREE_SIDE_EFFECTS (builtin) = 1;
-  TREE_READONLY (builtin) = 0;
-
   return {abort, builtin};
 }
 
@@ -1192,10 +1183,6 @@ arithmetic_or_logical_expression_checked 
(ArithmeticOrLogicalOperator op,
 
   auto abort_call = build_call_expr_loc (location, abort, 0);
 
-  // FIXME: ARTHUR: Is that needed?
-  TREE_SIDE_EFFECTS (abort_call) = 1;
-  TREE_READONLY (abort_call) = 0;
-
   auto builtin_call
 = build_call_expr_loc (location, builtin, 3, left, right, result_ref);
   auto overflow_check
@@ -1205,10 +1192,6 @@ arithmetic_or_logical_expression_checked 
(ArithmeticOrLogicalOperator op,
   auto if_block = build3_loc (location, COND_EXPR, void_type_node,
  overflow_check, abort_call, NULL_TREE);
 
-  // FIXME: ARTHUR: Needed?
-  TREE_SIDE_EFFECTS (if_block) = 1;
-  TREE_READONLY (if_block) = 0;
-
   return if_block;
 }


[gcc/devel/rust/master] Add 'gcc/rust/Make-lang.in:LIBFORMAT_PARSER'

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:fb9ff2f1550c3317628e4d8c9602f8b65c527865

commit fb9ff2f1550c3317628e4d8c9602f8b65c527865
Author: Thomas Schwinge 
Date:   Wed Feb 28 22:51:24 2024 +0100

Add 'gcc/rust/Make-lang.in:LIBFORMAT_PARSER'

... to avoid verbatim repetition.

gcc/rust/
* Make-lang.in (LIBPROC_MACRO_INTERNAL): New.
(RUST_LIBDEPS, crab1$(exeext), rust/libformat_parser.a): Use it.

Diff:
---
 gcc/rust/Make-lang.in | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index 6c34c7cb9070..d2ab626d3939 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -226,14 +226,15 @@ RUST_ALL_OBJS = $(GRS_OBJS) $(RUST_TARGET_OBJS)
 rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o
 
 LIBPROC_MACRO_INTERNAL = 
../libgrust/libproc_macro_internal/libproc_macro_internal.a
+LIBFORMAT_PARSER = rust/libformat_parser.a
 
-RUST_LIBDEPS = $(LIBDEPS) $(LIBPROC_MACRO_INTERNAL) rust/libformat_parser.a
+RUST_LIBDEPS = $(LIBDEPS) $(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER)
 
 # The compiler itself is called crab1
 crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(RUST_LIBDEPS) 
$(rust.prev)
@$(call LINK_PROGRESS,$(INDEX.rust),start)
+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
- $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) 
$(LIBPROC_MACRO_INTERNAL) rust/libformat_parser.a $(BACKENDLIBS)
+ $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) 
$(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) $(BACKENDLIBS)
@$(call LINK_PROGRESS,$(INDEX.rust),end)
 
 # Build hooks.
@@ -423,7 +424,7 @@ rust/%.o: rust/lex/%.cc
echo $@
 
 # TODO: Improve `cargo` invocation with host specific flags, possibly creating 
a $(CARGO) variable?
-rust/libformat_parser.a: $(srcdir)/../libgrust/libformat_parser/Cargo.toml 
$(wildcard $(srcdir)/../libgrust/libformat_parser/src/*.rs)
+$(LIBFORMAT_PARSER): $(srcdir)/../libgrust/libformat_parser/Cargo.toml 
$(wildcard $(srcdir)/../libgrust/libformat_parser/src/*.rs)
cd $(srcdir)/../libgrust/libformat_parser && cargo build --offline  # 
FIXME: Not always release, right?
cp 
$(srcdir)/../libgrust/libformat_parser/target/debug/liblibformat_parser.a $@


[gcc/devel/rust/master] borrowck: Testsuite

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:35e028f58c18876a8286745ac628bdc882818ead

commit 35e028f58c18876a8286745ac628bdc882818ead
Author: Jakub Dupak 
Date:   Wed Apr 24 13:47:20 2024 +0200

borrowck: Testsuite

gcc/testsuite/ChangeLog:

* rust/borrowck/borrowck.exp: New test.
* rust/borrowck/position_dependant_outlives.rs: New test.
* rust/borrowck/reference.rs: New test.
* rust/borrowck/return_ref_to_local.rs: New test.
* rust/borrowck/subset.rs: New test.
* rust/borrowck/test_move.rs: New test.
* rust/borrowck/test_move_behind_reference.rs: New test.
* rust/borrowck/test_move_conditional.rs: New test.
* rust/borrowck/tmp.rs: New test.
* rust/borrowck/use_while_mut.rs: New test.
* rust/borrowck/use_while_mut_fr.rs: New test.
* rust/borrowck/well_formed_function_inputs.rs: New test.

Diff:
---
 gcc/testsuite/rust/borrowck/borrowck.exp   | 35 
 .../rust/borrowck/position_dependant_outlives.rs   | 11 +++
 gcc/testsuite/rust/borrowck/reference.rs   | 99 ++
 gcc/testsuite/rust/borrowck/return_ref_to_local.rs |  6 ++
 gcc/testsuite/rust/borrowck/subset.rs  | 27 ++
 gcc/testsuite/rust/borrowck/test_move.rs   | 16 
 .../rust/borrowck/test_move_behind_reference.rs| 27 ++
 .../rust/borrowck/test_move_conditional.rs | 28 ++
 gcc/testsuite/rust/borrowck/tmp.rs | 79 +
 gcc/testsuite/rust/borrowck/use_while_mut.rs   |  7 ++
 gcc/testsuite/rust/borrowck/use_while_mut_fr.rs|  8 ++
 .../rust/borrowck/well_formed_function_inputs.rs   | 16 
 12 files changed, 359 insertions(+)

diff --git a/gcc/testsuite/rust/borrowck/borrowck.exp 
b/gcc/testsuite/rust/borrowck/borrowck.exp
new file mode 100644
index ..6e96a7d11d87
--- /dev/null
+++ b/gcc/testsuite/rust/borrowck/borrowck.exp
@@ -0,0 +1,35 @@
+# Copyright (C) 2021-2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# .
+
+# Compile tests, no torture testing.
+#
+# These tests raise errors in the front end; torture testing doesn't apply.
+
+# Load support procs.
+load_lib rust-dg.exp
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+set saved-dg-do-what-default ${dg-do-what-default}
+
+set dg-do-what-default "compile"
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.rs]] "" ""
+set dg-do-what-default ${saved-dg-do-what-default}
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/rust/borrowck/position_dependant_outlives.rs 
b/gcc/testsuite/rust/borrowck/position_dependant_outlives.rs
new file mode 100644
index ..7856934a6b36
--- /dev/null
+++ b/gcc/testsuite/rust/borrowck/position_dependant_outlives.rs
@@ -0,0 +1,11 @@
+// { dg-additional-options "-frust-compile-until=compilation 
-frust-borrowcheck" }
+
+pub fn position_dependent_outlives<'a>(x: &'a mut i32, cond: bool) -> &'a mut 
i32 {
+let y = &mut *x;
+if cond {
+return y;
+} else {
+*x = 0;
+return x;
+}
+}
\ No newline at end of file
diff --git a/gcc/testsuite/rust/borrowck/reference.rs 
b/gcc/testsuite/rust/borrowck/reference.rs
new file mode 100644
index ..b825a9686b75
--- /dev/null
+++ b/gcc/testsuite/rust/borrowck/reference.rs
@@ -0,0 +1,99 @@
+// { dg-additional-options "-frust-compile-until=compilation 
-frust-borrowcheck" }
+
+
+#[lang = "sized"]
+pub trait Sized {}
+
+struct Reference<'a> {
+value: &'a i32,
+}
+
+impl<'a> Reference<'a> {
+fn new<'a>(value: &'a i32) -> Reference<'a> {
+Reference { value: value }
+}
+}
+
+struct ReferenceMut<'a> {
+value: &'a mut i32,
+}
+
+impl<'a> ReferenceMut<'a> {
+fn new<'a>(value: &'a mut i32) -> ReferenceMut<'a> {
+ReferenceMut { value: value }
+}
+}
+
+fn immutable_borrow_while_immutable_borrowed_struct() {
+let x = 0;
+let y = Reference::new(&x);
+let z = &x;
+let w = y;
+}
+
+fn immutable_borrow_while_mutable_borrowed_struct() {
+// { dg-error "Found loan errors in function 
immutable_borrow_while_mutable_borrowed_struct" "" { target *-*-* } .-1 }
+let mut x = 0;
+let y = ReferenceMut::new(&mut x);
+let z = &x; //~ ERROR
+let w = y;
+}
+
+fn mutable_borrow_while_immutable_borrowed_struct() {
+// { dg-erro

[gcc/devel/rust/master] Remove 'libgrust/libproc_macro_internal' from 'gcc/rust/Make-lang.in:RUST_LDFLAGS'

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:97759a56aa09fcef19c2202d0d91dd9fedf94547

commit 97759a56aa09fcef19c2202d0d91dd9fedf94547
Author: Thomas Schwinge 
Date:   Wed Feb 28 22:41:42 2024 +0100

Remove 'libgrust/libproc_macro_internal' from 
'gcc/rust/Make-lang.in:RUST_LDFLAGS'

This isn't necessary, as the full path to 'libproc_macro_internal.a' is
specified.

gcc/rust/
* Make-lang.in (RUST_LDFLAGS): Remove
'libgrust/libproc_macro_internal'.

Diff:
---
 gcc/rust/Make-lang.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index a68ae1e93f68..13e035da218b 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -225,7 +225,7 @@ RUST_ALL_OBJS = $(GRS_OBJS) $(RUST_TARGET_OBJS)
 
 rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o
 
-RUST_LDFLAGS = $(LDFLAGS) -L./../libgrust/libproc_macro_internal
+RUST_LDFLAGS = $(LDFLAGS)
 RUST_LIBDEPS = $(LIBDEPS) 
../libgrust/libproc_macro_internal/libproc_macro_internal.a 
rust/libformat_parser.a
 
 # The compiler itself is called crab1


[gcc/devel/rust/master] borrowck: Link Polonius and run it

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:5f0db57567e147846cd0b7aa4cb2fc8bba9208a0

commit 5f0db57567e147846cd0b7aa4cb2fc8bba9208a0
Author: Jakub Dupak 
Date:   Tue Feb 27 23:59:36 2024 +0100

borrowck: Link Polonius and run it

gcc/rust/ChangeLog:

* Make-lang.in: Link Polonius.
* checks/errors/borrowck/rust-borrow-checker.cc: Run Polonius.

Signed-off-by: Jakub Dupak 

Diff:
---
 gcc/rust/Make-lang.in  | 7 +--
 gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc | 2 ++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index 3275015b0466..dd94c9b5eab5 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -227,12 +227,15 @@ rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o
 
 LIBPROC_MACRO_INTERNAL = 
../libgrust/libproc_macro_internal/libproc_macro_internal.a
 LIBFORMAT_PARSER = ../libgrust/libformat_parser/debug/liblibformat_parser.a
+LIBFFI_POLONIUS = rust/libffi_polonius.a
 
 # The compiler itself is called crab1
-crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS) 
$(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) $(rust.prev)
+crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS) 
$(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) $(LIBFFI_POLONIUS) $(rust.prev)
@$(call LINK_PROGRESS,$(INDEX.rust),start)
+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
- $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) 
$(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) $(BACKENDLIBS)
+ $(RUST_ALL_OBJS) attribs.o $(BACKEND) \
+ $(LIBS) $(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) 
$(LIBFFI_POLONIUS) \
+ $(BACKENDLIBS)
@$(call LINK_PROGRESS,$(INDEX.rust),end)
 
 # Build hooks.
diff --git a/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc 
b/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc
index a2351c57eb42..168b7054608d 100644
--- a/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc
@@ -154,6 +154,8 @@ BorrowChecker::go (HIR::Crate &crate)
  dump_facts_to_file ("placeholder",
  &Polonius::Facts::dump_placeholder);
}
+
+  Polonius::polonius_run (facts.freeze (), rust_be_debug_p ());
 }
 
   for (auto closure ATTRIBUTE_UNUSED : collector.get_closures ())


[gcc/devel/rust/master] Removed obsolete objects

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:3b9a0405f494774ce3054c87baea20aa3164eb4d

commit 3b9a0405f494774ce3054c87baea20aa3164eb4d
Author: Kushal Pal 
Date:   Wed Apr 24 06:04:53 2024 +

Removed obsolete objects

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::visit): Lines
removed as the objects are unused.

Signed-off-by: Kushal Pal 

Diff:
---
 gcc/rust/backend/rust-compile-expr.cc | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/gcc/rust/backend/rust-compile-expr.cc 
b/gcc/rust/backend/rust-compile-expr.cc
index 6a9bb73ffe0f..b5b88b410e58 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -1304,23 +1304,14 @@ CompileExpr::visit (HIR::MethodCallExpr &expr)
 {
   const TyTy::DynamicObjectType *dyn
= static_cast (receiver->get_root ());
-
-  std::vector arguments;
-  for (auto &arg : expr.get_arguments ())
-   arguments.push_back (arg.get ());
-
   fn_expr
= get_fn_addr_from_dyn (dyn, receiver, fntype, self, expr.get_locus ());
   self = get_receiver_from_dyn (dyn, receiver, fntype, self,
expr.get_locus ());
 }
   else
-{
-  // lookup compiled functions since it may have already been compiled
-  HIR::PathExprSegment method_name = expr.get_method_name ();
-  HIR::PathIdentSegment segment_name = method_name.get_segment ();
-  fn_expr = resolve_method_address (fntype, receiver, expr.get_locus ());
-}
+// lookup compiled functions since it may have already been compiled
+fn_expr = resolve_method_address (fntype, receiver, expr.get_locus ());
 
   // lookup the autoderef mappings
   HirId autoderef_mappings_id


[gcc/devel/rust/master] Add a test for inherent impl type name resolve

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:5b6c98285583130072cfa9ce84cbfd357a58c267

commit 5b6c98285583130072cfa9ce84cbfd357a58c267
Author: Pierre-Emmanuel Patry 
Date:   Thu Apr 18 22:39:47 2024 +0200

Add a test for inherent impl type name resolve

A previous bug with name resolution 2.0 was caused by an incorrectly
resolved inherent impl name. This test shall highlight the behavior
and prevent regression.

gcc/testsuite/ChangeLog:

* rust/compile/name_resolution25.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/testsuite/rust/compile/name_resolution25.rs | 5 +
 1 file changed, 5 insertions(+)

diff --git a/gcc/testsuite/rust/compile/name_resolution25.rs 
b/gcc/testsuite/rust/compile/name_resolution25.rs
new file mode 100644
index ..3cacac7f64bd
--- /dev/null
+++ b/gcc/testsuite/rust/compile/name_resolution25.rs
@@ -0,0 +1,5 @@
+// { dg-options "-frust-name-resolution-2.0" }
+
+struct Test; // { dg-warning "struct is never constructed: .Test." }
+
+impl Test {}


[gcc/devel/rust/master] Visit type during resolution of inherent impl

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:973e60a2be6936d4909a9ccda1c9dce1e6eb1f4a

commit 973e60a2be6936d4909a9ccda1c9dce1e6eb1f4a
Author: Pierre-Emmanuel Patry 
Date:   Thu Apr 18 22:30:56 2024 +0200

Visit type during resolution of inherent impl

Inherent impl has a type it applies to. This type
was not visited and thus not resolved.

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc (DefaultResolver::visit): Visit
inherent impl type.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/rust/resolve/rust-default-resolver.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/rust/resolve/rust-default-resolver.cc 
b/gcc/rust/resolve/rust-default-resolver.cc
index 393994808ee0..c54cabad2e5d 100644
--- a/gcc/rust/resolve/rust-default-resolver.cc
+++ b/gcc/rust/resolve/rust-default-resolver.cc
@@ -115,6 +115,7 @@ void
 DefaultResolver::visit (AST::InherentImpl &impl)
 {
   auto inner_fn = [this, &impl] () {
+visit (impl.get_type ());
 for (auto &item : impl.get_impl_items ())
   item->accept_vis (*this);
   };


[gcc/devel/rust/master] Merge commit '2a9881565c7b48d04cf891666a66a1a2e560bce8' into HEAD

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:17ee9c68cbc9ba7a13b77ea458fbbc6275c38d02

commit 17ee9c68cbc9ba7a13b77ea458fbbc6275c38d02
Merge: e02c6e686bd3 2a9881565c7b
Author: Thomas Schwinge 
Date:   Wed Apr 10 10:55:46 2024 +0200

Merge commit '2a9881565c7b48d04cf891666a66a1a2e560bce8' into HEAD

Diff:


[gcc/devel/rust/master] Rust: Move 'libformat_parser' build into libgrust

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:611d0bdc55a858736bd5cfabfc1ed4fef800d81a

commit 611d0bdc55a858736bd5cfabfc1ed4fef800d81a
Author: Thomas Schwinge 
Date:   Thu Feb 29 08:44:49 2024 +0100

Rust: Move 'libformat_parser' build into libgrust

Addresses #2883.

contrib/
* gcc_update (files_and_dependencies): Update for
'libformat_parser' in libgrust.
gcc/rust/
* Make-lang.in (LIBFORMAT_PARSER): Point to 'libformat_parser'
build in libgrust.
(%.toml:, $(LIBFORMAT_PARSER):): Remove.
libgrust/
* libformat_parser/Makefile.am: New.
* Makefile.am [!TARGET_LIBRARY] (SUBDIRS): Add 'libformat_parser'.
* configure.ac: Handle it.
(TARGET_LIBRARY): New 'AM_CONDITIONAL'.
* libformat_parser/Makefile.in: Generate.
* Makefile.in: Regenerate.
* configure: Likewise.

Diff:
---
 contrib/gcc_update|   1 +
 gcc/rust/Make-lang.in |  16 +-
 libgrust/Makefile.am  |   6 +-
 libgrust/Makefile.in  |   5 +-
 libgrust/configure|  22 +-
 libgrust/configure.ac |   3 +
 libgrust/libformat_parser/Makefile.am |  13 +
 libgrust/libformat_parser/Makefile.in | 441 ++
 8 files changed, 487 insertions(+), 20 deletions(-)

diff --git a/contrib/gcc_update b/contrib/gcc_update
index 774c926e723d..2c50592eb359 100755
--- a/contrib/gcc_update
+++ b/contrib/gcc_update
@@ -156,6 +156,7 @@ libgomp/config.h.in: libgomp/configure.ac libgomp/aclocal.m4
 libgrust/Makefile.in: libgrust/Makefile.am libgrust/aclocal.m4
 libgrust/aclocal.m4: libgrust/configure.ac
 libgrust/configure: libgrust/configure.ac libgrust/aclocal.m4
+libgrust/libformat_parser/Makefile.in: libgrust/libformat_parser/Makefile.am 
libgrust/aclocal.m4
 libgrust/libproc_macro_internal/Makefile.in: 
libgrust/libproc_macro_internal/Makefile.am libgrust/aclocal.m4
 libitm/aclocal.m4: libitm/configure.ac libitm/acinclude.m4
 libitm/Makefile.in: libitm/Makefile.am libitm/aclocal.m4
diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index 0c664b523d11..74663379487d 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -226,8 +226,7 @@ RUST_ALL_OBJS = $(GRS_OBJS) $(RUST_TARGET_OBJS)
 rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o
 
 LIBPROC_MACRO_INTERNAL = 
../libgrust/libproc_macro_internal/libproc_macro_internal.a
-LIBFORMAT_PARSER_D = rust/libformat_parser
-LIBFORMAT_PARSER = $(LIBFORMAT_PARSER_D)/debug/liblibformat_parser.a
+LIBFORMAT_PARSER = ../libgrust/libformat_parser/debug/liblibformat_parser.a
 
 # The compiler itself is called crab1
 crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS) 
$(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) $(rust.prev)
@@ -419,19 +418,6 @@ rust/%.o: rust/lex/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
$(POSTCOMPILE)
 
-%.toml:
-   echo $@
-
-# TODO: Improve `cargo` invocation with host specific flags, possibly creating 
a $(CARGO) variable?
-$(LIBFORMAT_PARSER): $(srcdir)/../libgrust/libformat_parser/Cargo.toml 
$(wildcard $(srcdir)/../libgrust/libformat_parser/src/*.rs)
-   cargo \
- --config $(srcdir)/../libgrust/libformat_parser/.cargo/config \
- build \
-   --offline \
-   --target-dir $(LIBFORMAT_PARSER_D) \
-   --manifest-path $(srcdir)/../libgrust/libformat_parser/Cargo.toml \
-   # FIXME: Not always '--release', right?
-
 # build all rust/parse files in rust folder, add cross-folder includes
 rust/%.o: rust/parse/%.cc
$(COMPILE) $(RUST_CXXFLAGS) $(RUST_INCLUDES) $<
diff --git a/libgrust/Makefile.am b/libgrust/Makefile.am
index 5b38c8842cb4..7a4512cae96b 100644
--- a/libgrust/Makefile.am
+++ b/libgrust/Makefile.am
@@ -11,7 +11,11 @@ TOP_GCCDIR := $(shell cd $(top_srcdir) && cd .. && pwd)
 GCC_DIR = $(TOP_GCCDIR)/gcc
 RUST_SRC = $(GCC_DIR)/rust
 
-SUBDIRS = libproc_macro_internal
+SUBDIRS =
+if !TARGET_LIBRARY
+SUBDIRS += libformat_parser
+endif
+SUBDIRS += libproc_macro_internal
 
 RUST_BUILDDIR := $(shell pwd)
 
diff --git a/libgrust/Makefile.in b/libgrust/Makefile.in
index d065584d196f..6665f8da738f 100644
--- a/libgrust/Makefile.in
+++ b/libgrust/Makefile.in
@@ -88,6 +88,7 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
+@TARGET_LIBRARY_FALSE@am__append_1 = libformat_parser
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
@@ -165,7 +166,7 @@ am__define_uniq_tagged_files = \
 ETAGS = etags
 CTAGS = ctags
 CSCOPE = cscope
-DIST_SUBDIRS = $(SUBDIRS)
+DIST_SUBDIRS = libformat_parser libproc_macro_internal
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
@@ -308,7 +309,7 @@ AM_CFLAGS = -I $(srcdir)/../libgcc -I 
$(MULTIBUILDTOP)../../gcc/include
 TOP_GCCDIR := $(shell cd $(top_srcdir) && 

[gcc/devel/rust/master] Rust: Move 'libformat_parser' build into the GCC build directory

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:8dde956e18426b2204e660d3e7ff68bb8589a635

commit 8dde956e18426b2204e660d3e7ff68bb8589a635
Author: Thomas Schwinge 
Date:   Wed Feb 28 23:26:39 2024 +0100

Rust: Move 'libformat_parser' build into the GCC build directory

Fixes #2883.

* .gitignore: Remove 'libgrust/*/target/'.
gcc/rust/
* Make-lang.in (LIBFORMAT_PARSER): Point to the GCC build
directory.
* ($(LIBFORMAT_PARSER)): Build in the GCC build directory.

Diff:
---
 .gitignore|  1 -
 gcc/rust/Make-lang.in | 11 +--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1b2ecabbfe7e..d0e0fd1837f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -77,4 +77,3 @@ test.code-workspace
 
 gcc/rust/test3-tiny/*
 .clang-format.swap
-libgrust/*/target/
diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index fbd43c96b1a0..0c664b523d11 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -226,7 +226,8 @@ RUST_ALL_OBJS = $(GRS_OBJS) $(RUST_TARGET_OBJS)
 rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o
 
 LIBPROC_MACRO_INTERNAL = 
../libgrust/libproc_macro_internal/libproc_macro_internal.a
-LIBFORMAT_PARSER = 
$(srcdir)/../libgrust/libformat_parser/target/debug/liblibformat_parser.a
+LIBFORMAT_PARSER_D = rust/libformat_parser
+LIBFORMAT_PARSER = $(LIBFORMAT_PARSER_D)/debug/liblibformat_parser.a
 
 # The compiler itself is called crab1
 crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS) 
$(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) $(rust.prev)
@@ -423,7 +424,13 @@ rust/%.o: rust/lex/%.cc
 
 # TODO: Improve `cargo` invocation with host specific flags, possibly creating 
a $(CARGO) variable?
 $(LIBFORMAT_PARSER): $(srcdir)/../libgrust/libformat_parser/Cargo.toml 
$(wildcard $(srcdir)/../libgrust/libformat_parser/src/*.rs)
-   cd $(srcdir)/../libgrust/libformat_parser && cargo build --offline  # 
FIXME: Not always release, right?
+   cargo \
+ --config $(srcdir)/../libgrust/libformat_parser/.cargo/config \
+ build \
+   --offline \
+   --target-dir $(LIBFORMAT_PARSER_D) \
+   --manifest-path $(srcdir)/../libgrust/libformat_parser/Cargo.toml \
+   # FIXME: Not always '--release', right?
 
 # build all rust/parse files in rust folder, add cross-folder includes
 rust/%.o: rust/parse/%.cc


[gcc/devel/rust/master] Rust: Don't cache 'libformat_parser.a'

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:34a70f48756cb294da342245f5d2b0d622fa298c

commit 34a70f48756cb294da342245f5d2b0d622fa298c
Author: Thomas Schwinge 
Date:   Wed Feb 28 23:02:19 2024 +0100

Rust: Don't cache 'libformat_parser.a'

gcc/rust/
* Make-lang.in (LIBFORMAT_PARSER): Point to the actual build 
artifact.
($(LIBFORMAT_PARSER)): Don't cache it.

Diff:
---
 gcc/rust/Make-lang.in | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index 862dbf6a8791..fbd43c96b1a0 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -226,7 +226,7 @@ RUST_ALL_OBJS = $(GRS_OBJS) $(RUST_TARGET_OBJS)
 rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o
 
 LIBPROC_MACRO_INTERNAL = 
../libgrust/libproc_macro_internal/libproc_macro_internal.a
-LIBFORMAT_PARSER = rust/libformat_parser.a
+LIBFORMAT_PARSER = 
$(srcdir)/../libgrust/libformat_parser/target/debug/liblibformat_parser.a
 
 # The compiler itself is called crab1
 crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBDEPS) 
$(LIBPROC_MACRO_INTERNAL) $(LIBFORMAT_PARSER) $(rust.prev)
@@ -424,7 +424,6 @@ rust/%.o: rust/lex/%.cc
 # TODO: Improve `cargo` invocation with host specific flags, possibly creating 
a $(CARGO) variable?
 $(LIBFORMAT_PARSER): $(srcdir)/../libgrust/libformat_parser/Cargo.toml 
$(wildcard $(srcdir)/../libgrust/libformat_parser/src/*.rs)
cd $(srcdir)/../libgrust/libformat_parser && cargo build --offline  # 
FIXME: Not always release, right?
-   cp 
$(srcdir)/../libgrust/libformat_parser/target/debug/liblibformat_parser.a $@
 
 # build all rust/parse files in rust folder, add cross-folder includes
 rust/%.o: rust/parse/%.cc


[gcc/devel/rust/master] Merge commit 'e621b174d7c622aa4b677a4c812e5061e311cc5c' into HEAD

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:c9e59de17dd46032f7c63463b8738b287ae34f8c

commit c9e59de17dd46032f7c63463b8738b287ae34f8c
Merge: d2bcecd7fd91 e621b174d7c6
Author: Thomas Schwinge 
Date:   Wed Apr 10 10:48:27 2024 +0200

Merge commit 'e621b174d7c622aa4b677a4c812e5061e311cc5c' into HEAD

Diff:


[gcc/devel/rust/master] borrowck: BIR: scope handling

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:de18440f92465be93f0248a7071834baa1ec748d

commit de18440f92465be93f0248a7071834baa1ec748d
Author: Jakub Dupak 
Date:   Fri Feb 2 14:38:59 2024 +0100

borrowck: BIR: scope handling

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc 
(ExprStmtBuilder::setup_loop):
Loop handling.
(ExprStmtBuilder::visit): Handle scopes.
* checks/errors/borrowck/rust-bir-builder-internal.h (struct 
BuilderContext):
Handle scopes.
* checks/errors/borrowck/rust-bir-dump.cc (Dump::go): Dump scopes.
(Dump::visit): Add scopes dump.
(Dump::indent): Add indentation logic.
(Dump::visit_scope): Dump scope.
* checks/errors/borrowck/rust-bir-dump.h: Dump methods.
* checks/errors/borrowck/rust-bir-place.h 
(std::numeric_limits::max): Scope constants.
(struct Scope): Scope representation.
(class PlaceDB): Scope tracking.

Signed-off-by: Jakub Dupak 

Diff:
---
 .../errors/borrowck/rust-bir-builder-expr-stmt.cc  | 32 ++---
 .../errors/borrowck/rust-bir-builder-internal.h| 82 +++---
 gcc/rust/checks/errors/borrowck/rust-bir-dump.cc   | 52 ++
 gcc/rust/checks/errors/borrowck/rust-bir-dump.h|  3 +
 gcc/rust/checks/errors/borrowck/rust-bir-place.h   | 56 ++-
 5 files changed, 188 insertions(+), 37 deletions(-)

diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc 
b/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
index ea8107b1fb76..89352d84f6b8 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
@@ -37,9 +37,17 @@ ExprStmtBuilder::setup_loop (HIR::BaseLoopExpr &expr)
   PlaceId label_var = take_or_create_return_place (lookup_type (expr));
 
   BasicBlockId continue_bb = new_bb ();
+  push_goto (continue_bb);
+  ctx.current_bb = continue_bb;
+  // falseUnwind
+  start_new_consecutive_bb ();
+
   BasicBlockId break_bb = new_bb ();
-  ctx.loop_and_label_stack.push_back (
-{true, label, label_var, break_bb, continue_bb});
+  // We are still outside the loop block;
+  ScopeId continue_scope = ctx.place_db.get_current_scope_id () + 1;
+  ctx.loop_and_label_stack.emplace_back (true, label, label_var, break_bb,
+continue_bb, continue_scope);
+
   return ctx.loop_and_label_stack.back ();
 }
 
@@ -289,13 +297,16 @@ ExprStmtBuilder::visit (HIR::FieldAccessExpr &expr)
 void
 ExprStmtBuilder::visit (HIR::BlockExpr &block)
 {
+  push_new_scope ();
+
   if (block.has_label ())
 {
   NodeId label
= block.get_label ().get_lifetime ().get_mappings ().get_nodeid ();
   PlaceId label_var = take_or_create_return_place (lookup_type (block));
-  ctx.loop_and_label_stack.push_back (
-   {false, label, label_var, new_bb (), INVALID_BB});
+  ctx.loop_and_label_stack.emplace_back (
+   false, label, label_var, new_bb (), INVALID_BB,
+   ctx.place_db.get_current_scope_id ());
 }
 
   // Eliminates dead code after break, continue, return.
@@ -333,6 +344,8 @@ ExprStmtBuilder::visit (HIR::BlockExpr &block)
take_or_create_return_place (
  lookup_type (*block.get_final_expr ();
 }
+
+  pop_scope ();
 }
 
 void
@@ -340,6 +353,8 @@ ExprStmtBuilder::visit (HIR::ContinueExpr &cont)
 {
   LoopAndLabelCtx info = cont.has_label () ? get_label_ctx (cont.get_label ())
   : get_unnamed_loop_ctx ();
+  start_new_consecutive_bb ();
+  unwind_until (info.continue_bb);
   push_goto (info.continue_bb);
   // No code allowed after continue. Handled in BlockExpr.
 }
@@ -352,6 +367,8 @@ ExprStmtBuilder::visit (HIR::BreakExpr &brk)
   if (brk.has_break_expr ())
 push_assignment (info.label_var, visit_expr (*brk.get_expr ()));
 
+  start_new_consecutive_bb ();
+  unwind_until (ctx.place_db.get_scope (info.continue_scope).parent);
   push_goto (info.break_bb);
   // No code allowed after continue. Handled in BlockExpr.
 }
@@ -406,6 +423,7 @@ ExprStmtBuilder::visit (HIR::ReturnExpr &ret)
 {
   push_assignment (RETURN_VALUE_PLACE, visit_expr (*ret.get_expr ()));
 }
+  unwind_until (ROOT_SCOPE);
   ctx.get_current_bb ().statements.emplace_back (Statement::Kind::RETURN);
 }
 
@@ -420,9 +438,6 @@ ExprStmtBuilder::visit (HIR::LoopExpr &expr)
 {
   auto loop = setup_loop (expr);
 
-  push_goto (loop.continue_bb);
-
-  ctx.current_bb = loop.continue_bb;
   (void) visit_expr (*expr.get_loop_block ());
   if (!ctx.get_current_bb ().is_terminated ())
 push_goto (loop.continue_bb);
@@ -435,9 +450,6 @@ ExprStmtBuilder::visit (HIR::WhileLoopExpr &expr)
 {
   auto loop = setup_loop (expr);
 
-  push_goto (loop.continue_bb);
-
-  ctx.current_bb = loop.continue_bb;
   auto cond_val = visit_expr (*e

[gcc/devel/rust/master] Add 'gcc/rust/Make-lang.in:LIBPROC_MACRO_INTERNAL'

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:00d5896b317ea0c43b01e3a8649b497a5d731f29

commit 00d5896b317ea0c43b01e3a8649b497a5d731f29
Author: Thomas Schwinge 
Date:   Wed Feb 28 22:51:24 2024 +0100

Add 'gcc/rust/Make-lang.in:LIBPROC_MACRO_INTERNAL'

... to avoid verbatim repetition.

gcc/rust/
* Make-lang.in (LIBPROC_MACRO_INTERNAL): New.
(RUST_LIBDEPS, crab1$(exeext)): Use it.

Diff:
---
 gcc/rust/Make-lang.in | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index c39fd9453823..6c34c7cb9070 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -225,13 +225,15 @@ RUST_ALL_OBJS = $(GRS_OBJS) $(RUST_TARGET_OBJS)
 
 rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o
 
-RUST_LIBDEPS = $(LIBDEPS) 
../libgrust/libproc_macro_internal/libproc_macro_internal.a 
rust/libformat_parser.a
+LIBPROC_MACRO_INTERNAL = 
../libgrust/libproc_macro_internal/libproc_macro_internal.a
+
+RUST_LIBDEPS = $(LIBDEPS) $(LIBPROC_MACRO_INTERNAL) rust/libformat_parser.a
 
 # The compiler itself is called crab1
 crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(RUST_LIBDEPS) 
$(rust.prev)
@$(call LINK_PROGRESS,$(INDEX.rust),start)
+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
- $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) 
../libgrust/libproc_macro_internal/libproc_macro_internal.a 
rust/libformat_parser.a $(BACKENDLIBS)
+ $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) 
$(LIBPROC_MACRO_INTERNAL) rust/libformat_parser.a $(BACKENDLIBS)
@$(call LINK_PROGRESS,$(INDEX.rust),end)
 
 # Build hooks.


[gcc/devel/rust/master] Inline 'gcc/rust/Make-lang.in:RUST_LDFLAGS'

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:1e97d748f45e4ae4e56ef2f2cd30c90bf000d410

commit 1e97d748f45e4ae4e56ef2f2cd30c90bf000d410
Author: Thomas Schwinge 
Date:   Wed Feb 28 22:45:18 2024 +0100

Inline 'gcc/rust/Make-lang.in:RUST_LDFLAGS'

Unused.

gcc/rust/
* Make-lang.in (RUST_LDFLAGS): Inline into all users.

Diff:
---
 gcc/rust/Make-lang.in | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index 13e035da218b..c39fd9453823 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -225,13 +225,12 @@ RUST_ALL_OBJS = $(GRS_OBJS) $(RUST_TARGET_OBJS)
 
 rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o
 
-RUST_LDFLAGS = $(LDFLAGS)
 RUST_LIBDEPS = $(LIBDEPS) 
../libgrust/libproc_macro_internal/libproc_macro_internal.a 
rust/libformat_parser.a
 
 # The compiler itself is called crab1
 crab1$(exeext): $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(RUST_LIBDEPS) 
$(rust.prev)
@$(call LINK_PROGRESS,$(INDEX.rust),start)
-   +$(LLINKER) $(ALL_LINKERFLAGS) $(RUST_LDFLAGS) -o $@ \
+   +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
  $(RUST_ALL_OBJS) attribs.o $(BACKEND) $(LIBS) 
../libgrust/libproc_macro_internal/libproc_macro_internal.a 
rust/libformat_parser.a $(BACKENDLIBS)
@$(call LINK_PROGRESS,$(INDEX.rust),end)


[gcc/devel/rust/master] Improve parsing of raw byte string literals

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:67928be5b05ab927baf0a366689c246ec61ed745

commit 67928be5b05ab927baf0a366689c246ec61ed745
Author: Owen Avery 
Date:   Tue Mar 26 20:16:08 2024 -0400

Improve parsing of raw byte string literals

gcc/rust/ChangeLog:

* lex/rust-lex.cc
(Lexer::parse_raw_byte_string):
Bring handling of edge cases to par with parse_byte_string.

gcc/testsuite/ChangeLog:

* rust/compile/raw-byte-string-loc.rs: New test.

Signed-off-by: Owen Avery 

Diff:
---
 gcc/rust/lex/rust-lex.cc  | 23 +++
 gcc/testsuite/rust/compile/raw-byte-string-loc.rs |  6 ++
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc
index 9c2203160cd4..7c37e83d6cb7 100644
--- a/gcc/rust/lex/rust-lex.cc
+++ b/gcc/rust/lex/rust-lex.cc
@@ -1840,14 +1840,18 @@ Lexer::parse_raw_byte_string (location_t loc)
   int length = 1;
   int hash_count = 0;
 
+  const location_t string_begin_locus = get_current_location ();
+
   // get hash count at beginnning
   skip_input ();
   current_char = peek_input ();
   length++;
+  current_column++;
   while (current_char == '#')
 {
   hash_count++;
   length++;
+  current_column++;
 
   skip_input ();
   current_char = peek_input ();
@@ -1862,6 +1866,7 @@ Lexer::parse_raw_byte_string (location_t loc)
   skip_input ();
   current_char = peek_input ();
   length++;
+  current_column++;
 
   while (true)
 {
@@ -1884,27 +1889,37 @@ Lexer::parse_raw_byte_string (location_t loc)
  skip_input (hash_count);
  current_char = peek_input ();
  length += hash_count + 1;
+ current_column += hash_count + 1;
  break;
}
}
-
-  if (current_char.value > 127)
+  else if (current_char.value > 127)
{
  rust_error_at (get_current_location (),
 "character %<%s%> in raw byte string out of range",
 current_char.as_string ().c_str ());
  current_char = 0;
}
+  else if (current_char.is_eof ())
+   {
+ rust_error_at (string_begin_locus, "unended raw byte string literal");
+ return Token::make (END_OF_FILE, get_current_location ());
+   }
 
   length++;
+  current_column++;
+  if (current_char == '\n')
+   {
+ current_line++;
+ current_column = 1;
+ start_line (current_line, max_column_hint);
+   }
 
   str += current_char;
   skip_input ();
   current_char = peek_input ();
 }
 
-  current_column += length;
-
   loc += length - 1;
 
   str.shrink_to_fit ();
diff --git a/gcc/testsuite/rust/compile/raw-byte-string-loc.rs 
b/gcc/testsuite/rust/compile/raw-byte-string-loc.rs
new file mode 100644
index ..f37d3f9694d3
--- /dev/null
+++ b/gcc/testsuite/rust/compile/raw-byte-string-loc.rs
@@ -0,0 +1,6 @@
+const X: &'static u8 = br#"12
+12"#;
+
+BREAK
+// { dg-error "unrecognised token" "" { target *-*-* } .-1 }
+// { dg-excess-errors "error 'failed to parse item' does not have location" }


[gcc/devel/rust/master] Fix use rebind name resolution.

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:a8d1604cb38ba6a170afee40dbfbbc630b2c7c6e

commit a8d1604cb38ba6a170afee40dbfbbc630b2c7c6e
Author: Pierre-Emmanuel Patry 
Date:   Thu Mar 21 19:25:52 2024 +0100

Fix use rebind name resolution.

Name resolution for rebind were missing.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc 
(TopLevel::handle_use_glob):
Change function prototype to use a reference instead.
(TopLevel::handle_use_dec): Likewise.
(TopLevel::handle_rebind): Add name resolution on rebind use
declarations.
(flatten_rebind): Change prototype to accept a pair of path/alias.
(flatten_list): Adapt call to flatten_rebind.
(flatten): Adapt call to flatten_rebind.
(flatten_glob): Remove unused part.
(TopLevel::visit): Add rebind resolution.
* resolve/rust-toplevel-name-resolver-2.0.h: Adapt function 
prototypes.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 .../resolve/rust-toplevel-name-resolver-2.0.cc | 194 -
 gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h |   5 +-
 2 files changed, 151 insertions(+), 48 deletions(-)

diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index e6da8db850c3..4593c67c5d3e 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -17,6 +17,7 @@
 // .
 
 #include "rust-toplevel-name-resolver-2.0.h"
+#include "input.h"
 #include "optional.h"
 #include "rust-ast-full.h"
 #include "rust-hir-map.h"
@@ -434,7 +435,7 @@ TopLevel::visit (AST::ConstantItem &const_item)
 }
 
 bool
-TopLevel::handle_use_glob (AST::SimplePath glob)
+TopLevel::handle_use_glob (AST::SimplePath &glob)
 {
   auto resolved = ctx.types.resolve_path (glob.get_segments ());
   if (!resolved.has_value ())
@@ -453,7 +454,7 @@ TopLevel::handle_use_glob (AST::SimplePath glob)
 }
 
 bool
-TopLevel::handle_use_dec (AST::SimplePath path)
+TopLevel::handle_use_dec (AST::SimplePath &path)
 {
   auto locus = path.get_final_segment ().get_locus ();
   auto declared_name = path.get_final_segment ().as_string ();
@@ -508,6 +509,97 @@ TopLevel::handle_use_dec (AST::SimplePath path)
});
   };
 
+  resolve_and_insert (Namespace::Values, path);
+  resolve_and_insert (Namespace::Types, path);
+  resolve_and_insert (Namespace::Macros, path);
+
+  return found;
+}
+
+bool
+TopLevel::handle_rebind (std::pair 
&rebind)
+{
+  auto &path = rebind.first;
+
+  location_t locus = UNKNOWN_LOCATION;
+  std::string declared_name;
+
+  switch (rebind.second.get_new_bind_type ())
+{
+case AST::UseTreeRebind::NewBindType::IDENTIFIER:
+  declared_name = rebind.second.get_identifier ().as_string ();
+  locus = rebind.second.get_identifier ().get_locus ();
+  break;
+case AST::UseTreeRebind::NewBindType::NONE:
+  declared_name = path.get_final_segment ().as_string ();
+  locus = path.get_final_segment ().get_locus ();
+  break;
+case AST::UseTreeRebind::NewBindType::WILDCARD:
+  rust_unreachable ();
+  break;
+}
+
+  // in what namespace do we perform path resolution? All
+  // of them? see which one matches? Error out on
+  // ambiguities? so, apparently, for each one that
+  // matches, add it to the proper namespace
+  // :(
+  auto found = false;
+
+  auto resolve_and_insert = [this, &found, &declared_name,
+locus] (Namespace ns,
+const AST::SimplePath &path) {
+tl::optional resolved = tl::nullopt;
+tl::optional resolved_bind = tl::nullopt;
+
+std::vector declaration_v
+  = {AST::SimplePathSegment (declared_name, locus)};
+// FIXME: resolve_path needs to return an `expected` so
+// that we can improve it with hints or location or w/ever. and maybe
+// only emit it the first time.
+switch (ns)
+  {
+  case Namespace::Values:
+   resolved = ctx.values.resolve_path (path.get_segments ());
+   resolved_bind = ctx.values.resolve_path (declaration_v);
+   break;
+  case Namespace::Types:
+   resolved = ctx.types.resolve_path (path.get_segments ());
+   resolved_bind = ctx.types.resolve_path (declaration_v);
+   break;
+  case Namespace::Macros:
+   resolved = ctx.macros.resolve_path (path.get_segments ());
+   resolved_bind = ctx.macros.resolve_path (declaration_v);
+   break;
+  case Namespace::Labels:
+   // TODO: Is that okay?
+   rust_unreachable ();
+  }
+
+resolved.map ([this, &found, &declared_name, locus, ns, path,
+  &resolved_bind] (Rib::Definition def) {
+  found = true;
+
+  insert_or_error_out (declared_name, locus, def.get_node_id (), ns);
+  if (resolved_bind.has_value ())
+   {
+ auto bind_def = resolved_bind

[gcc/devel/rust/master] Remove 'libgrust/librustc_format_parser' from 'gcc/rust/Make-lang.in:RUST_LDFLAGS'

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:9dda7062e0bddcfe08e08f6a4efd8dd544f89463

commit 9dda7062e0bddcfe08e08f6a4efd8dd544f89463
Author: Thomas Schwinge 
Date:   Wed Feb 28 22:39:52 2024 +0100

Remove 'libgrust/librustc_format_parser' from 
'gcc/rust/Make-lang.in:RUST_LDFLAGS'

That directory doesn't even exist.

gcc/rust/
* Make-lang.in (RUST_LDFLAGS): Remove
'libgrust/librustc_format_parser'.

Diff:
---
 gcc/rust/Make-lang.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index bec02f79731a..a68ae1e93f68 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -225,7 +225,7 @@ RUST_ALL_OBJS = $(GRS_OBJS) $(RUST_TARGET_OBJS)
 
 rust_OBJS = $(RUST_ALL_OBJS) rust/rustspec.o
 
-RUST_LDFLAGS = $(LDFLAGS) -L./../libgrust/libproc_macro_internal 
-L./../libgrust/librustc_format_parser/
+RUST_LDFLAGS = $(LDFLAGS) -L./../libgrust/libproc_macro_internal
 RUST_LIBDEPS = $(LIBDEPS) 
../libgrust/libproc_macro_internal/libproc_macro_internal.a 
rust/libformat_parser.a
 
 # The compiler itself is called crab1


[gcc/devel/rust/master] Add mappings for struct base and struct fields

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:15a37afd98abaa865c7945357b2ca07da4d063d2

commit 15a37afd98abaa865c7945357b2ca07da4d063d2
Author: Pierre-Emmanuel Patry 
Date:   Thu Mar 21 19:16:02 2024 +0100

Add mappings for struct base and struct fields

Definition/usage mapping during name resolution was missing.

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add mapping
implementation.
* resolve/rust-late-name-resolver-2.0.h: Add function visitor 
prototype
override.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 21 +
 gcc/rust/resolve/rust-late-name-resolver-2.0.h  |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
index dc7cde1b3233..f580c23377b0 100644
--- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
@@ -228,5 +228,26 @@ Late::visit (AST::TypePath &type)
 Definition (resolved->get_node_id ()));
 }
 
+void
+Late::visit (AST::StructExprStructBase &s)
+{
+  auto resolved = ctx.types.get (s.get_struct_name ().as_string ());
+
+  ctx.map_usage (Usage (s.get_struct_name ().get_node_id ()),
+Definition (resolved->get_node_id ()));
+  DefaultResolver::visit (s);
+}
+
+void
+Late::visit (AST::StructExprStructFields &s)
+{
+  auto resolved = ctx.types.get (s.get_struct_name ().as_string ());
+
+  ctx.map_usage (Usage (s.get_struct_name ().get_node_id ()),
+Definition (resolved->get_node_id ()));
+
+  DefaultResolver::visit (s);
+}
+
 } // namespace Resolver2_0
 } // namespace Rust
diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.h 
b/gcc/rust/resolve/rust-late-name-resolver-2.0.h
index 3a8a0060f5a2..ee712b305d4f 100644
--- a/gcc/rust/resolve/rust-late-name-resolver-2.0.h
+++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.h
@@ -46,6 +46,8 @@ public:
   void visit (AST::IdentifierExpr &) override;
   void visit (AST::PathInExpression &) override;
   void visit (AST::TypePath &) override;
+  void visit (AST::StructExprStructBase &) override;
+  void visit (AST::StructExprStructFields &) override;
 
 private:
   /* Setup Rust's builtin types (u8, i32, !...) in the resolver */


[gcc/devel/rust/master] rust: Add --offline flag to cargo when building Rust components.

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:2dff71f6fcbd84570e282b6c884ae246715c621e

commit 2dff71f6fcbd84570e282b6c884ae246715c621e
Author: Arthur Cohen 
Date:   Tue Apr 9 13:43:01 2024 +0200

rust: Add --offline flag to cargo when building Rust components.

gcc/rust/ChangeLog:

* Make-lang.in: Add --offline flag to cargo invocation.

Diff:
---
 gcc/rust/Make-lang.in | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index 1efab4987db5..bec02f79731a 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -421,8 +421,9 @@ rust/%.o: rust/lex/%.cc
 %.toml:
echo $@
 
+# TODO: Improve `cargo` invocation with host specific flags, possibly creating 
a $(CARGO) variable?
 rust/libformat_parser.a: $(srcdir)/../libgrust/libformat_parser/Cargo.toml 
$(wildcard $(srcdir)/../libgrust/libformat_parser/src/*.rs)
-   cargo build --manifest-path 
$(srcdir)/../libgrust/libformat_parser/Cargo.toml # FIXME: Not always release, 
right?
+   cd $(srcdir)/../libgrust/libformat_parser && cargo build --offline  # 
FIXME: Not always release, right?
cp 
$(srcdir)/../libgrust/libformat_parser/target/debug/liblibformat_parser.a $@
 
 # build all rust/parse files in rust folder, add cross-folder includes


[gcc/devel/rust/master] Fix quoted string format

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:7697c1e9f55ffd6dbcad818ba8c0d7e756080608

commit 7697c1e9f55ffd6dbcad818ba8c0d7e756080608
Author: Pierre-Emmanuel Patry 
Date:   Wed Mar 13 17:18:58 2024 +0100

Fix quoted string format

This format dialog triggered a warning.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc 
(TopLevel::handle_use_dec):
Replace the string format %<%s%> with the proper %qs format.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index 80b142678b95..e6da8db850c3 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -499,7 +499,7 @@ TopLevel::handle_use_dec (AST::SimplePath path)
  auto result = node_forwarding.find (def.get_node_id ());
  if (result != node_forwarding.cend ()
  && result->second != path.get_node_id ())
-   rust_error_at (path.get_locus (), "%<%s%> defined multiple times",
+   rust_error_at (path.get_locus (), "%qs defined multiple times",
   declared_name.c_str ());
  else // No previous thing has inserted this into our scope
node_forwarding.insert ({def.get_node_id (), path.get_node_id ()});


[gcc/devel/rust/master] Prevent getting immutable context with classic nr

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:a63f0ac77e448551b7320dac3acfb0a6331d6fe9

commit a63f0ac77e448551b7320dac3acfb0a6331d6fe9
Author: Pierre-Emmanuel Patry 
Date:   Wed Mar 13 16:44:00 2024 +0100

Prevent getting immutable context with classic nr

Immutable name resolution context is not initialized when the classic
name resolution is in use. It can therefore not be used, the getter would
error out.

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-path.cc 
(TypeCheckExpr::resolve_root_path):
Only get immutable name resolution context when name resolution 2.0 
is
used.
* typecheck/rust-hir-type-check-type.cc 
(TypeCheckType::resolve_root_path):
Likewise.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/rust/typecheck/rust-hir-type-check-path.cc | 14 --
 gcc/rust/typecheck/rust-hir-type-check-type.cc | 17 +
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-path.cc 
b/gcc/rust/typecheck/rust-hir-type-check-path.cc
index b0e52c454e9d..dd6ab03a3627 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-path.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-path.cc
@@ -199,16 +199,18 @@ TypeCheckExpr::resolve_root_path (HIR::PathInExpression 
&expr, size_t *offset,
   bool is_root = *offset == 0;
   NodeId ast_node_id = seg.get_mappings ().get_nodeid ();
 
-  auto nr_ctx
-   = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-
   // then lookup the reference_node_id
   NodeId ref_node_id = UNKNOWN_NODEID;
 
   if (flag_name_resolution_2_0)
-   // assign the ref_node_id if we've found something
-   nr_ctx.lookup (expr.get_mappings ().get_nodeid ())
- .map ([&ref_node_id] (NodeId resolved) { ref_node_id = resolved; });
+   {
+ auto nr_ctx
+   = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
+ // assign the ref_node_id if we've found something
+ nr_ctx.lookup (expr.get_mappings ().get_nodeid ())
+   .map ([&ref_node_id] (NodeId resolved) { ref_node_id = resolved; });
+   }
   else if (!resolver->lookup_resolved_name (ast_node_id, &ref_node_id))
resolver->lookup_resolved_type (ast_node_id, &ref_node_id);
 
diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc 
b/gcc/rust/typecheck/rust-hir-type-check-type.cc
index 588e5bce88e1..44ebc159b23a 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-type.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc
@@ -341,19 +341,20 @@ TypeCheckType::resolve_root_path (HIR::TypePath &path, 
size_t *offset,
   bool is_root = *offset == 0;
   NodeId ast_node_id = seg->get_mappings ().get_nodeid ();
 
-  auto nr_ctx
-   = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-
   // then lookup the reference_node_id
   NodeId ref_node_id = UNKNOWN_NODEID;
 
   // FIXME: HACK: ARTHUR: Remove this
   if (flag_name_resolution_2_0)
-   // assign the ref_node_id if we've found something
-   nr_ctx.lookup (path.get_mappings ().get_nodeid ())
- .map ([&ref_node_id, &path] (NodeId resolved) {
-   ref_node_id = resolved;
- });
+   {
+ auto nr_ctx
+   = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+ // assign the ref_node_id if we've found something
+ nr_ctx.lookup (path.get_mappings ().get_nodeid ())
+   .map ([&ref_node_id, &path] (NodeId resolved) {
+ ref_node_id = resolved;
+   });
+   }
   else if (!resolver->lookup_resolved_name (ast_node_id, &ref_node_id))
resolver->lookup_resolved_type (ast_node_id, &ref_node_id);


[gcc/devel/rust/master] Merge commit '767698ff6c8f07047ad90bef89f3dc4c4515f0df' into HEAD

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:30a67f581fef03ef28a8d93ed7608c35021e21d1

commit 30a67f581fef03ef28a8d93ed7608c35021e21d1
Merge: 17d389c4a3f9 767698ff6c8f
Author: Thomas Schwinge 
Date:   Wed Apr 10 11:05:52 2024 +0200

Merge commit '767698ff6c8f07047ad90bef89f3dc4c4515f0df' into HEAD

Diff:


[gcc/devel/rust/master] Adjust '.github/bors_log_expected_warnings'

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:013b520529d5f1bddec27dd921eab5e917663693

commit 013b520529d5f1bddec27dd921eab5e917663693
Author: Thomas Schwinge 
Date:   Wed Apr 10 14:34:26 2024 +0200

Adjust '.github/bors_log_expected_warnings'

Diff:
---
 .github/bors_log_expected_warnings | 141 ++---
 1 file changed, 100 insertions(+), 41 deletions(-)

diff --git a/.github/bors_log_expected_warnings 
b/.github/bors_log_expected_warnings
index 173310bb2257..989829d685f4 100644
--- a/.github/bors_log_expected_warnings
+++ b/.github/bors_log_expected_warnings
@@ -1,4 +1,68 @@
 ../../../../libgcc/generic-morestack.c:397:16: warning: comparison of integer 
expressions of different signedness: ‘unsigned int’ and ‘long int’ 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixdfbitint.c:51:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixdfbitint.c:51:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixdfbitint.c:57:22: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixdfbitint.c:57:22: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixdfbitint.c:61:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixdfbitint.c:61:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixsfbitint.c:51:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixsfbitint.c:51:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixsfbitint.c:57:22: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixsfbitint.c:57:22: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixsfbitint.c:61:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixsfbitint.c:61:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixtfbitint.c:61:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixtfbitint.c:61:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixtfbitint.c:67:22: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixtfbitint.c:67:22: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixtfbitint.c:71:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixtfbitint.c:71:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixxfbitint.c:62:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixxfbitint.c:62:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixxfbitint.c:68:22: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixxfbitint.c:68:22: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixxfbitint.c:72:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
+../../../../libgcc/soft-fp/fixxfbitint.c:72:20: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-c

[gcc/devel/rust/master] Struct are types, not values

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:01f3f7b846504858c43a5d94b9d60109369648e1

commit 01f3f7b846504858c43a5d94b9d60109369648e1
Author: Pierre-Emmanuel Patry 
Date:   Wed Jan 24 17:10:42 2024 +0100

Struct are types, not values

We shall search in the right namespace. The correct namespace for struct
is type namespace.

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): 
Change
search location for struct types.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/rust/typecheck/rust-hir-type-check-item.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.cc 
b/gcc/rust/typecheck/rust-hir-type-check-item.cc
index 4ab946e1c2a1..3e504e5df322 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-item.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-item.cc
@@ -279,9 +279,11 @@ TypeCheckItem::visit (HIR::StructStruct &struct_decl)
 {
   auto nr_ctx
= Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
-  auto canonical_path = nr_ctx.values.to_canonical_path (
+  auto canonical_path = nr_ctx.types.to_canonical_path (
struct_decl.get_mappings ().get_nodeid ());
 
+  if (!canonical_path.has_value ())
+   rust_unreachable ();
   path = canonical_path.value ();
 }
   else


[gcc/devel/rust/master] Merge commit '8534cc772def8142379c0e72ab6392d40f3f60f6^' into HEAD

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:17d389c4a3f9fd540cb9cce670b9165ea59ff2ab

commit 17d389c4a3f9fd540cb9cce670b9165ea59ff2ab
Merge: 31fed215c247 d0f8cb17bbd3
Author: Thomas Schwinge 
Date:   Wed Apr 10 11:05:29 2024 +0200

Merge commit '8534cc772def8142379c0e72ab6392d40f3f60f6^' into HEAD

Diff:

 gcc/ChangeLog  |   265 +
 gcc/DATESTAMP  | 2 +-
 gcc/analyzer/ChangeLog |29 +
 gcc/analyzer/analyzer.h| 3 +
 gcc/analyzer/ranges.cc |18 +
 gcc/analyzer/region-model-manager.cc   |38 +-
 gcc/analyzer/region-model.cc   |17 +-
 gcc/analyzer/region.cc |48 -
 gcc/analyzer/region.h  |20 +-
 gcc/analyzer/varargs.cc|38 +-
 gcc/cfgexpand.cc   | 2 +-
 gcc/cfgrtl.cc  |51 +-
 gcc/cfgrtl.h   | 1 +
 gcc/common/config/riscv/riscv-common.cc|46 +
 gcc/config/aarch64/aarch64-arches.def  | 2 +-
 gcc/config/aarch64/aarch64-builtins.cc | 3 +-
 gcc/config/aarch64/aarch64-passes.def  | 1 +
 gcc/config/aarch64/aarch64-protos.h| 1 +
 gcc/config/aarch64/aarch64-sme.md  |48 +-
 gcc/config/aarch64/aarch64-speculation.cc  |64 +-
 gcc/config/aarch64/aarch64.cc  |64 +-
 gcc/config/aarch64/aarch64.md  | 8 +-
 gcc/config/arm/arm.cc  |11 +-
 gcc/config/avr/avr-c.cc| 1 +
 gcc/config/avr/avr-protos.h| 1 +
 gcc/config/avr/avr.cc  |70 +-
 gcc/config/avr/avr.h   | 1 +
 gcc/config/avr/avr.md  |47 +-
 gcc/config/avr/builtins.def|16 +-
 gcc/config/bpf/bpf.md  | 2 +-
 gcc/config/bpf/bpf.opt | 2 +
 gcc/config/gcn/gcn-valu.md | 5 +-
 gcc/config/gcn/gcn.cc  |23 +-
 gcc/config/gcn/gcn.h   | 6 +
 gcc/config/i386/i386.cc|24 +-
 gcc/config/loongarch/larchintrin.h |71 +-
 gcc/config/nvptx/gen-omp-device-properties.sh  | 2 +-
 gcc/config/nvptx/nvptx.cc  | 3 +-
 gcc/config/riscv/riscv-c.cc| 2 +-
 gcc/config/riscv/riscv-protos.h| 7 +
 gcc/config/riscv/riscv-vsetvl.cc   |25 +
 gcc/config/riscv/riscv.h   | 7 +-
 gcc/config/riscv/riscv.md  | 2 +-
 gcc/config/riscv/riscv.opt |12 +
 gcc/cp/ChangeLog   |39 +
 gcc/cp/constraint.cc   | 5 +-
 gcc/cp/module.cc   | 4 +
 gcc/cp/parser.cc   | 9 +-
 gcc/cp/search.cc   |22 +-
 gcc/cp/typeck.cc   |24 +-
 gcc/d/ChangeLog|38 +
 gcc/d/Make-lang.in | 1 +
 gcc/d/d-attribs.cc | 6 +-
 gcc/d/d-builtins.cc|39 +-
 gcc/d/d-codegen.cc |16 +-
 gcc/d/d-convert.cc | 6 +-
 gcc/d/d-lang.cc|26 +-
 gcc/d/d-target.cc  |12 +-
 gcc/d/decl.cc  |39 +-
 gcc/d/dmd/MERGE| 2 +-
 gcc/d/dmd/VERSION  | 2 +-
 gcc/d/dmd/aggregate.h  | 7 +-
 gcc/d/dmd/cparse.d |17 +
 gcc/d/dmd/cppmangle.d  | 6 +-
 gcc/d/dmd/cxxfrontend.d|   623 +
 gcc/d/dmd/declaration.h| 7 +-
 gcc/d/dmd/dinterpret.d | 4 +-
 gcc/d/dmd/dmangle.d|10 +-
 gcc/d/dmd/dmodule.d| 4 +-
 gcc/d/dmd/doc.d| 2 +-
 gcc/d/dmd/doc.h| 7 +-
 gcc/d/dmd/dscope.d | 1 +
 gcc/d/dmd/dstruct.d| 2 +-
 gcc/d/dmd/dsymbol.d|   273 +-
 gcc/d/dmd/dsymbol.h|35 +-
 gcc/d/dm

[gcc/devel/rust/master] Merge commit 'f0b1cf01782ba975cfda32800c91076df78058d6' into HEAD [#2857]

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:31fed215c24705ff8a471d9d3662b3afd1faa932

commit 31fed215c24705ff8a471d9d3662b3afd1faa932
Merge: 9575360bad47 f0b1cf01782b
Author: Thomas Schwinge 
Date:   Wed Apr 10 11:02:28 2024 +0200

Merge commit 'f0b1cf01782ba975cfda32800c91076df78058d6' into HEAD [#2857]

Diff:


[gcc/devel/rust/master] Change enum namespace from value to type

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:08a6f1a1183572b35e5151f2b73b1aec41d42db2

commit 08a6f1a1183572b35e5151f2b73b1aec41d42db2
Author: Pierre-Emmanuel Patry 
Date:   Wed Jan 24 17:08:05 2024 +0100

Change enum namespace from value to type

The enum type shall be in type namespace, not value namespace.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc 
(GlobbingVisitor::visit):
Change enum type namespace.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index 820ba271ae0c..b672d448151a 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -95,7 +95,7 @@ GlobbingVisitor::visit (AST::Enum &enum_item)
 {
   if (enum_item.get_visibility ().is_public ())
 ctx.insert_shadowable (enum_item.get_identifier (),
-  enum_item.get_node_id (), Namespace::Values);
+  enum_item.get_node_id (), Namespace::Types);
 }
 
 void


[gcc/devel/rust/master] Unit struct constructor shall be resolved

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:e19483da430ccd1da3a08dd1cebb87b425898720

commit e19483da430ccd1da3a08dd1cebb87b425898720
Author: Pierre-Emmanuel Patry 
Date:   Wed Jan 24 17:04:51 2024 +0100

Unit struct constructor shall be resolved

Unit struct have a special constructor that should be added to the struct
namespace in order to be resolved later when called. As it is a function
it should be added in the value namespace.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc 
(GlobbingVisitor::visit):
Add the struct constructor when the struct is a unit.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index 4134b9a46202..75d9bb82131f 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -68,8 +68,13 @@ void
 GlobbingVisitor::visit (AST::StructStruct &struct_item)
 {
   if (struct_item.get_visibility ().is_public ())
-ctx.insert_shadowable (struct_item.get_identifier (),
-  struct_item.get_node_id (), Namespace::Values);
+{
+  ctx.insert_shadowable (struct_item.get_identifier (),
+struct_item.get_node_id (), Namespace::Types);
+  if (struct_item.is_unit_struct ())
+   ctx.insert_shadowable (struct_item.get_identifier (),
+  struct_item.get_node_id (), Namespace::Values);
+}
 }
 
 void


[gcc/devel/rust/master] Merge commit 'af3f0482367232d2d655e51bee382e98ddbfb117' into HEAD

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:1cae91f78a006bcd494e4846142fc170099af71e

commit 1cae91f78a006bcd494e4846142fc170099af71e
Merge: 1af2c40d7595 af3f04823672
Author: Thomas Schwinge 
Date:   Wed Apr 10 10:56:34 2024 +0200

Merge commit 'af3f0482367232d2d655e51bee382e98ddbfb117' into HEAD

Diff:


[gcc/devel/rust/master] Visit function return type in default resolver

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:e84d67febe5805675d3f86e0e535702dfe67b78d

commit e84d67febe5805675d3f86e0e535702dfe67b78d
Author: Pierre-Emmanuel Patry 
Date:   Wed Jan 24 16:47:50 2024 +0100

Visit function return type in default resolver

Function return type was not properly visited in the default resolver
visitor pattern.

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc (DefaultResolver::visit): Visit
function return type.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/rust/resolve/rust-default-resolver.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/rust/resolve/rust-default-resolver.cc 
b/gcc/rust/resolve/rust-default-resolver.cc
index e2609d13c9a6..d805bc9a511d 100644
--- a/gcc/rust/resolve/rust-default-resolver.cc
+++ b/gcc/rust/resolve/rust-default-resolver.cc
@@ -79,6 +79,9 @@ DefaultResolver::visit (AST::Function &function)
  }
   }
 
+if (function.has_return_type ())
+  visit (function.get_return_type ());
+
 if (function.has_body ())
   function.get_definition ().value ()->accept_vis (*this);
   };


[gcc/devel/rust/master] Merge commit 'f89186f962421f6d972035fc4b4c20490e7b1c5b^' into HEAD

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:1af2c40d7595c91f8c8f3573c1bec30556e35bb6

commit 1af2c40d7595c91f8c8f3573c1bec30556e35bb6
Merge: 17ee9c68cbc9 830d4659604e
Author: Thomas Schwinge 
Date:   Wed Apr 10 10:55:56 2024 +0200

Merge commit 'f89186f962421f6d972035fc4b4c20490e7b1c5b^' into HEAD

Diff:

 ChangeLog  |8 +
 MAINTAINERS|6 +-
 contrib/ChangeLog  |   10 +
 contrib/test_installed |4 +
 contrib/unicode/gen_libstdcxx_unicode_data.py  |   30 +-
 gcc/ChangeLog  |  762 ++
 gcc/DATESTAMP  |2 +-
 gcc/analyzer/ChangeLog |   36 +
 gcc/analyzer/checker-event.cc  |   59 +-
 gcc/analyzer/region-model.cc   |  111 +-
 gcc/analyzer/state-purge.cc|9 +
 gcc/analyzer/supergraph.cc |4 +
 gcc/asan.h |7 +-
 gcc/builtins.cc|8 +-
 gcc/c-family/ChangeLog |   12 +
 gcc/c-family/c-opts.cc |5 +
 gcc/c-family/c-pch.cc  |   23 +-
 gcc/c/ChangeLog|   32 +
 gcc/c/c-convert.cc |3 +-
 gcc/c/c-decl.cc|9 +-
 gcc/c/c-tree.h |3 +-
 gcc/c/c-typeck.cc  |   36 +-
 gcc/common/config/riscv/riscv-common.cc|   14 +
 gcc/config/aarch64/aarch64-simd.md |   11 +-
 gcc/config/aarch64/aarch64.cc  |  129 +-
 gcc/config/arm/arm.cc  |2 +
 gcc/config/avr/avr-mcus.def|8 +-
 gcc/config/avr/avr.cc  | 7434 +++
 gcc/config/gcn/gcn.cc  |6 +-
 gcc/config/gcn/gcn.h   |   16 +-
 gcc/config/gcn/gcn.md  |   17 +-
 gcc/config/i386/constraints.md |4 +
 gcc/config/i386/i386-expand.cc |2 +-
 gcc/config/i386/i386-features.cc   |   26 +
 gcc/config/i386/i386.cc|   91 +-
 gcc/config/i386/i386.md|4 -
 gcc/config/loongarch/larchintrin.h |   16 +-
 gcc/config/loongarch/lasx.md   |   16 -
 gcc/config/loongarch/loongarch-def.h   |3 +
 gcc/config/loongarch/loongarch-opts.cc |2 -
 gcc/config/loongarch/loongarch-protos.h|1 +
 gcc/config/loongarch/loongarch.cc  |  577 +-
 gcc/config/loongarch/loongarch.md  |  125 +-
 gcc/config/loongarch/lsx.md|   11 -
 gcc/config/loongarch/predicates.md |   12 +
 gcc/config/loongarch/simd.md   |   18 +
 gcc/config/mips/mips-msa.md|   18 +-
 gcc/config/pa/pa.cc|  215 +-
 gcc/config/pa/pa.md|   90 +-
 gcc/config/riscv/generic-ooo.md|2 +-
 gcc/config/riscv/generic.md|2 +-
 gcc/config/riscv/riscv-c.cc|3 +-
 gcc/config/riscv/riscv-cores.def   |   11 +
 gcc/config/riscv/riscv-opts.h  |2 +
 gcc/config/riscv/riscv-protos.h|2 +-
 gcc/config/riscv/riscv-v.cc|   12 +-
 gcc/config/riscv/riscv-vector-builtins.cc  |   23 +-
 gcc/config/riscv/riscv-vsetvl.cc   |  255 +-
 gcc/config/riscv/riscv.cc  |  151 +-
 gcc/config/riscv/riscv.h   |5 +-
 gcc/config/riscv/riscv.md  |   20 +-
 gcc/config/riscv/riscv.opt |   14 +
 gcc/config/riscv/sifive-7.md   |2 +-
 gcc/config/riscv/sifive-p400.md|  174 +
 gcc/config/riscv/sifive-p600.md|  178 +
 gcc/config/riscv/thead.cc  |3 +-
 gcc/config/sol2.h  |2 +-
 gcc/config/sparc/sparc.h   |7 +
 gcc/config/xtensa/constraints.md   |   26 +-
 gcc/config/xtensa/predicates.md|7 +-
 gcc/config/xtensa/xtensa.cc|   46 +-
 gcc/config/xtensa/xtensa.md|   41 +-
 gcc/config/xtensa/xtensa.opt   |4 +-
 gcc/cp/ChangeLog   |  111 +
 gcc/cp/call.cc |   18 +-
 gcc/cp/constexpr.cc|1 +
 gcc/cp/constr

[gcc/devel/rust/master] Change error message to match test

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:124d56a328163a8de49e01e9d88aaf6f6c5aa3e9

commit 124d56a328163a8de49e01e9d88aaf6f6c5aa3e9
Author: Pierre-Emmanuel Patry 
Date:   Wed Jan 17 13:53:21 2024 +0100

Change error message to match test

Error message did not match the test from the previous name resolver when
a given path cannot be resolved.

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-path.cc 
(TypeCheckExpr::resolve_root_path):
Change error message to match old resolver and test case.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/rust/typecheck/rust-hir-type-check-path.cc | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-path.cc 
b/gcc/rust/typecheck/rust-hir-type-check-path.cc
index cdb506dacbe5..b0e52c454e9d 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-path.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-path.cc
@@ -266,8 +266,10 @@ TypeCheckExpr::resolve_root_path (HIR::PathInExpression 
&expr, size_t *offset,
{
  if (is_root)
{
- rust_error_at (seg.get_locus (),
-"failed to resolve root segment");
+ rust_error_at (expr.get_locus (), ErrorCode::E0425,
+"cannot find value %qs in this scope",
+expr.as_simple_path ().as_string ().c_str ());
+
  return new TyTy::ErrorType (expr.get_mappings ().get_hirid ());
}
  return root_tyty;


[gcc/devel/rust/master] Add support for ambiguous use declarations

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:6b1d14b72e1b38ce55389683436781b229ed51f8

commit 6b1d14b72e1b38ce55389683436781b229ed51f8
Author: Pierre-Emmanuel Patry 
Date:   Tue Jan 16 13:55:02 2024 +0100

Add support for ambiguous use declarations

Glob use declarations may lead to ambiguous situation where two
definitions with the same name are imported in a given scope. The
compiler now handles shadowable items inserted after non shadowable
items. An error is now thrown when multiple shadowable items are imported
and used in the same rib.

gcc/rust/ChangeLog:

* resolve/rust-early-name-resolver-2.0.cc (Early::visit): Adapt
resolved type to the new API.
(Early::visit_attributes): Retrieve the node id from the definition.
* resolve/rust-forever-stack.h: Change the return type of getter
functions. Those functions now return a definition type instead of a
node id.
* resolve/rust-forever-stack.hxx: Change member function 
implementation
in the forever stack to accomodate it's API changes.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Use internal
node id. Emit an error when resolving multiple ambiguous values.
* resolve/rust-rib.cc (Rib::Definition::Definition): Add a default
constructor.
(Rib::Definition::is_ambiguous): Add a new function to determine
whether a function definition is ambiguous or not.
(Rib::Definition::to_string): Add a member function to convert a 
given
definition to a string.
(Rib::insert): Add new rules for value insertion in a rib. Insertion
order does not impact the result anymore: inserting a shadowable 
value
after a non shadowable one does not trigger an error anymore. All
shadowable values inserted in a rib are kepts until being replaced 
by a
non shadowable one.
(Rib::get): Return a definition instead of a node id.
* resolve/rust-rib.h: Update function prototypes.
* resolve/rust-toplevel-name-resolver-2.0.cc 
(TopLevel::handle_use_glob):
Update return value container to match the new function's prototype.
(TopLevel::handle_use_dec): Likewise.
(flatten_glob): Likewise.

Signed-off-by: Pierre-Emmanuel Patry 

Diff:
---
 gcc/rust/resolve/rust-early-name-resolver-2.0.cc   | 18 +++---
 gcc/rust/resolve/rust-forever-stack.h  | 10 ++--
 gcc/rust/resolve/rust-forever-stack.hxx| 39 ++--
 gcc/rust/resolve/rust-late-name-resolver-2.0.cc| 17 --
 gcc/rust/resolve/rust-rib.cc   | 69 +-
 gcc/rust/resolve/rust-rib.h| 19 +-
 .../resolve/rust-toplevel-name-resolver-2.0.cc | 41 +++--
 7 files changed, 142 insertions(+), 71 deletions(-)

diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
index 982c696d2af1..af148b0c1c0d 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
@@ -152,9 +152,11 @@ Early::visit (AST::MacroInvocation &invoc)
 
   // 
https://doc.rust-lang.org/reference/macros-by-example.html#path-based-scope
 
-  tl::optional definition = tl::nullopt;
+  tl::optional definition = tl::nullopt;
   if (path.get_segments ().size () == 1)
-definition = textual_scope.get (path.get_final_segment ().as_string ());
+definition
+  = textual_scope.get (path.get_final_segment ().as_string ())
+ .map ([] (NodeId id) { return Rib::Definition::NonShadowable (id); });
 
   // we won't have changed `definition` from `nullopt` if there are more
   // than one segments in our path
@@ -169,13 +171,13 @@ Early::visit (AST::MacroInvocation &invoc)
   return;
 }
 
-  insert_once (invoc, *definition);
+  insert_once (invoc, definition->get_node_id ());
 
   // now do we need to keep mappings or something? or insert "uses" into our
   // ForeverStack? can we do that? are mappings simpler?
   auto mappings = Analysis::Mappings::get ();
   AST::MacroRulesDefinition *rules_def = nullptr;
-  if (!mappings->lookup_macro_def (definition.value (), &rules_def))
+  if (!mappings->lookup_macro_def (definition->get_node_id (), &rules_def))
 {
   // Macro definition not found, maybe it is not expanded yet.
   return;
@@ -212,8 +214,8 @@ Early::visit_attributes (std::vector &attrs)
  continue;
}
 
- auto pm_def
-   = mappings->lookup_derive_proc_macro_def (definition.value ());
+ auto pm_def = mappings->lookup_derive_proc_macro_def (
+   definition->get_node_id ());
 
  rust_assert (pm_def.has_value ());
 
@@ -234,8 +236,8 @@ Early::visit_attributes (std::vector &attrs)
 "cou

[gcc/devel/rust/master] Merge commit '2341df1cb9b3681bfefe29207887b2b3dc271a95' into HEAD [#2801]

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:0de2032ecf451e9fed2ad16c3ce771663fbc37a5

commit 0de2032ecf451e9fed2ad16c3ce771663fbc37a5
Merge: d1a0609b7e62 2341df1cb9b3
Author: Thomas Schwinge 
Date:   Wed Apr 10 10:52:58 2024 +0200

Merge commit '2341df1cb9b3681bfefe29207887b2b3dc271a95' into HEAD [#2801]

Diff:


[gcc/devel/rust/master] Merge commit '4bd09ce06f50d266c992c984cc993384d5e6655e' into HEAD

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:ca224bde2989de54fc33fae46df560b7f5af835e

commit ca224bde2989de54fc33fae46df560b7f5af835e
Merge: 4966574bdc77 4bd09ce06f50
Author: Thomas Schwinge 
Date:   Wed Apr 10 10:45:29 2024 +0200

Merge commit '4bd09ce06f50d266c992c984cc993384d5e6655e' into HEAD

Diff:


[gcc/devel/rust/master] borrowck: Remove block braces to satisfy GNU style

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:c90a9ada247d96025562be15780dba3f3d1f9ec0

commit c90a9ada247d96025562be15780dba3f3d1f9ec0
Author: Jakub Dupak 
Date:   Mon Apr 1 14:06:33 2024 +0200

borrowck: Remove block braces to satisfy GNU style

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-dump.cc (renumber_places):
Remove unecessary braces.
(Dump::go): Remove unecessary braces.
(Dump::visit): Remove unecessary braces.
(Dump::visit_scope): Remove unecessary braces.
* checks/errors/borrowck/rust-bir-fact-collector.h (class 
FactCollector):
Remove unecessary braces.
(points): Remove unecessary braces.
* checks/errors/borrowck/rust-bir-free-region.h: Remove unecessary 
braces.
* checks/errors/borrowck/rust-bir-place.h: Remove unecessary braces.
* checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go):
Remove unecessary braces.
* checks/errors/borrowck/rust-function-collector.h: Remove 
unecessary braces.

Signed-off-by: Jakub Dupak 

Diff:
---
 gcc/rust/checks/errors/borrowck/rust-bir-dump.cc   | 47 +---
 .../errors/borrowck/rust-bir-fact-collector.h  | 87 +++---
 .../checks/errors/borrowck/rust-bir-free-region.h  | 16 +---
 gcc/rust/checks/errors/borrowck/rust-bir-place.h   | 17 ++---
 .../checks/errors/borrowck/rust-borrow-checker.cc  |  6 +-
 .../errors/borrowck/rust-function-collector.h  |  4 +-
 6 files changed, 56 insertions(+), 121 deletions(-)

diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc 
b/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
index 51dd14363506..a39f145f8f95 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
@@ -42,13 +42,9 @@ renumber_places (const Function &func, std::vector 
&place_map)
 {
   const Place &place = func.place_db[in_id];
   if (place.kind == Place::VARIABLE || place.kind == Place::TEMPORARY)
-   {
- place_map[in_id] = next_out_id++;
-   }
+   place_map[in_id] = next_out_id++;
   else
-   {
- place_map[in_id] = INVALID_PLACE;
-   }
+   place_map[in_id] = INVALID_PLACE;
 }
 }
 
@@ -138,10 +134,9 @@ Dump::go (bool enable_simplify_cfg)
  stream << ";\n";
}
   if (!bb_terminated)
-   {
- stream << indentation << indentation << "goto -> bb"
-<< bb_fold_map[bb.successors.at (0)] << ";\t\t" << i++ << "\n";
-   }
+   stream << indentation << indentation << "goto -> bb"
+  << bb_fold_map[bb.successors.at (0)] << ";\t\t" << i++ << "\n";
+
   stream << indentation << "}\n";
 }
 
@@ -276,15 +271,13 @@ void
 Dump::visit (const CallExpr &expr)
 {
   stream << "Call(";
-  if (auto fn_type
-  = func.place_db[expr.get_callable ()].tyty->try_as ())
-{
-  stream << fn_type->get_identifier ();
-}
+  auto maybe_fn_type
+= func.place_db[expr.get_callable ()].tyty->try_as ();
+  if (maybe_fn_type)
+stream << maybe_fn_type->get_identifier ();
   else
-{
-  visit_move_place (expr.get_callable ());
-}
+visit_move_place (expr.get_callable ());
+
   stream << ")(";
   print_comma_separated (stream, expr.get_arguments (),
 [this] (PlaceId place_id) {
@@ -321,13 +314,9 @@ void
 Dump::visit (const Assignment &expr)
 {
   if (func.place_db[expr.get_rhs ()].is_rvalue ())
-{
-  visit_move_place (expr.get_rhs ());
-}
+visit_move_place (expr.get_rhs ());
   else
-{
-  visit_place (expr.get_rhs ());
-}
+visit_place (expr.get_rhs ());
 }
 
 std::ostream &
@@ -346,9 +335,8 @@ Dump::visit_scope (ScopeId id, size_t depth)
 return;
 
   if (id > 1)
-{
-  indent (depth) << "scope " << id - 1 << " {\n";
-}
+indent (depth) << "scope " << id - 1 << " {\n";
+
   for (auto &local : scope.locals)
 {
   indent (depth + 1) << "let _";
@@ -357,9 +345,8 @@ Dump::visit_scope (ScopeId id, size_t depth)
   stream << ";\n";
 }
   for (auto &child : scope.children)
-{
-  visit_scope (child, (id >= 1) ? depth + 1 : depth);
-}
+visit_scope (child, (id >= 1) ? depth + 1 : depth);
+
   if (id > 1)
 indent (depth) << "}\n";
 }
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h 
b/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
index 17c198e0fa7f..527ae65606cc 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
@@ -67,9 +67,8 @@ class FactCollector : public Visitor
   {
 std::vector free_regions;
 for (size_t i = 0; i < size; i++)
-  {
-   free_regions.push_back (region_binder.get_next_free_region ());
-  }
+  free_regions.push_back (region_binder.get_next_free_region ());
+
 return FreeRegions (std::move (free_regions));
   

[gcc/devel/rust/master] Merge commit 'a5258f3a11ab577835ef5e93be5cb65ec9e44132^' into HEAD

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:d2bcecd7fd914adf55daac7d36745b03b3279c49

commit d2bcecd7fd914adf55daac7d36745b03b3279c49
Merge: ca224bde2989 db4e496aadf1
Author: Thomas Schwinge 
Date:   Wed Apr 10 10:45:56 2024 +0200

Merge commit 'a5258f3a11ab577835ef5e93be5cb65ec9e44132^' into HEAD

Diff:

 gcc/config/aarch64/aarch64.cc   | 11 +++
 gcc/testsuite/gcc.target/aarch64/pr112573.c | 15 +++
 2 files changed, 26 insertions(+)


[gcc/devel/rust/master] borrowck: BIR: make BIR visitor const

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:42ec29cacf4a16586bd30611b116cfff5a549c5e

commit 42ec29cacf4a16586bd30611b116cfff5a549c5e
Author: Jakub Dupak 
Date:   Tue Feb 27 20:22:17 2024 +0100

borrowck: BIR: make BIR visitor const

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-dump.cc (Dump::visit): const
visitor
* checks/errors/borrowck/rust-bir-dump.h: const visitor
* checks/errors/borrowck/rust-bir-visitor.h: const visitor
* checks/errors/borrowck/rust-bir.h: const getter

Signed-off-by: Jakub Dupak 

Diff:
---
 gcc/rust/checks/errors/borrowck/rust-bir-dump.cc   | 14 +++---
 gcc/rust/checks/errors/borrowck/rust-bir-dump.h| 14 +++---
 gcc/rust/checks/errors/borrowck/rust-bir-visitor.h | 14 +++---
 gcc/rust/checks/errors/borrowck/rust-bir.h |  6 +-
 4 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc 
b/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
index 320b653f830a..6f1579df1d9e 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
@@ -155,7 +155,7 @@ Dump::go (bool enable_simplify_cfg)
   stream << "}\n";
 }
 void
-Dump::visit (Statement &stmt)
+Dump::visit (const Statement &stmt)
 {
   statement_place = stmt.get_place ();
   switch (stmt.get_kind ())
@@ -247,7 +247,7 @@ Dump::visit_move_place (PlaceId place_id)
 }
 
 void
-Dump::visit (BorrowExpr &expr)
+Dump::visit (const BorrowExpr &expr)
 {
   stream << "&";
   visit_lifetime (statement_place);
@@ -268,7 +268,7 @@ Dump::visit_lifetime (PlaceId place_id)
 }
 
 void
-Dump::visit (InitializerExpr &expr)
+Dump::visit (const InitializerExpr &expr)
 {
   stream << "{";
   print_comma_separated (stream, expr.get_values (), [this] (PlaceId place_id) 
{
@@ -278,7 +278,7 @@ Dump::visit (InitializerExpr &expr)
 }
 
 void
-Dump::visit (CallExpr &expr)
+Dump::visit (const CallExpr &expr)
 {
   stream << "Call(";
   if (auto fn_type
@@ -305,7 +305,7 @@ Dump::visit (CallExpr &expr)
 }
 
 void
-Dump::visit (Operator<1> &expr)
+Dump::visit (const Operator<1> &expr)
 {
   stream << "Operator(";
   visit_move_place (expr.get_operand<0> ());
@@ -313,7 +313,7 @@ Dump::visit (Operator<1> &expr)
 }
 
 void
-Dump::visit (Operator<2> &expr)
+Dump::visit (const Operator<2> &expr)
 {
   stream << "Operator(";
   visit_move_place (expr.get_operand<0> ());
@@ -323,7 +323,7 @@ Dump::visit (Operator<2> &expr)
 }
 
 void
-Dump::visit (Assignment &expr)
+Dump::visit (const Assignment &expr)
 {
   if (func.place_db[expr.get_rhs ()].is_rvalue ())
 {
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-dump.h 
b/gcc/rust/checks/errors/borrowck/rust-bir-dump.h
index cc3f9cdc7386..9d6babd00535 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-dump.h
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-dump.h
@@ -49,16 +49,16 @@ public:
   void go (bool enable_simplify_cfg = false);
 
 protected:
-  void visit (Statement &stmt) override;
+  void visit (const Statement &stmt) override;
   void visit_place (PlaceId place_id);
   void visit_move_place (PlaceId place_id);
-  void visit (BorrowExpr &expr) override;
+  void visit (const BorrowExpr &expr) override;
   void visit_lifetime (PlaceId place_id);
-  void visit (InitializerExpr &expr) override;
-  void visit (CallExpr &expr) override;
-  void visit (Operator<1> &expr) override;
-  void visit (Operator<2> &expr) override;
-  void visit (Assignment &expr) override;
+  void visit (const InitializerExpr &expr) override;
+  void visit (const CallExpr &expr) override;
+  void visit (const Operator<1> &expr) override;
+  void visit (const Operator<2> &expr) override;
+  void visit (const Assignment &expr) override;
   void visit_scope (ScopeId id, size_t depth = 1);
 
   std::ostream &indent (size_t depth);
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-visitor.h 
b/gcc/rust/checks/errors/borrowck/rust-bir-visitor.h
index 7ad62f700dbc..2371b8bb5cec 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-visitor.h
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-visitor.h
@@ -32,13 +32,13 @@ class CallExpr;
 class Visitor
 {
 public:
-  virtual void visit (Statement &stmt) = 0;
-  virtual void visit (InitializerExpr &expr) = 0;
-  virtual void visit (Operator<1> &expr) = 0;
-  virtual void visit (Operator<2> &expr) = 0;
-  virtual void visit (BorrowExpr &expr) = 0;
-  virtual void visit (Assignment &expr) = 0;
-  virtual void visit (CallExpr &expr) = 0;
+  virtual void visit (const Statement &stmt) = 0;
+  virtual void visit (const InitializerExpr &expr) = 0;
+  virtual void visit (const Operator<1> &expr) = 0;
+  virtual void visit (const Operator<2> &expr) = 0;
+  virtual void visit (const BorrowExpr &expr) = 0;
+  virtual void visit (const Assignment &expr) = 0;
+  virtual void visit (const CallExpr &expr) = 0;
 };
 
 class Visitable
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir.h 
b/gcc/

[gcc/devel/rust/master] Merge commit '7a6906c8d80e437a97c780370a8fec4e00561c7b' into HEAD [#2288]

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:4966574bdc77ab3a0e6ff8bdebb8b85ffb44c851

commit 4966574bdc77ab3a0e6ff8bdebb8b85ffb44c851
Merge: 041fef1b5810 7a6906c8d80e
Author: Thomas Schwinge 
Date:   Wed Apr 10 10:43:34 2024 +0200

Merge commit '7a6906c8d80e437a97c780370a8fec4e00561c7b' into HEAD [#2288]

Diff:


[gcc/devel/rust/master] borrowck: BIR: use callable API

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:ba7e9a78f6c0f875d94db51c9fc64fec64477874

commit ba7e9a78f6c0f875d94db51c9fc64fec64477874
Author: Jakub Dupak 
Date:   Fri Feb 2 14:33:56 2024 +0100

borrowck: BIR: use callable API

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc 
(ExprStmtBuilder::visit):
Use callable API

Signed-off-by: Jakub Dupak 

Diff:
---
 .../errors/borrowck/rust-bir-builder-expr-stmt.cc  | 23 +-
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc 
b/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
index 2c916294ca7a..ea8107b1fb76 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
@@ -248,25 +248,12 @@ ExprStmtBuilder::visit (HIR::CallExpr &expr)
   PlaceId fn = visit_expr (*expr.get_fnexpr ());
   std::vector arguments = visit_list (expr.get_arguments ());
 
-  auto *call_type = ctx.place_db[fn].tyty;
-  if (auto fn_type = call_type->try_as ())
-{
-  for (size_t i = 0; i < fn_type->get_params ().size (); ++i)
-   {
- coercion_site (arguments[i], fn_type->get_params ()[i].second);
-   }
-}
-  else if (auto fn_ptr_type = call_type->try_as ())
-{
-  for (size_t i = 0; i < fn_ptr_type->get_params ().size (); ++i)
-   {
- coercion_site (arguments[i],
-fn_ptr_type->get_params ()[i].get_tyty ());
-   }
-}
-  else
+  const auto fn_type
+= ctx.place_db[fn].tyty->as ();
+
+  for (size_t i = 0; i < fn_type->get_num_params (); ++i)
 {
-  rust_unreachable ();
+  coercion_site (arguments[i], fn_type->get_param_type_at (i));
 }
 
   return_expr (new CallExpr (fn, std::move (arguments)), lookup_type (expr),


[gcc/devel/rust/master] Fix grammar as pointed out by Marc

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:edd018d8c7b7a0229e10430ee61ac50f390670c2

commit edd018d8c7b7a0229e10430ee61ac50f390670c2
Author: Jasmine Tang 
Date:   Fri Apr 5 02:25:48 2024 -0700

Fix grammar as pointed out by Marc

ChangeLog:

* README.md (gccrs-workspace]): like-wise.

Diff:
---
 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 502b61f0ab1e..2ba59d3a6b24 100644
--- a/README.md
+++ b/README.md
@@ -75,11 +75,11 @@ $ make
 
 ```
 
-Alternatively, a docker environment is avaiable for ARM-based Mac contributors.
+Alternatively, a docker environment is available for ARM-based Mac 
contributors.
 
 Please visit 
[gccrs-workspace](https://github.com/badumbatish/gccrs-workspace). 
  
-The image is based on Ubuntu ARM and came with dependencies all fetched.
+The image is based on Ubuntu ARM and comes with dependencies all fetched.
 
  Running GCC Rust


[gcc/devel/rust/master] Merge commit 'fc59a3995cb46c190c0efb0431ad204e399975c4' into HEAD [#2183]

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:041fef1b58109237f972d28f8225f72c0fc1a75a

commit 041fef1b58109237f972d28f8225f72c0fc1a75a
Merge: 0ba53bfa815a fc59a3995cb4
Author: Thomas Schwinge 
Date:   Wed Apr 10 10:34:02 2024 +0200

Merge commit 'fc59a3995cb46c190c0efb0431ad204e399975c4' into HEAD [#2183]

Diff:


[gcc/devel/rust/master] borrowck: Bump copyright notice

2024-05-07 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:ff196e451c6b4eb9736b2331c6a108b85f9d260b

commit ff196e451c6b4eb9736b2331c6a108b85f9d260b
Author: Jakub Dupak 
Date:   Wed Apr 3 10:30:15 2024 +0200

borrowck: Bump copyright notice

gcc/rust/ChangeLog:

* checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs: Bump 
copyright.
* checks/errors/borrowck/ffi-polonius/src/lib.rs: Bump copyright.
* checks/errors/borrowck/polonius/rust-polonius-ffi.h: Bump 
copyright.
* checks/errors/borrowck/polonius/rust-polonius.h: Bump copyright.
* checks/errors/borrowck/rust-bir-dump.cc: Bump copyright.
* checks/errors/borrowck/rust-bir-fact-collector.h: Bump copyright.
* checks/errors/borrowck/rust-bir-free-region.h: Bump copyright.

Signed-off-by: Jakub Dupak 

Diff:
---
 .../errors/borrowck/ffi-polonius/src/gccrs_ffi.rs  |  2 +-
 .../checks/errors/borrowck/ffi-polonius/src/lib.rs |  2 +-
 .../errors/borrowck/polonius/rust-polonius-ffi.h   |  2 +-
 .../checks/errors/borrowck/polonius/rust-polonius.h|  2 +-
 gcc/rust/checks/errors/borrowck/rust-bir-dump.cc   | 18 ++
 .../checks/errors/borrowck/rust-bir-fact-collector.h   |  2 +-
 gcc/rust/checks/errors/borrowck/rust-bir-free-region.h | 18 ++
 7 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/gcc/rust/checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs 
b/gcc/rust/checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs
index 3a849444bbc3..5b4e6d39d21c 100644
--- a/gcc/rust/checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs
+++ b/gcc/rust/checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2023 Free Software Foundation, Inc.
+// Copyright (C) 2020-2024 Free Software Foundation, Inc.
 
 // This file is part of GCC.
 
diff --git a/gcc/rust/checks/errors/borrowck/ffi-polonius/src/lib.rs 
b/gcc/rust/checks/errors/borrowck/ffi-polonius/src/lib.rs
index a9aa8106b69a..819c34a93749 100644
--- a/gcc/rust/checks/errors/borrowck/ffi-polonius/src/lib.rs
+++ b/gcc/rust/checks/errors/borrowck/ffi-polonius/src/lib.rs
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2023 Free Software Foundation, Inc.
+// Copyright (C) 2020-2024 Free Software Foundation, Inc.
 
 // This file is part of GCC.
 
diff --git a/gcc/rust/checks/errors/borrowck/polonius/rust-polonius-ffi.h 
b/gcc/rust/checks/errors/borrowck/polonius/rust-polonius-ffi.h
index 500d25a3222e..ebfddab76170 100644
--- a/gcc/rust/checks/errors/borrowck/polonius/rust-polonius-ffi.h
+++ b/gcc/rust/checks/errors/borrowck/polonius/rust-polonius-ffi.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2023 Free Software Foundation, Inc.
+// Copyright (C) 2020-2024 Free Software Foundation, Inc.
 
 // This file is part of GCC.
 
diff --git a/gcc/rust/checks/errors/borrowck/polonius/rust-polonius.h 
b/gcc/rust/checks/errors/borrowck/polonius/rust-polonius.h
index df746dd0c767..239cc3440117 100644
--- a/gcc/rust/checks/errors/borrowck/polonius/rust-polonius.h
+++ b/gcc/rust/checks/errors/borrowck/polonius/rust-polonius.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2022 Free Software Foundation, Inc.
+// Copyright (C) 2020-2024 Free Software Foundation, Inc.
 
 // This file is part of GCC.
 
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc 
b/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
index a39f145f8f95..d3398b6f405a 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-dump.cc
@@ -1,3 +1,21 @@
+// Copyright (C) 2020-2024 Free Software Foundation, Inc.
+
+// This file is part of GCC.
+
+// GCC is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3, or (at your option) any later
+// version.
+
+// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GCC; see the file COPYING3.  If not see
+// 
+
 #include "rust-system.h"
 #include "rust-bir-dump.h"
 #include "rust-diagnostics.h"
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h 
b/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
index 527ae65606cc..bb8fedaf3db7 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-fact-collector.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2023 Free Software Foundation, Inc.
+// Copyright (C) 2020-2024 Free Software Foundation, Inc.
 
 // This file is part of GCC.
 
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-free-region.h 
b/gcc/rust/checks/errors/borrowck/rust-bir-free-region.h
index e5d6ef3c98be..b8d73c9c070d 100644
---

  1   2   3   4   5   6   >