Hello everyone,<br><br>I am trying to write a trivial adding metadata transformation pass. I have Test.bc the target on which I want to perform transformations.<br><br>First, I compile with clang++ my target program and I have my resulting Test.bc. I save it under Test1.bc. <br>
As a particular example, I have " <span class="comment-copy">%myDimension = alloca %class.ThreeDimension, align 4 </span> ".<br><br>Second, I apply my pass :<br>//..../llvm/Release+Asserts/bin/opt -load //home/alex/llvm/Release+Asserts/lib/my_test_metadata.so -my-metadata //..../llvm/tools/clang/woRKSPACE/Test.bc<br>
<br>Test1.bc and Test.bc are the same. In Test.bc no metadata is added. However, if in my transformation pass I debug with errs(), metadata is displayed ( " <span class="comment-copy">%myDimension = alloca %class.ThreeDimension, align 4, !sensitive !0, !md !1</span> " ), but the Test.bc file is not modified (still have " <span class="comment-copy">%myDimension = alloca %class.ThreeDimension, align 4 </span> "). <br>
<br>Can you tell me how can I make the transformations persistent?<br><br>I have :<br><pre><code>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);</code></pre>Thank you !