https://gcc.gnu.org/g:2116e8d2275f8bfb04263f26eed17b928513fed8
commit r15-6713-g2116e8d2275f8bfb04263f26eed17b928513fed8 Author: Thomas Schwinge <tschwi...@baylibre.com> Date: Fri Dec 13 13:54:10 2024 +0100 nvptx: Add '__builtin_stack_save()', '__builtin_stack_restore()' test case [PR65181] Documenting the status quo. PR target/65181 gcc/testsuite/ * gcc.target/nvptx/__builtin_stack_save___builtin_stack_restore-1.c: Add. Diff: --- ..._builtin_stack_save___builtin_stack_restore-1.c | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/gcc/testsuite/gcc.target/nvptx/__builtin_stack_save___builtin_stack_restore-1.c b/gcc/testsuite/gcc.target/nvptx/__builtin_stack_save___builtin_stack_restore-1.c new file mode 100644 index 000000000000..294014dae1db --- /dev/null +++ b/gcc/testsuite/gcc.target/nvptx/__builtin_stack_save___builtin_stack_restore-1.c @@ -0,0 +1,32 @@ +/* Document what we do for '__builtin_stack_save()', '__builtin_stack_restore()'. */ + +/* { dg-do compile } + TODO We can't 'assemble' this -- it's invalid PTX code. */ +/* { dg-options {-O3 -mno-soft-stack} } */ +/* { dg-additional-options -save-temps } */ +/* { dg-final { check-function-bodies {** } {} } } */ + +void *p; + +void f(void) +{ + p = __builtin_stack_save(); + asm volatile ("" : : : "memory"); + __builtin_stack_restore(p); + asm volatile ("" : : : "memory"); +} +/* +** f: +** \.visible \.func f +** { +** st\.global\.u64 \[p\], %stack; +** ret; +*/ + +/* The concept of a '%stack' pointer doesn't apply like this for + '-mno-soft-stack': PTX "native" stacks (TODO). + + { dg-final { scan-assembler-not {%stack} { xfail *-*-* } } } */ + +/* As these are an internal-use built-in function, we don't bother with + emitting proper error diagnostics. */