aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/CaptureTracking.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-10-03 13:24:02 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-10-03 13:24:02 +0000
commitd2757ba1be2915c8f41dd850ffdda8ff6a673382 (patch)
tree714249e73a9e2178be5321e1efa88d1c86ff2e8b /llvm/lib/Analysis/CaptureTracking.cpp
parent0d17013cb734ae245527d7ccb1438a4ab88b4277 (diff)
downloadllvm-d2757ba1be2915c8f41dd850ffdda8ff6a673382.zip
llvm-d2757ba1be2915c8f41dd850ffdda8ff6a673382.tar.gz
llvm-d2757ba1be2915c8f41dd850ffdda8ff6a673382.tar.bz2
CaptureTracking: Plug a loophole in the "too many uses" heuristic.
The heuristic was added to avoid spending too much compile time A specially crafted test case (PR17461, PR16474) with many uses on a select or bitcast instruction can still trigger the slow case. Add a check for that case. This only affects compile time, don't have a good way to test it. llvm-svn: 191896
Diffstat (limited to 'llvm/lib/Analysis/CaptureTracking.cpp')
-rw-r--r--llvm/lib/Analysis/CaptureTracking.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/CaptureTracking.cpp b/llvm/lib/Analysis/CaptureTracking.cpp
index 9eb76a8..79fab1b 100644
--- a/llvm/lib/Analysis/CaptureTracking.cpp
+++ b/llvm/lib/Analysis/CaptureTracking.cpp
@@ -146,8 +146,14 @@ void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker) {
case Instruction::PHI:
case Instruction::Select:
// The original value is not captured via this if the new value isn't.
+ Count = 0;
for (Instruction::use_iterator UI = I->use_begin(), UE = I->use_end();
UI != UE; ++UI) {
+ // If there are lots of uses, conservatively say that the value
+ // is captured to avoid taking too much compile time.
+ if (Count++ >= Threshold)
+ return Tracker->tooManyUses();
+
Use *U = &UI.getUse();
if (Visited.insert(U))
if (Tracker->shouldExplore(U))