xref: /llvm-project/llvm/test/tools/dsymutil/X86/Inputs/tail-call.cpp (revision f7052da6db8f85814adb2e1a6742d607e774bb88)
1 /*
2  * This file is used to test dsymutil support for call site entries with tail
3  * calls (DW_AT_call_pc).
4  *
5  * Instructions for regenerating binaries (on Darwin/x86_64):
6  *
7  * 1. Copy the source to a top-level directory to work around having absolute
8  *    paths in the symtab's OSO entries.
9  *
10  *    mkdir -p /Inputs/ && cp tail-call.c /Inputs && cd /Inputs
11  *
12  * 2. Compile with call site info enabled. -O2 is used to get tail call
13  *    promotion.
14  *
15  *    clang -g -O2 tail-call.c -c -o tail-call.macho.x86_64.o
16  *    clang tail-call.macho.x86_64.o -o tail-call.macho.x86_64
17  *
18  * 3. Copy the binaries back into the repo's Inputs directory. You'll need
19  *    -oso-prepend-path=%p to link.
20  */
21 
22 volatile int x;
23 
func2()24 __attribute__((disable_tail_calls, noinline)) void func2() { x++; }
25 
func1()26 __attribute__((noinline)) void func1() { func2(); /* tail */ }
27 
main()28 __attribute__((disable_tail_calls)) int main() { func1(); /* regular */ }
29