summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
diff options
context:
space:
mode:
authorTaewook Oh <twoh@fb.com>2018-04-05 04:16:23 +0000
committerTaewook Oh <twoh@fb.com>2018-04-05 04:16:23 +0000
commite0db533febf4af42a5fd5af9bdbc3f6c6d043523 (patch)
treecca336485ea3df69f9bb16b1165b46218300989a /llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
parent70565e4cacfec74b75b4ef893e391c5ae95f5bf4 (diff)
downloadbcm5719-llvm-e0db533febf4af42a5fd5af9bdbc3f6c6d043523.tar.gz
bcm5719-llvm-e0db533febf4af42a5fd5af9bdbc3f6c6d043523.zip
[CallSiteSplitting] Do not perform callsite splitting inside landing pad
Summary: If the callsite is inside landing pad, do not perform callsite splitting. Callsite splitting uses utility function llvm::DuplicateInstructionsInSplitBetween, which eventually calls llvm::SplitEdge. llvm::SplitEdge calls llvm::SplitCriticalEdge with an assumption that the function returns nullptr only when the target edge is not a critical edge (and further assumes that if the return value was not nullptr, the predecessor of the original target edge always has a single successor because critical edge splitting was successful). However, this assumtion is not true because SplitCriticalEdge returns nullptr if the destination block is a landing pad. This invalid assumption results assertion failure. Fundamental solution might be fixing llvm::SplitEdge to not to rely on the invalid assumption. However, it'll involve a lot of work because current API assumes that llvm::SplitEdge never fails. Instead, this patch makes callsite splitting to not to attempt splitting if the callsite is in a landing pad. Attached test case will crash with assertion failure without the fix. Reviewers: fhahn, junbuml, dberlin Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D45130 llvm-svn: 329250
Diffstat (limited to 'llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp b/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
index 796177b5f85..2a29c08a655 100644
--- a/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
+++ b/llvm/lib/Transforms/Scalar/CallSiteSplitting.cpp
@@ -206,6 +206,12 @@ static bool canSplitCallSite(CallSite CS, TargetTransformInfo &TTI) {
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();
}
OpenPOWER on IntegriCloud