1 | volatile int x; |
2 | |
3 | void __attribute__((noinline)) sink2() { |
4 | x++; //% self.filecheck("bt", "main.cpp", "-check-prefix=FROM-FUNC1") |
5 | // FROM-FUNC1: frame #0: 0x{{[0-9a-f]+}} a.out`sink{{.*}} at main.cpp:[[@LINE-1]] |
6 | // FROM-FUNC1-NEXT: sink |
7 | // FROM-FUNC1-NEXT: func1 |
8 | // FROM-FUNC1-SAME: [artificial] |
9 | // FROM-FUNC1-NEXT: main |
10 | } |
11 | |
12 | void __attribute__((noinline)) sink(bool called_from_main) { |
13 | if (called_from_main) { |
14 | x++; //% self.filecheck("bt", "main.cpp", "-check-prefix=FROM-MAIN") |
15 | // FROM-MAIN: frame #0: 0x{{[0-9a-f]+}} a.out`sink{{.*}} at main.cpp:[[@LINE-1]] |
16 | // FROM-MAIN-NEXT: main |
17 | } else { |
18 | sink2(); |
19 | } |
20 | } |
21 | |
22 | void __attribute__((noinline)) func1() { sink(called_from_main: false); /* tail */ } |
23 | |
24 | int __attribute__((disable_tail_calls)) main(int argc, char **) { |
25 | // When func1 tail-calls sink, make sure that the former appears in the |
26 | // backtrace. |
27 | sink(called_from_main: true); |
28 | func1(); |
29 | return 0; |
30 | } |
31 | |