Alexandru Ionut Diaconescu
2013-Feb-08 12:07 UTC
[LLVMdev] llvm metadata transformation pass
Hello !
I have a toolchain of two passes. First one, is a transformation pass that
should add metadata to some structures (instructions/variables) and the
second pass is an analyzing pass which needs to access the added metadata.
The problem is with my adding metadata transformation pass. There might be
two problems(or both):
First, maybe I don't add correctly metadata.
LLVMContext& C = myInstruction->getContext();
MDNode* N = MDNode::get(C, MDString::get(C, "add info"));
myInstruction->setMetadata("important", N);
errs()<<"\n"<<cast<MDString>(myInstruction->getMetadata("important")->getOperand(0))->getString();
However, "add info" is printed after running the pass.
Second, it seems that the transformations are not applied on the .bc of the
target program.
The Test1.bc (clean) and Test2.bc (transformation applied) are the same. I
just have
using namespace llvm;
namespace {
struct metadata : public FunctionPass {
const Function *F;
static char ID; // Pass identifcation, replacement for typeid
metadata() : FunctionPass(ID) {
//initializeMemDepPrinterPass(*PassRegistry::getPassRegistry());
}
virtual bool runOnFunction(Function &F);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
}
// virtual void releaseMemory() {
// F = 0;
// }
};
}
char metadata::ID = 0;
static RegisterPass<metadata> X("my-metadata", "Adding
metadata",
false, true);
at the beginning of my transformation pass. Please tell me how can I add
metadata persistently.
Thank you for your answers !
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20130208/21ee5f7e/attachment.html>
Possibly Parallel Threads
- [LLVMdev] write a transformation pass
- [LLVMdev] How can I output assembly comments from emitPrologue()?
- [LLVMdev] How can I output assembly comments from emitPrologue()?
- [LLVMdev] How to get ELF section virtual starting address from MCSymbolRefExpr?
- [LLVMdev] creating new Metadata
