[PATCH] Track indirect calls for call site information in debug info.
Pierre-Marie de Rodat
derodat@adacore.com
Mon Jul 20 13:02:00 GMT 2015
Hello,
On PowerPC targets with -mlongcall, most subprogram calls are turned
into indirect calls: the call target is read from a register even though
it is compile-time known. This makes it difficult for machine code
static analysis engines to recover the callee information. The attached
patch is an attempt to help such engines, generating
DW_AT_abstract_origin attributes for all DW_TAG_GNU_call_site we are
interested in.
Here is how it works:
1. At -O0, the var-tracking pass is disabled, so in order to get a
NOTE_INSN_CALL_ARG_LOCATION for each call we are interested in, this
patch creates a new "naive" var-tracking pass. When optimizing, the
regular var-tracking pass does this job and this new pass is disabled.
2. The DWARF back-end (dwarf2out.c) first registers this RTL note
(in dwarf2out_var_location, already existing code) and extracts the
corresponding callee function symbol reference (new code to add handling
for the case we are interested in).
There, the patch also relaxes assertions in gen_subprogram_die:
yes, we can have both a compile-time known call target and an indirect
call. Already existing code in gen_subprogram_die calls
gen_call_site_die and takes care of generating the corresponding debug
information.
Bootstrapped and regtested on x86_64-pc-linux-gnu and powerpc-linux-gnu:
no regression. Ok for trunk? Thank you in advance for your feedback!
gcc/ChangeLog:
* passes.def: Add a new pass: variable_tracking_no_opt.
* rtl.h (variable_tracking_no_opt_main): New.
* tree-pass.h (make_pass_variable_tracking_no_opt): New.
* var-tracking.c (variable_tracking_no_opt_main,
pass_data_variable_tracking_no_opt,
pass_variable_tracking_no_opt,
make_pass_variable_tracking_no_opt): New. Implement the new
pass which adds notes for indirect calls.
* dwarf2out.c (dwarf2out_var_location): Set the symbol reference
for calls whose target is compile-time known but that are
indirect.
(gen_subprogram_die): Handle such calls.
--
Pierre-Marie de Rodat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Track-indirect-calls-for-call-site-information-in-de.patch
Type: text/x-diff
Size: 8597 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150720/5a92a719/attachment.bin>
More information about the Gcc-patches
mailing list