[LLVMdev] How to get line number and source file name for IR?

Xi Wang xi.wang at gmail.com
Mon May 18 19:34:37 PDT 2009


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
>




More information about the llvm-dev mailing list