Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DWARF] Emit DW_AT_call_pc for tail calls
Record the address of a tail-calling branch instruction within its call site entry using DW_AT_call_pc. This allows a debugger to determine the address to use when creating aritificial frames. This creates an extra attribute + relocation at tail call sites, which constitute 3-5% of all call sites in xnu/clang respectively. rdar://60307600 Differential Revision: https://reviews.llvm.org/D76336 (cherry picked from commit f7052da)
- Loading branch information
Showing
11 changed files
with
128 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* This file is used to test dsymutil support for call site entries with tail | ||
* calls (DW_AT_call_pc). | ||
* | ||
* Instructions for regenerating binaries (on Darwin/x86_64): | ||
* | ||
* 1. Copy the source to a top-level directory to work around having absolute | ||
* paths in the symtab's OSO entries. | ||
* | ||
* mkdir -p /Inputs/ && cp tail-call.c /Inputs && cd /Inputs | ||
* | ||
* 2. Compile with call site info enabled. -O2 is used to get tail call | ||
* promotion. | ||
* | ||
* clang -g -O2 tail-call.c -c -o tail-call.macho.x86_64.o | ||
* clang tail-call.macho.x86_64.o -o tail-call.macho.x86_64 | ||
* | ||
* 3. Copy the binaries back into the repo's Inputs directory. You'll need | ||
* -oso-prepend-path=%p to link. | ||
*/ | ||
|
||
volatile int x; | ||
|
||
__attribute__((disable_tail_calls, noinline)) void func2() { x++; } | ||
|
||
__attribute__((noinline)) void func1() { func2(); /* tail */ } | ||
|
||
__attribute__((disable_tail_calls)) int main() { func1(); /* regular */ } |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
RUN: dsymutil -oso-prepend-path=%p %p/Inputs/tail-call.macho.x86_64 -o %t.dSYM | ||
RUN: llvm-dwarfdump %t.dSYM | FileCheck %s -implicit-check-not=DW_AT_call_pc | ||
|
||
CHECK: DW_AT_call_pc (0x0000000100000f95) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters