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?


check llvm/Analysis/DebugInfo.h (for -g).