Hi!

José, any objection to me pushing the attached
"BPF, nvptx: Standardize on 'sorry, unimplemented: dynamic stack allocation not 
supported'"?
(Why this is useful, you'll understand later today.)

I've tested BPF as follows:

    $ [...]/configure --target=bpf-none
    $ make -j12 all-gcc
    $ make check-gcc-c RUNTESTFLAGS=bpf.exp

The before vs. after 'diff' of 'gcc/testsuite/gcc/gcc.log' looks as
expected:

    [...]
     Executing on host: [...]/xgcc -B[...]/ 
[...]/gcc.target/bpf/diag-alloca-1.c    -fdiagnostics-plain-output    -ansi 
-pedantic-errors -S -o diag-alloca-1.s    (timeout = 300)
     spawn -ignore SIGHUP [...]/xgcc -B[...]/ 
[...]/gcc.target/bpf/diag-alloca-1.c -fdiagnostics-plain-output -ansi 
-pedantic-errors -S -o diag-alloca-1.s
     [...]/gcc.target/bpf/diag-alloca-1.c: In function 'foo':
    -[...]/gcc.target/bpf/diag-alloca-1.c:6:12: error: BPF does not support 
dynamic stack allocation
    +[...]/gcc.target/bpf/diag-alloca-1.c:6:12: sorry, unimplemented: dynamic 
stack allocation not supported
     compiler exited with status 1
    -PASS: gcc.target/bpf/diag-alloca-1.c  (test for errors, line 6)
    +PASS: gcc.target/bpf/diag-alloca-1.c  at line 7 (test for warnings, line 6)
     PASS: gcc.target/bpf/diag-alloca-1.c (test for excess errors)
     Executing on host: [...]/xgcc -B[...]/ 
[...]/gcc.target/bpf/diag-alloca-2.c    -fdiagnostics-plain-output   -std=gnu89 
-S -o diag-alloca-2.s    (timeout = 300)
     spawn -ignore SIGHUP [...]/xgcc -B[...]/ 
[...]/gcc.target/bpf/diag-alloca-2.c -fdiagnostics-plain-output -std=gnu89 -S 
-o diag-alloca-2.s
     [...]/gcc.target/bpf/diag-alloca-2.c: In function 'foo':
    -[...]/gcc.target/bpf/diag-alloca-2.c:7:7: error: BPF does not support 
dynamic stack allocation
    +[...]/gcc.target/bpf/diag-alloca-2.c:7:7: sorry, unimplemented: dynamic 
stack allocation not supported
     compiler exited with status 1
    -PASS: gcc.target/bpf/diag-alloca-2.c  (test for errors, line 7)
    +PASS: gcc.target/bpf/diag-alloca-2.c  at line 8 (test for warnings, line 7)
     PASS: gcc.target/bpf/diag-alloca-2.c (test for excess errors)
    [...]

(No further testing done for BPF.)


Grüße
 Thomas


>From 8ebac3064696c6d42041e398ebb5a622498523cc Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tschwi...@baylibre.com>
Date: Fri, 21 Feb 2025 11:21:08 +0100
Subject: [PATCH] BPF, nvptx: Standardize on 'sorry, unimplemented: dynamic
 stack allocation not supported'

... instead of BPF: 'error: BPF does not support dynamic stack allocation', and
nvptx: 'sorry, unimplemented: target cannot support alloca'.

	gcc/
	* config/bpf/bpf.md (define_expand "allocate_stack"): Emit
	'sorry, unimplemented: dynamic stack allocation not supported'.
	* config/nvptx/nvptx.md (define_expand "allocate_stack")
	[!TARGET_SOFT_STACK && !(TARGET_PTX_7_3 && TARGET_SM52)]: Likewise.
	gcc/testsuite/
	* gcc.target/bpf/diag-alloca-1.c: Adjust 'dg-message'.
	* gcc.target/bpf/diag-alloca-2.c: Likewise.
	* gcc.target/nvptx/alloca-1-sm_30.c: Likewise.
	* gcc.target/nvptx/vla-1-sm_30.c: Likewise.
	* lib/target-supports.exp (proc check_effective_target_alloca):
	Adjust comment.
---
 gcc/config/bpf/bpf.md                           | 5 ++---
 gcc/config/nvptx/nvptx.md                       | 2 +-
 gcc/testsuite/gcc.target/bpf/diag-alloca-1.c    | 3 ++-
 gcc/testsuite/gcc.target/bpf/diag-alloca-2.c    | 4 +++-
 gcc/testsuite/gcc.target/nvptx/alloca-1-sm_30.c | 2 +-
 gcc/testsuite/gcc.target/nvptx/vla-1-sm_30.c    | 2 +-
 gcc/testsuite/lib/target-supports.exp           | 2 +-
 7 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/gcc/config/bpf/bpf.md b/gcc/config/bpf/bpf.md
index 12cf9fae855..91d94838e39 100644
--- a/gcc/config/bpf/bpf.md
+++ b/gcc/config/bpf/bpf.md
@@ -121,12 +121,11 @@
   [(match_operand:DI 0 "general_operand" "")
    (match_operand:DI 1 "general_operand" "")]
   ""
-  "
 {
-  error (\"BPF does not support dynamic stack allocation\");
+  sorry ("dynamic stack allocation not supported");
   emit_insn (gen_nop ());
   DONE;
-}")
+})
 
 ;;;; Arithmetic/Logical
 
diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md
index 532812bcf70..dc19695d040 100644
--- a/gcc/config/nvptx/nvptx.md
+++ b/gcc/config/nvptx/nvptx.md
@@ -1723,7 +1723,7 @@
     emit_insn (gen_nvptx_alloca (Pmode, operands[0], operands[1]));
   else if (!TARGET_SOFT_STACK)
     {
-      sorry ("target cannot support alloca");
+      sorry ("dynamic stack allocation not supported");
       emit_insn (gen_nop ());
     }
   else if (TARGET_SOFT_STACK)
diff --git a/gcc/testsuite/gcc.target/bpf/diag-alloca-1.c b/gcc/testsuite/gcc.target/bpf/diag-alloca-1.c
index 0406f2c3595..e549cab84ca 100644
--- a/gcc/testsuite/gcc.target/bpf/diag-alloca-1.c
+++ b/gcc/testsuite/gcc.target/bpf/diag-alloca-1.c
@@ -3,7 +3,8 @@
 int
 foo (int x)
 {
-  int *p = __builtin_alloca (x); /* { dg-error "support" } */
+  int *p = __builtin_alloca (x);
+  /* { dg-message {sorry, unimplemented: dynamic stack allocation not supported} {} { target *-*-* } .-1 } */
 
   return p[2];
 }
diff --git a/gcc/testsuite/gcc.target/bpf/diag-alloca-2.c b/gcc/testsuite/gcc.target/bpf/diag-alloca-2.c
index ef7170b2c3d..b1084bf5726 100644
--- a/gcc/testsuite/gcc.target/bpf/diag-alloca-2.c
+++ b/gcc/testsuite/gcc.target/bpf/diag-alloca-2.c
@@ -4,6 +4,8 @@
 int
 foo (int x)
 {
-  int arr[x]; /* { dg-error "support" } */
+  int arr[x];
+  /* { dg-message {sorry, unimplemented: dynamic stack allocation not supported} {} { target *-*-* } .-1 } */
+
   return arr[3];
 }
diff --git a/gcc/testsuite/gcc.target/nvptx/alloca-1-sm_30.c b/gcc/testsuite/gcc.target/nvptx/alloca-1-sm_30.c
index 261a603ec4c..5538751035b 100644
--- a/gcc/testsuite/gcc.target/nvptx/alloca-1-sm_30.c
+++ b/gcc/testsuite/gcc.target/nvptx/alloca-1-sm_30.c
@@ -7,5 +7,5 @@ void sink(void *);
 void f(void)
 {
   sink(__builtin_alloca(123));
-  /* { dg-message {sorry, unimplemented: target cannot support alloca} {} { target *-*-* } .-1 } */
+  /* { dg-message {sorry, unimplemented: dynamic stack allocation not supported} {} { target *-*-* } .-1 } */
 }
diff --git a/gcc/testsuite/gcc.target/nvptx/vla-1-sm_30.c b/gcc/testsuite/gcc.target/nvptx/vla-1-sm_30.c
index 2bf2c91d60e..7c2d2e0e35b 100644
--- a/gcc/testsuite/gcc.target/nvptx/vla-1-sm_30.c
+++ b/gcc/testsuite/gcc.target/nvptx/vla-1-sm_30.c
@@ -7,6 +7,6 @@ void sink(void *);
 void f(int s)
 {
   char a[s];
-  /* { dg-message {sorry, unimplemented: target cannot support alloca} {} { target *-*-* } .-1 } */
+  /* { dg-message {sorry, unimplemented: dynamic stack allocation not supported} {} { target *-*-* } .-1 } */
   sink(a);
 }
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 47564a400e6..9346bb3e03c 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -990,7 +990,7 @@ proc check_effective_target_untyped_assembly {} {
     return 1
 }
 
-# Return 1 if alloca is supported, 0 otherwise.
+# Return 1 if dynamic stack allocation is supported, 0 otherwise.
 
 proc check_effective_target_alloca {} {
     if { [istarget bpf-*-*] } {
-- 
2.34.1

Reply via email to