Debian Codegraph @

gcc/testsuite/gcc.dg/tree-prof/inliner-1.c

raw
1 /* { dg-options "-O2 -fdump-tree-optimized -fgnu89-inline" } */
2 int a;
3 int b[100];
4 void abort (void);
5
6 inline void
7 cold_function ()
8 {
9 int i;
10 for (i = 0; i < 99; i++)
11 if (b[i] / (b[i+1] + 1))
12 abort ();
13 }
14
15 inline void
16 hot_function ()
17 {
18 int i;
19 for (i = 0; i < 99; i++)
20 if (b[i] / (b[i+1] + 1))
21 abort ();
22 }
23
24 int
25 main ()
26 {
27 int i;
28 for (i = 0; i < 1000000; i++)
29 {
30 if (a)
31 cold_function (); /* Should not be inlined. */
32 else
33 hot_function (); /* Should be inlined. */
34 }
35 return 0;
36 }
37
38 /* The call to hot_function should be inlined, while cold_function should
39 not be. Look for the "cold_function ();" call statement and not for
40 its declaration or other occurrences of the string in the dump. */
41 /* { dg-final-use { scan-tree-dump "cold_function ..;" "optimized"} } */
42 /* { dg-final-use { scan-tree-dump-not "hot_function ..;" "optimized"} } */