[PATCH] D49617: Early exit with cheaper checks

Aditya Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 20 14:40:59 PDT 2018


hiraditya created this revision.
hiraditya added reviewers: davide, trentxintong, fhahn, sebpop.

https://reviews.llvm.org/D49617

Files:
  lib/Transforms/Scalar/CallSiteSplitting.cpp


Index: lib/Transforms/Scalar/CallSiteSplitting.cpp
===================================================================
--- lib/Transforms/Scalar/CallSiteSplitting.cpp
+++ lib/Transforms/Scalar/CallSiteSplitting.cpp
@@ -191,6 +191,15 @@
     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;
+
+  if (!CallSiteBB->canSplitPredecessors())
+    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 +213,7 @@
       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,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49617.156610.patch
Type: text/x-patch
Size: 1604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180720/37b8357a/attachment.bin>


More information about the llvm-commits mailing list