[llvm] r191896 - CaptureTracking: Plug a loophole in the "too many uses" heuristic.

Benjamin Kramer benny.kra at googlemail.com
Thu Oct 3 06:24:02 PDT 2013

Author: d0k
Date: Thu Oct  3 08:24:02 2013
New Revision: 191896

URL: http://llvm.org/viewvc/llvm-project?rev=191896&view=rev
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.


Modified: llvm/trunk/lib/Analysis/CaptureTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CaptureTracking.cpp?rev=191896&r1=191895&r2=191896&view=diff
--- llvm/trunk/lib/Analysis/CaptureTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/CaptureTracking.cpp Thu Oct  3 08:24:02 2013
@@ -146,8 +146,14 @@ void llvm::PointerMayBeCaptured(const Va
     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))

More information about the llvm-commits mailing list