[llvm-dev] Help with new llvm.debug.value metadata API

Adrian Prantl via llvm-dev llvm-dev at lists.llvm.org
Tue Dec 22 10:45:13 PST 2015


> On Dec 22, 2015, at 6:53 AM, Zvonimir Rakamaric via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi all,
> 
> So I started working on upgrading our tool from LLVM 3.5 to 3.6, and I would appreciate your help with the new metadata API.
> 
> In particular, I currently have the following snippet of code:
> // ci is llvm.debug.value instruction
>     const llvm::MDNode* m1 = dyn_cast<const llvm::MDNode>(ci.getArgOperand(0));
>     const llvm::MDNode* m2 = dyn_cast<const llvm::MDNode>(ci.getArgOperand(2));
>     assert(m1 && "Expected metadata node in first argument to llvm.dbg.value.");
>     assert(m2 && "Expected metadata node in third argument to llvm.dbg.value.");
>     const llvm::MDString* m3 = dyn_cast<const llvm::MDString>(m2->getOperand(2));
>     assert(m3 && "Expected metadata string in the third argument to metadata node.");
> 
>    if (const llvm::Value* V = m1->getOperand(0)) { // this does not compile any more!
>    ... Need Type of Value V here.
>     }
> 
> In LLVM 3.6, the expression in the if condition does not compile any more.
> 
> What I basically need in the if body is to access the type (Type) of the variable specified in the llvm.debug.value metadata. How do I access its type using the new metadata API?

There are now convenient accessors to do all of this:

http://www.llvm.org/docs/doxygen/html/classllvm_1_1DbgValueInst.html

You’ll probably want:
   resolve(ci->getVariable()->getType())

-- adrian

> 
> Any pointers would be greatly appreciated.
> 
> Thanks!
> -- Zvonimir
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list