Skip to content

Commit

Permalink
AMDGPU: Use eraseFromParent to delete am instruction when it is no lo…
Browse files Browse the repository at this point in the history
…nger needed.

Reviewer: Nicolai

Differential Revision:
  https://reviews.llvm.org/D46438

llvm-svn: 331788
  • Loading branch information
Changpeng Fang committed May 8, 2018
1 parent c517e95 commit d049da3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp
Expand Up @@ -145,7 +145,8 @@ static BasicBlock *unifyReturnBlockSet(Function &F,
if (PN)
PN->addIncoming(BB->getTerminator()->getOperand(0), BB);

BB->getInstList().pop_back(); // Remove the return insn
// Remove and delete the return inst.
BB->getTerminator()->eraseFromParent();
BranchInst::Create(NewRetBlock, BB);
}

Expand Down Expand Up @@ -190,7 +191,8 @@ bool AMDGPUUnifyDivergentExitNodes::runOnFunction(Function &F) {
new UnreachableInst(F.getContext(), UnreachableBlock);

for (BasicBlock *BB : UnreachableBlocks) {
BB->getInstList().pop_back(); // Remove the unreachable inst.
// Remove and delete the unreachable inst.
BB->getTerminator()->eraseFromParent();
BranchInst::Create(UnreachableBlock, BB);
}
}
Expand All @@ -201,7 +203,8 @@ bool AMDGPUUnifyDivergentExitNodes::runOnFunction(Function &F) {

Type *RetTy = F.getReturnType();
Value *RetVal = RetTy->isVoidTy() ? nullptr : UndefValue::get(RetTy);
UnreachableBlock->getInstList().pop_back(); // Remove the unreachable inst.
// Remove and delete the unreachable inst.
UnreachableBlock->getTerminator()->eraseFromParent();

Function *UnreachableIntrin =
Intrinsic::getDeclaration(F.getParent(), Intrinsic::amdgcn_unreachable);
Expand Down

0 comments on commit d049da3

Please sign in to comment.