[LLVMdev] Finding the first line number of a function (-g vs -gline-tables-only)
Diego Novillo
dnovillo at google.com
Tue Nov 26 04:47:26 PST 2013
For the sample profiler, I need to determine the location of the first
user instruction in the function. This can be the LOC where the
function header is or the LOC of the actual first instruction, it
doesn't really matter. But it needs to be consistent wrt -g and
-gline-tables-only.
Currently, I'm scanning for the first non-zero line number from the
top of the function. This skips over the frame setup instructions
emitted by the compiler, that have no LOC, but it gives me different
results depending on whether -g or -gline-tables-only is used, and
whether the function has arguments:
- If -g is used, and the function has arguments, the first non-zero
loc instruction is the debug declaration call for the first argument:
call void @llvm.dbg.declare(...)
- If -g is used, and the function has no arguments, the first non-zero
loc instruction is the first user instruction.
- Similarly, if -gline-tables-only is used, we do not emit debug
declarations for the arguments, so the first non-zero loc is the first
user instruction.
I want to modify the scanning I do in my pass to skip over all the
debug setup instruction at the start of the function and latch on the
first user instruction. Is there a straightforward way to do that?
Right now I'm tempted to recognize calls to llvm.dbg.declare(), but I
don't know if that leaves other cases unhandled.
Thanks. Diego.
More information about the llvm-dev
mailing list