diff --git a/llvm/lib/Transforms/ClearDFG/ClearDFG.cpp b/llvm/lib/Transforms/ClearDFG/ClearDFG.cpp index 37f74325a74a04e11fad7352115214565c41a689..84f9bec04f6d3c4e71a5a5be76152c3a9be128b0 100644 --- a/llvm/lib/Transforms/ClearDFG/ClearDFG.cpp +++ b/llvm/lib/Transforms/ClearDFG/ClearDFG.cpp @@ -59,6 +59,7 @@ private: //Functions void deleteNode(DFNode* N); + public: // Constructor TreeTraversal(Module &_M, BuildDFG &_DFG) : M(_M), DFG(_DFG) { } @@ -88,6 +89,7 @@ public: }; bool ClearDFG::runOnModule(Module &M) { + errs() << "\nCLEARDFG PASS\n"; // Get the BuildDFG Analysis Results: // - Dataflow graph @@ -118,6 +120,19 @@ bool ClearDFG::runOnModule(Module &M) { VC->replaceAllUsesWith(UndefValue::get(VC->getType())); VC->eraseFromParent(); + + Function* VN = M.getFunction("llvm.visc.node.id"); + if (VN != NULL){ // Delete visc.node.id intrinsic calls if they exist + for(Value::user_iterator ui = VN->user_begin(), ue = VN->user_end(); ui != ue; ui++) { + Instruction* I = dyn_cast<Instruction>(*ui); + I->eraseFromParent(); + } + + VN->replaceAllUsesWith(UndefValue::get(VN->getType())); + VN->eraseFromParent(); + } + + // Visitor for Code Generation Graph Traversal TreeTraversal *Visitor = new TreeTraversal(M, DFG); @@ -125,7 +140,9 @@ bool ClearDFG::runOnModule(Module &M) { for (auto rootNode: Roots) { Visitor->visit(rootNode); } + delete Visitor; + return true; } @@ -149,7 +166,7 @@ void TreeTraversal::deleteNode(DFNode* N) { char ClearDFG::ID = 0; static RegisterPass<ClearDFG> X("clearDFG", - "Delete all DFG functions for which code has been generated", - false /* does not modify the CFG */, - true /* transformation, not just analysis */); + "Delete all DFG functions for which code has been generated", + false /* does not modify the CFG */, + true /* transformation, not just analysis */);