Debian Codegraph @

doc/SystemTap_Beginners_Guide/testsuite/systemtap.base/callee.inlined.c

raw
1 // Must compile with -g -O
2
3 // Note that there is no 100% guarantee that GCC will inline these. But giving
4 // really simple functions should help it make its decision. But note that they
5 // can't be too simple either, otherwise we won't even have an inline instance.
6
7 __attribute__((always_inline))
8 inline int baz(int a, int b) {
9 return a + b;
10 }
11
12 __attribute__((always_inline))
13 inline int foo(int a, int b) {
14 int c = a*2 + b;
15 c = baz(b, c);
16 return c;
17 }
18
19 __attribute__((always_inline))
20 inline int bar(int a, int b) {
21 int c = a + b;
22 c = foo(c, a*b);
23 return c;
24 }
25
26 int main(int argc, char** argv) {
27 int a = argc;
28 a = foo(a, a);
29 a = bar(a, a);
30 a = foo(a, a);
31 return ((a > 100) ? 0 : 1);
32 }
33