x86: Enable -fcf-protection with multi-byte NOPs
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / cet-notrack-icf-3.c
blobed2d53ac5ef3554984c0fc3e76e68f50d69b58bf
1 /* Verify nocf_check function calls are not ICF optimized. */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -fcf-protection=none" } */
4 /* { dg-final { scan-assembler-not "endbr" } } */
5 /* { dg-final { scan-assembler-not "fn2:" } } */
6 /* { dg-final { scan-assembler "set\[ \t]+fn2,fn1" } } */
7 /* { dg-final { scan-assembler "set\[ \t]+fn3,fn1" } } */
9 int (*foo)(int);
11 typedef int (*type1_t) (int) __attribute__ ((nocf_check)); /* { dg-warning "'nocf_check' attribute ignored. Use -fcf-protection option to enable it" } */
12 typedef int (*type2_t) (int);
14 static __attribute__((noinline)) int
15 fn1 (int x)
17 return ((type2_t)foo)(x + 12);
20 static __attribute__((noinline)) int
21 fn2 (int x)
23 return ((type1_t)foo)(x + 12);
26 static __attribute__((noinline)) int
27 fn3 (int x)
29 return ((type2_t)foo)(x + 12);
32 int
33 fn4 (int x)
35 return fn1 (x) + fn2 (x) + fn3 (x);