[llvm-dev] getting the value back from metadata

Alon Shaltiel (ashaltie) via llvm-dev
Mon, 14 Nov 2016 17:18:46 -0000

Hello,

I'm trying to extract the value out of my MDNode, but for some reason I
can't.



For example, if one part of the code gets an MDNode that was created as follows:

Metadata* vals[2]
       { ValueAsMetadata::get(&F),
ValueAsMetadata::get(ConstantInt::get(context, 135)) };

MDNode* mdnode = MDNode::get(context, vals);



Is it possible to extract the value of the constant int (135 in this case)?



I tried using MetaDataAsValue as follows:

cast<ConstantInt>(MetadataAsValue::get(context,

                                 mdnode->getOperand(1)))->getZExtValue()



but I get NULL... (although when pronting the MetadataAsValue I do see "i32
135")



maybe the MDNode should be built in a different manner?



Thanks!

Alon





-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20161114/bcd300a0/attachment.html>