aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/cet-notrack-icf-4.c
blob: b5f07876b5290e1f7a8bb4a0c3aeabb5b4ee54b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* Verify nocf_check function calls are not ICF optimized.  */
/* { dg-do compile } */
/* { dg-options "-O2 -fcf-protection" } */
/* { dg-final { scan-assembler "endbr" } } */
/* { dg-final { scan-assembler "fn2:" } } */
/* { dg-final { scan-assembler "set\[ \t]+fn3,fn1" } } */

int (*foo)(int);

typedef int (*type1_t) (int) __attribute__ ((nocf_check));
typedef int (*type2_t) (int);

static __attribute__((noinline)) int
fn1 (int x)
{
  return ((type2_t)foo)(x + 12);
}

static __attribute__((noinline)) int
fn2 (int x)
{
  return ((type1_t)foo)(x + 12);
}

static __attribute__((noinline)) int
fn3 (int x)
{
  return ((type2_t)foo)(x + 12);
}

int
fn4 (int x)
{
  return fn1 (x) + fn2 (x) + fn3 (x);
}