[llvm] r337643 - Early exit with cheaper checks
Aditya Kumar via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 21 07:13:44 PDT 2018
Author: hiraditya
Date: Sat Jul 21 07:13:44 2018
New Revision: 337643
URL: http://llvm.org/viewvc/llvm-project?rev=337643&view=rev
Log:
Early exit with cheaper checks
Reviewers: sebpop,davide,fhahn,trentxintong
Differential Revision: https://reviews.llvm.org/D49617
Modified:
llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp?rev=337643&r1=337642&r2=337643&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CallSiteSplitting.cpp Sat Jul 21 07:13:44 2018
@@ -191,6 +191,17 @@ static bool canSplitCallSite(CallSite CS
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
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,
More information about the llvm-commits
mailing list