Zvonimir Rakamaric via llvm-dev
2015-Dec-22 14:53 UTC
[llvm-dev] Help with new llvm.debug.value metadata API
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?
Any pointers would be greatly appreciated.
Thanks!
-- Zvonimir
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20151222/92833728/attachment.html>
Adrian Prantl via llvm-dev
2015-Dec-22 18:45 UTC
[llvm-dev] Help with new llvm.debug.value metadata API
> 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
Vedant Kumar via llvm-dev
2015-Dec-23 17:32 UTC
[llvm-dev] Help with new llvm.debug.value metadata API
Hi Zvonimir,> 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.It looks like MDNode::getOperand() returns `const MDOperand &` now, not `Value *`.> 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?I haven't tried this, but I suspect you'd need something like: if (auto *VAM = dyn_cast<llvm::ValueAsMetadata>(m1->getOperand(0).get())) { // VAM->getType() } This should be documented in: http://llvm.org/docs/doxygen/html/classllvm_1_1MDNode.html best vedant