From ec7c07a379701ef161a62ce41d5dfdb0e13abe92 Mon Sep 17 00:00:00 2001 From: akashk4 <akashk4@illinois.edu> Date: Thu, 2 Jan 2020 11:15:10 -0600 Subject: [PATCH] Added assertions for inserted hpvm instrinsics and integer arguments --- llvm/tools/hpvm/lib/Transforms/GenVISC/GenVISC.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/llvm/tools/hpvm/lib/Transforms/GenVISC/GenVISC.cpp b/llvm/tools/hpvm/lib/Transforms/GenVISC/GenVISC.cpp index 43140244ff..cd711b4a7d 100644 --- a/llvm/tools/hpvm/lib/Transforms/GenVISC/GenVISC.cpp +++ b/llvm/tools/hpvm/lib/Transforms/GenVISC/GenVISC.cpp @@ -1065,6 +1065,7 @@ bool GenVISC::runOnModule(Module &M) { DEBUG(errs() << *EdgeF << "\n"); ConstantInt* Op = cast<ConstantInt>(CI->getArgOperand(5)); ConstantInt* EdgeTypeOp = cast<ConstantInt>(CI->getArgOperand(2)); + assert(Op && EdgeTypeOp && "Arguments of CreateEdge are not constant integers."); Value* isStreaming = Op->isZero()? ConstantInt::getFalse(Ctx) : ConstantInt::getTrue(Ctx); Value* isAllToAll = EdgeTypeOp->isZero()? ConstantInt::getFalse(Ctx) @@ -1086,6 +1087,7 @@ bool GenVISC::runOnModule(Module &M) { DEBUG(errs() << *BindInF << "\n"); // Check if this is a streaming bind or not ConstantInt* Op = cast<ConstantInt>(CI->getArgOperand(3)); + assert(Op && "Streaming argument for bind in intrinsic should be a constant integer."); Value* isStreaming = Op->isZero()? ConstantInt::getFalse(Ctx) : ConstantInt::getTrue(Ctx); Value* BindInArgs[] = {CI->getArgOperand(0), CI->getArgOperand(1), @@ -1104,6 +1106,7 @@ bool GenVISC::runOnModule(Module &M) { DEBUG(errs() << *BindOutF << "\n"); // Check if this is a streaming bind or not ConstantInt* Op = cast<ConstantInt>(CI->getArgOperand(3)); + assert(Op && "Streaming argument for bind out intrinsic should be a constant integer."); Value* isStreaming = Op->isZero()? ConstantInt::getFalse(Ctx) : ConstantInt::getTrue(Ctx); Value* BindOutArgs[] = {CI->getArgOperand(0), CI->getArgOperand(1), @@ -1121,7 +1124,13 @@ bool GenVISC::runOnModule(Module &M) { Function* F = I->getParent()->getParent(); DEBUG(errs() << F->getName() << "\n";); IntrinsicInst* NodeIntrinsic = cast<IntrinsicInst>(CI->getArgOperand(0)); + assert(NodeIntrinsic && "Instruction value in bind out is not a create node intrinsic."); DEBUG(errs() << "Node intrinsic: " << *NodeIntrinsic << "\n"); + assert((NodeIntrinsic->getIntrinsicID() == Intrinsic::visc_createNode || + NodeIntrinsic->getIntrinsicID() == Intrinsic::visc_createNode1D || + NodeIntrinsic->getIntrinsicID() == Intrinsic::visc_createNode2D || + NodeIntrinsic->getIntrinsicID() == Intrinsic::visc_createNode3D) && + "Instruction value in bind out is not a create node intrinsic."); Function* ChildF = cast<Function>(NodeIntrinsic->getArgOperand(0)->stripPointerCasts()); DEBUG(errs() << ChildF->getName() << "\n";); int srcpos = cast<ConstantInt>(CI->getArgOperand(1))->getSExtValue(); @@ -1199,7 +1208,6 @@ bool GenVISC::runOnModule(Module &M) { toBeErased.push_back(CI); ReplaceInstWithInst(oldReturn, RetInst); DEBUG(errs() << "Function after visc return processing\n" << *I->getParent()->getParent() << "\n"); - } if (isVISCCall_getNodeInstanceID_x(I)) { -- GitLab