]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Fix up vla-1.c test [PR119931]
authorJakub Jelinek <jakub@redhat.com>
Tue, 25 Nov 2025 10:18:07 +0000 (11:18 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 25 Nov 2025 10:18:07 +0000 (11:18 +0100)
From what I can see, the vla-1.c test has been added to test the handling
of debug info for optimized out parameters.  But recent changes don't make
the argument optimized away, but optimized away and replaced by constant 5
(even without IPA-VRP).  The function is noinline, but can't be noclone
nor noipa exactly because we want to test how it behaves when it is cloned
and the unused argument is dropped.

So, the following patch arranges to hide from the IPA optimizations the
value of x in the caller (and even make sure it is preserved in a register
or stack slot in the caller across the call).

2025-11-25  Jakub Jelinek  <jakub@redhat.com>

PR testsuite/119931
* gcc.dg/vla-1.c (main): Hide x value from optimizers and use it after
the call as well.

gcc/testsuite/gcc.dg/vla-1.c

index d16e73d1dc3accc5ea70075a4505f3832d81b8bf..2ab2b7a48acf61c5b015c8214bfb04ed775e244c 100644 (file)
@@ -16,11 +16,12 @@ main ()
 {
   volatile int j;
   int x = 5;
+  asm volatile ("" : "+r" (x));
   j = f1 (x);
+  asm volatile ("" : "+r" (x));
   return 0;
 }
 
 /* One debug source bind is generated for the parameter, and one to describe the
    sizes of a and b.  */
 /* { dg-final { scan-tree-dump-times " s=> i" 2 "optimized" } } */
-