]> granicus.if.org Git - llvm/commitdiff
Early exit with cheaper checks
authorAditya Kumar <hiraditya@msn.com>
Sat, 21 Jul 2018 14:13:44 +0000 (14:13 +0000)
committerAditya Kumar <hiraditya@msn.com>
Sat, 21 Jul 2018 14:13:44 +0000 (14:13 +0000)
Reviewers: sebpop,davide,fhahn,trentxintong
Differential Revision: https://reviews.llvm.org/D49617

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337643 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/CallSiteSplitting.cpp

index 20bfe458fc6fb7d2933ffa893490351a9aa6ae15..5ebfbf8a879b77c4649d8b286c1b163804694bb4 100644 (file)
@@ -191,6 +191,17 @@ static bool canSplitCallSite(CallSite CS, TargetTransformInfo &TTI) {
     return false;
 
   BasicBlock *CallSiteBB = Instr->getParent();
+  // Need 2 predecessors and cannot split an edge from an IndirectBrInst.
+  SmallVector<BasicBlock *, 2> Preds(predecessors(CallSiteBB));
+  if (Preds.size() != 2 || isa<IndirectBrInst>(Preds[0]->getTerminator()) ||
+      isa<IndirectBrInst>(Preds[1]->getTerminator()))
+    return false;
+
+  // BasicBlock::canSplitPredecessors is more agressive, so checking for
+  // BasicBlock::isEHPad as well.
+  if (!CallSiteBB->canSplitPredecessors() || CallSiteBB->isEHPad())
+    return false;
+
   // Allow splitting a call-site only when the CodeSize cost of the
   // instructions before the call is less then DuplicationThreshold. The
   // instructions before the call will be duplicated in the split blocks and
@@ -204,19 +215,7 @@ static bool canSplitCallSite(CallSite CS, TargetTransformInfo &TTI) {
       return false;
   }
 
-  // Need 2 predecessors and cannot split an edge from an IndirectBrInst.
-  SmallVector<BasicBlock *, 2> Preds(predecessors(CallSiteBB));
-  if (Preds.size() != 2 || isa<IndirectBrInst>(Preds[0]->getTerminator()) ||
-      isa<IndirectBrInst>(Preds[1]->getTerminator()))
-    return false;
-
-  // Do not split a call-site in an exception handling block. This check
-  // prevents triggering an assertion in SplitEdge used via
-  // DuplicateInstructionsInSplitBetween. 
-  if (CallSiteBB->isEHPad())
-    return false;
-
-  return CallSiteBB->canSplitPredecessors();
+  return true;
 }
 
 static Instruction *cloneInstForMustTail(Instruction *I, Instruction *Before,