[LLVMdev] Replacement for findStopPoint() in LLVM 2.7

Devang Patel devang.patel at gmail.com
Tue Mar 16 11:18:45 PDT 2010


2010/3/16 John Criswell <criswell at uiuc.edu>:
> Török Edwin wrote:
>> [snip]
>>
>> Ah, the method got moved to the instruction itself!
>>
>> dbgKind = Context->getMDKindID("dbg");
>> if (MDNode *Dbg = I->getMetadata(dbgKind)) {
>> ...
>>
>
> Thanks!  This appears to work.
>
> I also have code that looks up debug information for GlobalVariables and
> regular LLVM Value *'s.  For the former, I think I can look up their
> debug information by using the DebugInfoFinder class and iterating
> through all the MDNodes for global variables (using the
> global_variable_begin()/global_variable_end() methods).  Is this the
> best way to do it, or is there a better way?
>

That'll work, but may not be as efficient as it could be, if you're
only interested in global variables' debug info. You can try following

  NamedMDNode *NMD = M.getNamedMetadata("llvm.dbg.gv");
  if (!NMD)
    return;

  for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
    DIGlobalVariable DIG(cast<MDNode>(NMD->getOperand(i)));
    ...
   }

-
Devang




More information about the llvm-dev mailing list