diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-10-03 13:24:02 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-10-03 13:24:02 +0000 |
commit | 4d63c8daec1759e60f85a49b7a91f88edf0c0a4d (patch) | |
tree | 276ff9d15c9a136e938063222196a9d4d1333c2f /lib | |
parent | 20357662a04f0a7f2f0850d072d0fafb0c53b90c (diff) | |
download | llvm-4d63c8daec1759e60f85a49b7a91f88edf0c0a4d.tar.gz llvm-4d63c8daec1759e60f85a49b7a91f88edf0c0a4d.tar.bz2 llvm-4d63c8daec1759e60f85a49b7a91f88edf0c0a4d.tar.xz |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191896 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/CaptureTracking.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Analysis/CaptureTracking.cpp b/lib/Analysis/CaptureTracking.cpp index 9eb76a8b27..79fab1be44 100644 --- a/lib/Analysis/CaptureTracking.cpp +++ b/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)) |