summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/cet-notrack-icf-1.c
blob: 0bddf54862a9e16e37ec6766cb7d2da8f87a4bf8 (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
/* Verify nocf_check functions are not ICF optimized.  */
/* { dg-do compile } */
/* { dg-options "-O2 -fcf-protection=none" } */
/* { dg-final { scan-assembler-not "endbr" } } */
/* { dg-final { scan-assembler-not "fn3:" } } */
/* { dg-final { scan-assembler "set\[ \t]+fn2,fn1" } } */
/* { dg-final { scan-assembler "set\[ \t]+fn3,fn1" } } */

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

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

static __attribute__((noinline, nocf_check)) int
fn3 (int x)
{ /* { dg-warning "'nocf_check' attribute ignored. Use -fcf-protection option to enable it" } */
  return x + 12;
}

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