Hello !<br><br>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):<br>
<br>First, maybe I don't add correctly metadata. <br><br>        LLVMContext& C = myInstruction->getContext();<br>        MDNode* N = MDNode::get(C, MDString::get(C, "add info"));<br>        myInstruction->setMetadata("important", N);<br>
        errs()<<"\n"<<cast<MDString>(myInstruction->getMetadata("important")->getOperand(0))->getString();<br><br>However, "add info" is printed after running the pass.<br>
<br>Second, it seems that the transformations are not applied on the .bc of the target program.<br>The Test1.bc (clean) and Test2.bc (transformation applied) are the same. I just have <br><br>    using namespace llvm;<br>
    <br>    namespace {<br>      struct metadata : public FunctionPass {<br>        const Function *F;<br>        static char ID; // Pass identifcation, replacement for typeid<br>        metadata() : FunctionPass(ID) {<br>
          //initializeMemDepPrinterPass(*PassRegistry::getPassRegistry());<br>        }<br>        virtual bool runOnFunction(Function &F);<br>        virtual void getAnalysisUsage(AnalysisUsage &AU) const {<br>          AU.setPreservesAll();<br>
        }<br>    <br>       // virtual void releaseMemory() {<br>        //  F = 0;<br>       // }<br>      };<br>    }<br>    <br>    char metadata::ID = 0;<br>    <br>    static RegisterPass<metadata> X("my-metadata", "Adding metadata", false, true);<br>
<br>at the beginning of my transformation pass. Please tell me how can I add metadata persistently. <br><br>Thank you for your answers !<br><br>