nvptx: Add test cases for dead/unused 'alloca'/VLA

gcc/testsuite/
	* gcc.target/nvptx/alloca-1-dead-O0-sm_30.c: New.
	* gcc.target/nvptx/alloca-1-dead-O0.c: Likewise.
	* gcc.target/nvptx/alloca-1-dead-O1-sm_30.c: Likewise.
	* gcc.target/nvptx/alloca-1-dead-O1.c: Likewise.
	* gcc.target/nvptx/alloca-1-unused-O0-sm_30.c: Likewise.
	* gcc.target/nvptx/alloca-1-unused-O0.c: Likewise.
	* gcc.target/nvptx/alloca-1-unused-O1-sm_30.c: Likewise.
	* gcc.target/nvptx/alloca-1-unused-O1.c: Likewise.
	* gcc.target/nvptx/vla-1-dead-O0-sm_30.c: Likewise.
	* gcc.target/nvptx/vla-1-dead-O0.c: Likewise.
	* gcc.target/nvptx/vla-1-dead-O1-sm_30.c: Likewise.
	* gcc.target/nvptx/vla-1-dead-O1.c: Likewise.
	* gcc.target/nvptx/vla-1-unused-O0-sm_30.c: Likewise.
	* gcc.target/nvptx/vla-1-unused-O0.c: Likewise.
	* gcc.target/nvptx/vla-1-unused-O1-sm_30.c: Likewise.
	* gcc.target/nvptx/vla-1-unused-O1.c: Likewise.
This commit is contained in:
Thomas Schwinge 2025-02-24 22:03:47 +01:00
parent cfc9f42122
commit 5c9ef3bdab
16 changed files with 295 additions and 0 deletions

View file

@ -0,0 +1,10 @@
/* { dg-do compile } */
/* { dg-options {-O0 -mno-soft-stack} } */
/* { dg-additional-options -march=sm_30 } */
void f(void)
{
char *a = __builtin_alloca(123);
/* { dg-message {sorry, unimplemented: dynamic stack allocation not supported} {} { target *-*-* } .-1 } */
a[0] = 0;
}

View file

@ -0,0 +1,48 @@
/* { dg-do assemble } */
/* { dg-options {-O0 -mno-soft-stack} } */
/* { dg-add-options nvptx_alloca_ptx } */
/* { dg-additional-options -save-temps } */
/* { dg-final { check-function-bodies {** } {} } } */
void f(void)
{
char *a = __builtin_alloca(123);
a[0] = 0;
}
/*
** f:
** \.visible \.func f
** {
** \.local \.align 16 \.b8 %frame_ar\[16\];
** \.reg\.u64 %frame;
** cvta\.local\.u64 %frame, %frame_ar;
** \.reg\.u64 (%r[0-9]+);
** \.reg\.u64 (%r[0-9]+);
** \.reg\.u64 (%r[0-9]+);
** \.reg\.u64 (%r[0-9]+);
** \.reg\.u64 (%r[0-9]+);
** \.reg\.u64 (%r[0-9]+);
** \.reg\.u64 (%r[0-9]+);
** \.reg\.u64 (%r[0-9]+);
** \.reg\.u64 (%r[0-9]+);
** \.reg\.u32 (%r[0-9]+);
** \.reg\.u64 (%r[0-9]+);
** mov\.u64 \11, 16;
** add\.u64 \1, \11, -1;
** add\.u64 \2, \1, 123;
** div\.u64 \3, \2, 16;
** mul\.lo\.u64 \4, \3, 16;
** {
** \.reg\.u64 \5_local;
** alloca\.u64 \5_local, \4;
** cvta\.local\.u64 \5, \5_local;
** }
** add\.u64 \6, \5, 15;
** shr\.u64 \7, \6, 4;
** shl\.b64 \8, \7, 4;
** st\.u64 \[%frame\], \8;
** ld\.u64 \9, \[%frame\];
** mov\.u32 \10, 0;
** st\.u8 \[\9\], \10;
** ret;
*/

View file

