Skip to content
Snippets Groups Projects
Commit 08a47b92 authored by Hashim Sharif's avatar Hashim Sharif
Browse files

Adding support for removing @llvm.visc.node.id calls in ClearDFG (conseravtive for correctness)

parent 059a6fb7
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,7 @@ private: ...@@ -59,6 +59,7 @@ private:
//Functions //Functions
void deleteNode(DFNode* N); void deleteNode(DFNode* N);
public: public:
// Constructor // Constructor
TreeTraversal(Module &_M, BuildDFG &_DFG) : M(_M), DFG(_DFG) { } TreeTraversal(Module &_M, BuildDFG &_DFG) : M(_M), DFG(_DFG) { }
...@@ -88,6 +89,7 @@ public: ...@@ -88,6 +89,7 @@ public:
}; };
bool ClearDFG::runOnModule(Module &M) { bool ClearDFG::runOnModule(Module &M) {
errs() << "\nCLEARDFG PASS\n"; errs() << "\nCLEARDFG PASS\n";
// Get the BuildDFG Analysis Results: // Get the BuildDFG Analysis Results:
// - Dataflow graph // - Dataflow graph
...@@ -118,6 +120,19 @@ bool ClearDFG::runOnModule(Module &M) { ...@@ -118,6 +120,19 @@ bool ClearDFG::runOnModule(Module &M) {
VC->replaceAllUsesWith(UndefValue::get(VC->getType())); VC->replaceAllUsesWith(UndefValue::get(VC->getType()));
VC->eraseFromParent(); 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 // Visitor for Code Generation Graph Traversal
TreeTraversal *Visitor = new TreeTraversal(M, DFG); TreeTraversal *Visitor = new TreeTraversal(M, DFG);
...@@ -125,7 +140,9 @@ bool ClearDFG::runOnModule(Module &M) { ...@@ -125,7 +140,9 @@ bool ClearDFG::runOnModule(Module &M) {
for (auto rootNode: Roots) { for (auto rootNode: Roots) {
Visitor->visit(rootNode); Visitor->visit(rootNode);
} }
delete Visitor; delete Visitor;
return true; return true;
} }
...@@ -149,7 +166,7 @@ void TreeTraversal::deleteNode(DFNode* N) { ...@@ -149,7 +166,7 @@ void TreeTraversal::deleteNode(DFNode* N) {
char ClearDFG::ID = 0; char ClearDFG::ID = 0;
static RegisterPass<ClearDFG> X("clearDFG", static RegisterPass<ClearDFG> X("clearDFG",
"Delete all DFG functions for which code has been generated", "Delete all DFG functions for which code has been generated",
false /* does not modify the CFG */, false /* does not modify the CFG */,
true /* transformation, not just analysis */); true /* transformation, not just analysis */);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment