Vedavyas Duggirala
2011-Mar-29 22:58 UTC
[LLVMdev] Accessing metadata & creating DIVariable
I get the filename and directory from DISubprogram from reading llvm.dbg.sp and use that to DIBuiler::.createCompileUnit. This leads to "duplicate symbol" error from llc.>>> You need to call di.createCompileUnit() once for your translation unit in the beginning. You don't need to keep track of CU yourself. DIBuilder will take care of it. After words, you can call di.createBasicType(..) and it will work. >> >> Actually it doesn't. But if I call di.createCompileUnit(file, dir, >> producer, ...) with file or dir different from that of CU already in >> the file, then it works. It isn't sufficient if the producer is >> different. That fixes my problem, so many thanks. >> >> If DIBuiler constructor would pick existing CU from the Module, we >> can retain original CU entry. But, I do no have enough knowledge of >> DWARF or LLVM, to know if it is valid/reasonable thing to do. > > Either you have not answered my earlier question OR I missed your reply. In any case, how did you get (or create) your pre existing CU from the Module ? What did you do to construct it ? > - > Devang >
On Mar 29, 2011, at 3:58 PM, Vedavyas Duggirala wrote:> I get the filename and directory from DISubprogram from reading > llvm.dbg.sp and use > that to DIBuiler::.createCompileUnit. This leads to "duplicate > symbol" error from llc.If the llvm::Module already has llvm.dbg.sp then you don't need to use DIBuilder::createCompileUnit(). The point, I am missing is how did you get llvm.dbg.sp in module ? It seems you already have generated debug info in llvm::Module using DIBuilder. If that is true then you don't need to use createCompileUnit() for the same translation unit. If you reading a llvm::Module which already has a debug info and you are trying to add more debug info in the module than DIBuilder is not the tool for you. Have you looked at how clang generated debug info ? - Devang
Vedavyas Duggirala
2011-Mar-29 23:30 UTC
[LLVMdev] Accessing metadata & creating DIVariable
>>> I get the filename and directory from DISubprogram from reading >>> llvm.dbg.sp and use >>> that to DIBuiler::.createCompileUnit. This leads to "duplicate >>> symbol" error from llc.>> If the llvm::Module already has llvm.dbg.sp then you don't need to use DIBuilder::createCompileUnit(). The point, I am missing is how did you get llvm.dbg.sp in module ? >> >> It seems you already have generated debug info in llvm::Module using DIBuilder. If that is true then you don't need to use createCompileUnit() for the same translation unit.Yes, that was what I said in the first line of my original mail :) I am adding instrumentation code/variables to IR, and I want to add debuginfo for the new variables and calls I introduced.>> If you reading a llvm::Module which already has a debug info and you are trying to add more debug info in the module than DIBuilder is not the tool for you. > > :( > >> Have you looked at how clang generated debug info ?No experience with clang, But where do I have to look ? Is what I am looking for even possible. I thought since it is said optimization passes update the metadata, it should be simple. Vyas