diff options
author | Thomas Schwinge <tschwinge@baylibre.com> | 2024-12-12 23:26:14 +0100 |
---|---|---|
committer | Thomas Schwinge <tschwinge@baylibre.com> | 2025-01-08 22:54:19 +0100 |
commit | 678c3f06fc165b883f63b0c44ce9f650b7c1504a (patch) | |
tree | 6e92ffa95e9fbc23af8e816ebc06d139df08adf2 | |
parent | 36eee5a74eb6d4c48a3a22cd71b3944bac499d0a (diff) | |
download | gcc-678c3f06fc165b883f63b0c44ce9f650b7c1504a.zip gcc-678c3f06fc165b883f63b0c44ce9f650b7c1504a.tar.gz gcc-678c3f06fc165b883f63b0c44ce9f650b7c1504a.tar.bz2 |
nvptx: Add '__builtin_alloca(0)' test cases [PR65181]
Documenting the status quo. This specific behavior relates to a 1994 change
(Subversion r7229, Git commit 15fc002672d643fd9d93d220027b5cd2aefc632c).
That one, however, isn't to blame here: we'd otherwise of course run into
nvptx' 'sorry, unimplemented: target cannot support alloca'.
PR target/65181
gcc/testsuite/
* gcc.target/nvptx/__builtin_alloca_0-1-O0.c: New.
* gcc.target/nvptx/__builtin_alloca_0-1-O1.c: Likewise.
-rw-r--r-- | gcc/testsuite/gcc.target/nvptx/__builtin_alloca_0-1-O0.c | 37 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/nvptx/__builtin_alloca_0-1-O1.c | 33 |
2 files changed, 70 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/nvptx/__builtin_alloca_0-1-O0.c b/gcc/testsuite/gcc.target/nvptx/__builtin_alloca_0-1-O0.c new file mode 100644 index 0000000..8c00a66 --- /dev/null +++ b/gcc/testsuite/gcc.target/nvptx/__builtin_alloca_0-1-O0.c @@ -0,0 +1,37 @@ +/* Document what we run into for '__builtin_alloca(0)'. */ + +/* { dg-do compile } + TODO We can't 'assemble' this -- it's invalid PTX code. */ +/* { dg-options {-O0 -mno-soft-stack} } */ +/* { dg-additional-options -save-temps } */ +/* { dg-final { check-function-bodies {** } {} } } */ + +void sink(void *); + +void f(void) +{ + sink(__builtin_alloca(0)); +} +/* +** f: +** .visible .func f +** { +** \.reg\.u64 (%r[0-9]+); +** \.reg\.u64 (%r[0-9]+); +** mov\.u64 \1, %stack; +** mov\.u64 \2, \1; +** { +** \.param\.u64 %out_arg1; +** st\.param\.u64 \[%out_arg1\], \2; +** call sink, \(%out_arg1\); +** } +** ret; +*/ + +/* '%stack' is 'VIRTUAL_STACK_DYNAMIC_REGNUM', 'virtual_stack_dynamic_rtx'. + For '__builtin_alloca (0)', we get to + 'gcc/explow.cc:allocate_dynamic_stack_space', where 'addr' gets set to + 'virtual_stack_dynamic_rtx', 'size == const0_rtx', therefore 'return addr;', + which gets us '%stack' -- undefined (TODO). + + { dg-final { scan-assembler-not {%stack} { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.target/nvptx/__builtin_alloca_0-1-O1.c b/gcc/testsuite/gcc.target/nvptx/__builtin_alloca_0-1-O1.c new file mode 100644 index 0000000..2d61065 --- /dev/null +++ b/gcc/testsuite/gcc.target/nvptx/__builtin_alloca_0-1-O1.c @@ -0,0 +1,33 @@ +/* Document what we run into for '__builtin_alloca(0)'. */ + +/* { dg-do compile } + TODO We can't 'assemble' this -- it's invalid PTX code. */ +/* { dg-options {-O1 -mno-soft-stack} } */ +/* { dg-additional-options -save-temps } */ +/* { dg-final { check-function-bodies {** } {} } } */ + +void sink(void *); + +void f(void) +{ + sink(__builtin_alloca(0)); +} +/* +** f: +** .visible .func f +** { +** { +** \.param\.u64 %out_arg1; +** st\.param\.u64 \[%out_arg1\], %stack; +** call sink, \(%out_arg1\); +** } +** ret; +*/ + +/* '%stack' is 'VIRTUAL_STACK_DYNAMIC_REGNUM', 'virtual_stack_dynamic_rtx'. + For '__builtin_alloca (0)', we get to + 'gcc/explow.cc:allocate_dynamic_stack_space', where 'addr' gets set to + 'virtual_stack_dynamic_rtx', 'size == const0_rtx', therefore 'return addr;', + which gets us '%stack' -- undefined (TODO). + + { dg-final { scan-assembler-not {%stack} { xfail *-*-* } } } */ |