[PATCH] D28075: MergeFunctions: Preserve debug info in thunks, under option -mergefunc-preserve-debug-info

Anmol P. Paralkar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 22 19:41:31 PST 2016


appcs created this revision.
appcs added reviewers: echristo, aprantl, friss, eeckstein.
appcs added a subscriber: llvm-commits.
Herald added subscribers: mehdi_amini, jfb.

Under -mergefunc-preserve-debug-info MergeFunctions::writeThunk():

- Does not create a new function for the thunk.
- Retains the debug info (and associated instructions) in the entry block for the thunk's parameters. PS: -debug will display the algorithm at work.
- Creates debug-info for the call (to the "master-copy") made by the thunk and its return value.
- Does not mark the call made by the thunk as a tail-call, so that the backtrace indicates the execution flow at -O0.
- Erases the rest of the function, retaining the (minimally sized) entry block.

GDB (7.11.1) features verified to work at [-O0, -O2]:
 (gdb) info functions # Thunked function will now be listed.
 (gdb) step <thunked function> # Reaches the "master-copy" function that the thunk calls.
 (gdb) backtrace # When inside the thunk, will show call chain leading up to the thunk

  1. When we step into the master-copy function called by the thunk, will
  2. show call chain leading upto the master-copy (including thunk, one-above, at -O0)
  3. but PS: at -O<non-zero> the call does get tail-call'optimized, so will not show, as generally. (gdb) finish # When inside the thunk and when inside the master-copy when called from the thunk (gdb) break # On thunked function
1. On master-copy function, breaks on newly inserted call made from within thunk
2. On call-site of thunked function in another translation unit (not the TU of its definition)


https://reviews.llvm.org/D28075

Files:
  lib/Transforms/IPO/MergeFunctions.cpp
  test/Transforms/MergeFunc/thunk-debugability.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28075.82397.patch
Type: text/x-patch
Size: 36902 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161223/8ef9dcee/attachment.bin>


More information about the llvm-commits mailing list