[PATCH] D47949: [callsitesplit] Limit the # of predecessors walk when recording condition
Xin Tong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 8 09:07:50 PDT 2018
trentxintong created this revision.
trentxintong added reviewers: fhahn, junbuml.
We have some pathological cases (generated by machine) which
callsite splitting chokes on.
Repository:
rL LLVM
https://reviews.llvm.org/D47949
Files:
lib/Transforms/Scalar/CallSiteSplitting.cpp
Index: lib/Transforms/Scalar/CallSiteSplitting.cpp
===================================================================
--- lib/Transforms/Scalar/CallSiteSplitting.cpp
+++ lib/Transforms/Scalar/CallSiteSplitting.cpp
@@ -84,6 +84,15 @@
"their cost is below DuplicationThreshold"),
cl::init(5));
+
+/// Only allow N level of predecessors to be walked.
+static cl::opt<unsigned>
+ PredecessorWalkThreshold("callsite-predecessor-walk-threshold", cl::Hidden,
+ cl::desc("Only allow N number of predecessors to be"
+ "walked"),
+ cl::init(16));
+
+
static void addNonNullAttribute(CallSite CS, Value *Op) {
unsigned ArgNo = 0;
for (auto &I : CS.args()) {
@@ -152,6 +161,7 @@
/// x == 1 and x == 0, the first condition will be used.
static void recordConditions(CallSite CS, BasicBlock *Pred,
ConditionsTy &Conditions) {
+ uint32_t PredWalked = 0;
recordCondition(CS, Pred, CS.getInstruction()->getParent(), Conditions);
BasicBlock *From = Pred;
BasicBlock *To = Pred;
@@ -161,6 +171,9 @@
recordCondition(CS, From, To, Conditions);
Visited.insert(From);
To = From;
+ // Make sure we do not traverse too many predecessors up the CFG.
+ if (++PredWalked > PredecessorWalkThreshold)
+ break;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47949.150527.patch
Type: text/x-patch
Size: 1413 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180608/a88a793c/attachment.bin>
More information about the llvm-commits
mailing list