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:
//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 */);
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