From 0d8677bc909985e1886b49fd2388643e75a85cef Mon Sep 17 00:00:00 2001 From: akashk4 <akashk4@illinois.edu> Date: Tue, 31 Dec 2019 06:20:37 -0600 Subject: [PATCH] Fix bug involving casts in internal nodes --- .../hpvm/lib/Transforms/BuildDFG/BuildDFG.cpp | 83 ++++++++++--------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/llvm/tools/hpvm/lib/Transforms/BuildDFG/BuildDFG.cpp b/llvm/tools/hpvm/lib/Transforms/BuildDFG/BuildDFG.cpp index 447ffdc9b1..2610fb5081 100644 --- a/llvm/tools/hpvm/lib/Transforms/BuildDFG/BuildDFG.cpp +++ b/llvm/tools/hpvm/lib/Transforms/BuildDFG/BuildDFG.cpp @@ -337,52 +337,55 @@ void BuildDFG::handleBindOutput(DFInternalNode* N, IntrinsicInst* II) { } void BuildDFG::BuildGraph (DFInternalNode* N, Function *F) { - + errs() << "FUNCTION: " << F->getName() << "\n"; // TODO: Place checks for valid visc functions. For example one of the // check can be that any function that contains visc dataflow graph // construction intrinsics should not have other llvm IR statements. // Iterate over all the instructions of a function and look for visc // intrinsics. - for (inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i) { - Instruction* I = &*i; // Grab pointer to instruction reference - DEBUG(errs() << *I << "\n"); - if(IntrinsicInst* II = dyn_cast<IntrinsicInst>(I)) { - DEBUG(errs() << "IntrinsicID = " << II->getIntrinsicID() << ": " << II->getCalledFunction()->getName()<<"\n"); - switch(II->getIntrinsicID()) { - - case Intrinsic::visc_createNode: - case Intrinsic::visc_createNode1D: - case Intrinsic::visc_createNode2D: - case Intrinsic::visc_createNode3D: - handleCreateNode (N, II); - break; - - case Intrinsic::visc_createEdge: - handleCreateEdge(N, II); - break; - case Intrinsic::visc_bind_input: - handleBindInput(N, II); - break; - case Intrinsic::visc_bind_output: - handleBindOutput(N, II); - break; - - //TODO: Reconsider launch within a dataflow graph (recursion?) - case Intrinsic::visc_wait: - case Intrinsic::visc_launch: - errs() << "Error: Launch/wait intrinsic used within a dataflow graph\n\t" << *II << "\n"; - break; - - default: - errs() << "Error: Invalid VISC Intrinsic inside Internal node!\n\t" << *II << "\n"; - break; - } - } - else if(!isa<ReturnInst>(I)) { - errs() << "Non-intrinsic instruction: " << *I << "\n"; - llvm_unreachable("Found non-intrinsic instruction inside an internal node. Only return instruction is allowed!"); - + for(auto &BB : *F) { + for(auto &Inst : BB) { + Instruction* I = &Inst; + DEBUG(errs() << *I << "\n"); + if(IntrinsicInst* II = dyn_cast<IntrinsicInst>(I)) { + DEBUG(errs() << "IntrinsicID = " << II->getIntrinsicID() << ": " << II->getCalledFunction()->getName()<<"\n"); + switch(II->getIntrinsicID()) { + + case Intrinsic::visc_createNode: + case Intrinsic::visc_createNode1D: + case Intrinsic::visc_createNode2D: + case Intrinsic::visc_createNode3D: + handleCreateNode (N, II); + break; + + case Intrinsic::visc_createEdge: + handleCreateEdge(N, II); + break; + case Intrinsic::visc_bind_input: + handleBindInput(N, II); + break; + case Intrinsic::visc_bind_output: + handleBindOutput(N, II); + break; + + //TODO: Reconsider launch within a dataflow graph (recursion?) + case Intrinsic::visc_wait: + case Intrinsic::visc_launch: + errs() << "Error: Launch/wait intrinsic used within a dataflow graph\n\t" << *II << "\n"; + break; + + default: + errs() << "Error: Invalid VISC Intrinsic inside Internal node!\n\t" << *II << "\n"; + break; + } + continue; + } + if(!isa<ReturnInst>(I) && !isa<CastInst>(I)) { + errs() << "Non-intrinsic instruction: " << *I << "\n"; + llvm_unreachable("Found non-intrinsic instruction inside an internal node. Only return instruction is allowed!"); + + } } } -- GitLab