Index: lib/Analysis/LazyValueInfo.cpp =================================================================== --- lib/Analysis/LazyValueInfo.cpp +++ lib/Analysis/LazyValueInfo.cpp @@ -39,6 +39,8 @@ #define DEBUG_TYPE "lazy-value-info" +static const unsigned MaxProcessedPerValue = 500; + char LazyValueInfoWrapperPass::ID = 0; INITIALIZE_PASS_BEGIN(LazyValueInfoWrapperPass, "lazy-value-info", "Lazy Value Information Analysis", false, true) @@ -646,7 +648,21 @@ } // end anonymous namespace void LazyValueInfoImpl::solve() { + unsigned processedCount = 0; while (!BlockValueStack.empty()) { + processedCount++; + // Abort if we have to process too many values to get a result for this one. + if (processedCount > MaxProcessedPerValue) { + DEBUG(dbgs() << "Giving up on stack because we are getting too deep\n"); + while (!BlockValueStack.empty()) { + std::pair &e = BlockValueStack.top(); + TheCache.insertResult(e.second, e.first, + LVILatticeVal::getOverdefined()); + BlockValueSet.erase(e); + BlockValueStack.pop(); + } + return; + } std::pair &e = BlockValueStack.top(); assert(BlockValueSet.count(e) && "Stack value should be in BlockValueSet!");