2 /* { dg-require-effective-target hwaddress_exec } */
3 /* { dg-additional-options "--param hwasan-instrument-allocas=0 -save-temps" } */
4 /* Only run this test without optimisation. When running with optimisation we
5 use the unprotected-allocas-1.c file that also checks there are no memory
6 tagging calls (since when optimised the only variable on the stack should be
7 the vararray/alloca). */
8 /* { dg-skip-if "" { *-*-* } { "-O1" "-O2" "-O3" } { "" } } */
10 #define alloca __builtin_alloca
11 #define assert(x) if (!(x)) __builtin_abort ()
13 char tag_of (void * x
) { return ((unsigned long long)x
) >> 56; }
15 int __attribute__ ((noinline
))
16 using_alloca (int num
)
19 int *big_array
= (int*)alloca (num
* sizeof (int));
20 char alloca_tag
= tag_of (big_array
);
21 assert (alloca_tag
== 0);
22 for (int i
= 0; i
< num
; ++i
) {
23 retval
+= big_array
[i
];
28 int __attribute__ ((noinline
))
29 using_vararray (int num
)
33 char vararray_tag
= tag_of (big_array
);
34 assert (vararray_tag
== 0);
35 for (int i
= 0; i
< num
; ++i
) {
36 retval
+= big_array
[i
];