Merging r258610:
authorDavid Majnemer <david.majnemer@gmail.com>
Wed, 17 Feb 2016 18:48:45 +0000 (18:48 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Wed, 17 Feb 2016 18:48:45 +0000 (18:48 +0000)
------------------------------------------------------------------------
r258610 | majnemer | 2016-01-22 21:41:27 -0800 (Fri, 22 Jan 2016) | 3 lines

[PruneEH] Unify invoke and call handling in DeleteBasicBlock

No functionality change is intended.
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_38@261130 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/PruneEH.cpp

index 8e126d4..da3bf23 100644 (file)
@@ -231,11 +231,15 @@ void PruneEH::DeleteBasicBlock(BasicBlock *BB) {
   CallGraphNode *CGN = CG[BB->getParent()];
   for (BasicBlock::iterator I = BB->end(), E = BB->begin(); I != E; ) {
     --I;
-    if (CallInst *CI = dyn_cast<CallInst>(I)) {
-      if (!isa<IntrinsicInst>(I))
-        CGN->removeCallEdgeFor(CI);
-    } else if (InvokeInst *II = dyn_cast<InvokeInst>(I))
-      CGN->removeCallEdgeFor(II);
+
+    if (auto CS = CallSite (&*I)) {
+      const Function *Callee = CS.getCalledFunction();
+      if (!Callee || !Intrinsic::isLeaf(Callee->getIntrinsicID()))
+        CGN->removeCallEdgeFor(CS);
+      else if (!Callee->isIntrinsic())
+        CGN->removeCallEdgeFor(CS);
+    }
+
     if (!I->use_empty())
       I->replaceAllUsesWith(UndefValue::get(I->getType()));
   }