@ -0,0 +1,17 @@
/* { dg-do assemble } */
/* { dg-options {-O1 -mno-soft-stack} } */
/* { dg-additional-options -march=sm_30 } */
/* { dg-additional-options -save-temps } */
/* { dg-final { check-function-bodies {** } {} } } */
void f(void)
{
char *a = __builtin_alloca(123);
a[0] = 0;
}
/*
** f:
** \.visible \.func f
** {
** ret;
*/

View file

@ -0,0 +1,17 @@
/* { dg-do assemble } */
/* { dg-options {-O1 -mno-soft-stack} } */
/* { dg-add-options nvptx_alloca_ptx } */
/* { dg-additional-options -save-temps } */
/* { dg-final { check-function-bodies {** } {} } } */
void f(void)
{
char *a = __builtin_alloca(123);
a[0] = 0;
}
/*
** f:
** \.visible \.func f
** {
** ret;
*/

View file

@ -0,0 +1,9 @@
/* { dg-do compile } */
/* { dg-options {-O0 -mno-soft-stack} } */
/* { dg-additional-options -march=sm_30 } */
void f(void)
{
__builtin_alloca(123); /* { dg-warning "ignoring return value of '__builtin_alloca' declared with attribute 'warn_unused_result'" } */
/* { dg-message {sorry, unimplemented: dynamic stack allocation not supported} {} { target *-*-* } .-1 } */
}

View file

@ -0,0 +1,16 @@
/* { dg-do assemble } */
/* { dg-options {-O0 -mno-soft-stack} } */
/* { dg-add-options nvptx_alloca_ptx } */
/* { dg-additional-options -save-temps } */
/* { dg-final { check-function-bodies {** } {} } } */
void f(void)
{
__builtin_alloca(123); /* { dg-warning "ignoring return value of '__builtin_alloca' declared with attribute 'warn_unused_result'" } */
}
/*
** f:
** \.visible \.func f
** {
** ret;
*/

View file

@ -0,0 +1,16 @@
/* { dg-do assemble } */
/* { dg-options {-O1 -mno-soft-stack} } */
/* { dg-additional-options -march=sm_30 } */
/* { dg-additional-options -save-temps } */
/* { dg-final { check-function-bodies {** } {} } } */
void f(void)
{
__builtin_alloca(123); /* { dg-warning "ignoring return value of '__builtin_alloca' declared with attribute 'warn_unused_result'" } */
}
/*
** f:
** \.visible \.func f
** {
** ret;
*/

View file

@ -0,0 +1,16 @@
/* { dg-do assemble } */
/* { dg-options {-O1 -mno-soft-stack} } */
/* { dg-add-options nvptx_alloca_ptx } */
/* { dg-additional-options -save-temps } */
/* { dg-final { check-function-bodies {** } {} } } */
void f(void)
{
__builtin_alloca(123); /* { dg-warning "ignoring return value of '__builtin_alloca' declared with attribute 'warn_unused_result'" } */
}
/*
** f:
** \.visible \.func f
** {
** ret;
*/

View file

@ -0,0 +1,10 @@
/* { dg-do compile } */
/* { dg-options {-O0 -mno-soft-stack} } */
/* { dg-additional-options -march=sm_30 } */
void f(int s)
{
char a[s];
/* { dg-message {sorry, unimplemented: dynamic stack allocation not supported} {} { target *-*-* } .-1 } */
a[0] = 0;
}

View file

@ -0,0 +1,27 @@
/* { dg-do assemble } */
/* { dg-options {-O0 -mno-soft-stack} } */
/* { dg-add-options nvptx_alloca_ptx } */
/* { dg-additional-options -save-temps } */
/* { dg-final { check-function-bodies {**} {} } } */
void f(int s)
{
char a[s];
a[0] = 0;
}
/*
** f:
** ...
** cvt\.s64\.s32 (%r[0-9]+), (%r[0-9]+);
** mov\.u64 (%r[0-9]+), 16;
** add\.u64 (%r[0-9]+), \3, -1;
** add\.u64 (%r[0-9]+), \1, \4;
** div\.u64 (%r[0-9]+), \5, 16;
** mul\.lo\.u64 (%r[0-9]+), \6, 16;
** {
** \.reg\.u64 (%r[0-9]+)_local;
** alloca\.u64 \8_local, \7;
** cvta\.local\.u64 \8, \8_local;
** }
** ...
*/

