While the language reference mention a lot about the LLVM Metadata,
and I see some posts on SO - How to add a Metadata String to an LLVM module with the C++ API?
I also see some code in the llvm source- http://llvm.org/doxygen/DIBuilder_8cpp_source.html
However, they dont seem to mention how to create a MDNode containing a ConstantInt of a particular width.
Following is the relevant code (doesn't work ) -
std::vector<Metadata*> Elts =
{
ConstantInt::get(TheContext,APInt(returnType->getIntegerBitWidth(),decimal_val))
};
MDNode* Node = MDNode::get(TheContext, Elts);
callInst->setMetadata(LLVMContext::MD_range,Node);
Can anyone explain how this can be done ?
Thanks!