[PATCH] D46438: AMDGPU: Use eraseFromParent to delete am instruction when it is no longer needed.

Changpeng Fang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 4 09:34:44 PDT 2018


cfang created this revision.
cfang added reviewers: nhaehnle, kzhuravl.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, wdng.

We should delete the instruction when it is not needed any more.
Done in file AMDGPUUnifyDivergentExitNodes.cpp


https://reviews.llvm.org/D46438

Files:
  lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp


Index: lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp
===================================================================
--- lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp
+++ lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp
@@ -145,7 +145,8 @@
     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);
   }
 
@@ -190,7 +191,8 @@
       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);
       }
     }
@@ -201,7 +203,8 @@
 
       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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46438.145211.patch
Type: text/x-patch
Size: 1366 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180504/f47fed36/attachment.bin>


More information about the llvm-commits mailing list