View file

@ -0,0 +1,19 @@
/* { dg-do assemble } */
/* { dg-options {-O1 -mno-soft-stack} } */
/* { dg-additional-options -march=sm_30 } */
/* { dg-additional-options -save-temps } */
/* { dg-final { check-function-bodies {** } {} } } */
void f(int s)
{
char a[s];
a[0] = 0;
}
/*
** f:
** \.visible \.func f \(\.param\.u32 %in_ar0\)
** {
** \.reg\.u32 %ar0;
** ld\.param\.u32 %ar0, \[%in_ar0\];
** ret;
*/

View file

@ -0,0 +1,19 @@
/* { dg-do assemble } */
/* { dg-options {-O1 -mno-soft-stack} } */
/* { dg-add-options nvptx_alloca_ptx } */
/* { dg-additional-options -save-temps } */
/* { dg-final { check-function-bodies {** } {} } } */
void f(int s)
{
char a[s];
a[0] = 0;
}
/*
** f:
** \.visible \.func f \(\.param\.u32 %in_ar0\)
** {
** \.reg\.u32 %ar0;
** ld\.param\.u32 %ar0, \[%in_ar0\];
** ret;
*/

View file

@ -0,0 +1,9 @@
/* { dg-do compile } */
/* { dg-options {-O0 -mno-soft-stack} } */
/* { dg-additional-options -march=sm_30 } */
void f(int s)
{
char a[s];
/* { dg-message {sorry, unimplemented: dynamic stack allocation not supported} {} { target *-*-* } .-1 } */
}

View file

@ -0,0 +1,26 @@
/* { dg-do assemble } */
/* { dg-options {-O0 -mno-soft-stack} } */
/* { dg-add-options nvptx_alloca_ptx } */
/* { dg-additional-options -save-temps } */
/* { dg-final { check-function-bodies {**} {} } } */
void f(int s)
{
char a[s];
}
/*
** f:
** ...
** cvt\.s64\.s32 (%r[0-9]+), (%r[0-9]+);
** mov\.u64 (%r[0-9]+), 16;
** add\.u64 (%r[0-9]+), \3, -1;
** add\.u64 (%r[0-9]+), \1, \4;
** div\.u64 (%r[0-9]+), \5, 16;
** mul\.lo\.u64 (%r[0-9]+), \6, 16;
** {
** \.reg\.u64 (%r[0-9]+)_local;
** alloca\.u64 \8_local, \7;
** cvta\.local\.u64 \8, \8_local;
** }
** ...
*/

View file

@ -0,0 +1,18 @@
/* { dg-do assemble } */
/* { dg-options {-O1 -mno-soft-stack} } */
/* { dg-additional-options -march=sm_30 } */
/* { dg-additional-options -save-temps } */
/* { dg-final { check-function-bodies {** } {} } } */
void f(int s)
{
char a[s];
}
/*
** f:
** \.visible \.func f \(\.param\.u32 %in_ar0\)
** {
** \.reg\.u32 %ar0;
** ld\.param\.u32 %ar0, \[%in_ar0\];
** ret;
*/

View file

@ -0,0 +1,18 @@
/* { dg-do assemble } */
/* { dg-options {-O1 -mno-soft-stack} } */
/* { dg-add-options nvptx_alloca_ptx } */
/* { dg-additional-options -save-temps } */
/* { dg-final { check-function-bodies {** } {} } } */
void f(int s)
{
char a[s];
}
/*
** f:
** \.visible \.func f \(\.param\.u32 %in_ar0\)
** {
** \.reg\.u32 %ar0;
** ld\.param\.u32 %ar0, \[%in_ar0\];
** ret;
*/