aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/torture/strub-const1.c
blob: 22056713cce4bdb7f8eb3507bbcb96a547039878 (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
/* { dg-do compile } */
/* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
/* { dg-require-effective-target strub } */

/* Check that, along with a strub const function call, we issue an asm
   statement to make sure the watermark passed to it is held in memory before
   the call, and another to make sure it is not assumed to be unchanged.  f
   should not be inlined into g, but if it were too simple it might be folded
   by interprocedural value-range propagation.  */

extern int __attribute__ ((__strub__ ("callable"),
			   __const__, __nothrow__)) c ();

int __attribute__ ((__strub__, __const__))
f () {
  return c ();
}

int
g () {
  return f ();
}

/* { dg-final { scan-ipa-dump-times "__asm__" 2 "strub" } } */