1 /* Verify nocf_check function calls are not ICF optimized.  */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -fcf-protection" } */
4 /* { dg-final { scan-assembler "endbr" } } */
5 /* { dg-final { scan-assembler "fn2:" } } */
6 /* { dg-final { scan-assembler "set\[ \t]+fn3,fn1" { target { ! *-*-darwin* } } } } */
7 
8 int (*foo)(int);
9 
10 typedef int (*type1_t) (int) __attribute__ ((nocf_check));
11 typedef int (*type2_t) (int);
12 
13 static __attribute__((noinline)) int
fn1(int x)14 fn1 (int x)
15 {
16   return ((type2_t)foo)(x + 12);
17 }
18 
19 static __attribute__((noinline)) int
fn2(int x)20 fn2 (int x)
21 {
22   return ((type1_t)foo)(x + 12);
23 }
24 
25 static __attribute__((noinline)) int
fn3(int x)26 fn3 (int x)
27 {
28   return ((type2_t)foo)(x + 12);
29 }
30 
31 int
fn4(int x)32 fn4 (int x)
33 {
34   return fn1 (x) + fn2 (x) + fn3 (x);
35 }
36