hc2428 at columbia.edu
2009-May-19 02:21 UTC
[LLVMdev] How to get line number and source file name for IR?
Dear Staff,
I am asking this question: given a line of IR code in *.ll file,
how can I know the corresponding line number and C/C++ source file
name for this IR code?
I am investigating some code patterns with LLVM IR, I need to
know where this IR code come from (the line number in a source file
name).
An existing way is using -g option to compile my software, then I
can get something as below:
call void @llvm.dbg.stoppoint(i32 9, i32 0, { }* bitcast
(%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit17 to { }*))
I know that the first argument is line number, and the third
argument, the compile unit llvm.dbg.compile_unit17, is mapped to a
source file. I can get the first line number very easily by
"CallSite::arg_iterator" (and represent the first argument with class
ConstantInt). However, I do not know how to represent the "{ }*
bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit17 to {
}*)" in LLVM source code.
Moreover, do we have a better way to achieve the line number and
source file name without the "-g" option?
Thanks,
Heming
Xi Wang
2009-May-19 02:34 UTC
[LLVMdev] How to get line number and source file name for IR?
check llvm/Analysis/DebugInfo.h (for -g). On Mon, May 18, 2009 at 10:21 PM, <hc2428 at columbia.edu> wrote:> Dear Staff, > I am asking this question: given a line of IR code in *.ll file, > how can I know the corresponding line number and C/C++ source file > name for this IR code? > I am investigating some code patterns with LLVM IR, I need to > know where this IR code come from (the line number in a source file > name). > An existing way is using -g option to compile my software, then I > can get something as below: > call void @llvm.dbg.stoppoint(i32 9, i32 0, { }* bitcast > (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit17 to { }*)) > > I know that the first argument is line number, and the third > argument, the compile unit llvm.dbg.compile_unit17, is mapped to a > source file. I can get the first line number very easily by > "CallSite::arg_iterator" (and represent the first argument with class > ConstantInt). However, I do not know how to represent the "{ }* > bitcast (%llvm.dbg.compile_unit.type* @llvm.dbg.compile_unit17 to { > }*)" in LLVM source code. > Moreover, do we have a better way to achieve the line number and > source file name without the "-g" option? > > Thanks, > Heming > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Maybe Matching Threads
- [LLVMdev] A few more questions about DIFactory and source-level debugging.
- [LLVMdev] Some questions on the output formats of AliasSetTracker
- [LLVMdev] Does llvm-db work?
- [LLVMdev] Is line number in DbgStopPointInst in LLVM accurate?
- [LLVMdev] Debug Information