From e68713ae8b7bc30ce96f9d74685e3c230340a01f Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Wed, 5 Jan 2011 23:26:22 +0000 Subject: [PATCH] Reorder, rename, and document some members to make this easier to follow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122929 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/LazyValueInfo.cpp | 43 ++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/lib/Analysis/LazyValueInfo.cpp b/lib/Analysis/LazyValueInfo.cpp index 17348cd028e..9be106b8575 100644 --- a/lib/Analysis/LazyValueInfo.cpp +++ b/lib/Analysis/LazyValueInfo.cpp @@ -351,13 +351,26 @@ namespace { /// LazyValueInfoCache - This is the cache kept by LazyValueInfo which /// maintains information about queries across the clients' queries. class LazyValueInfoCache { - public: /// ValueCacheEntryTy - This is all of the cached block information for /// exactly one Value*. The entries are sorted by the BasicBlock* of the /// entries, allowing us to do a lookup with a binary search. typedef std::map, LVILatticeVal> ValueCacheEntryTy; - private: + /// ValueCache - This is all of the cached information for all values, + /// mapped from Value* to key information. + DenseMap ValueCache; + + /// OverDefinedCache - This tracks, on a per-block basis, the set of + /// values that are over-defined at the end of that block. This is required + /// for cache updating. + typedef std::pair, Value*> OverDefinedPairTy; + DenseSet OverDefinedCache; + + /// BlockValueStack - This stack holds the state of the value solver + /// during a query. It basically emulates the callstack of the naive + /// recursive value lookup process. + std::stack > BlockValueStack; + friend struct LVIValueHandle; /// OverDefinedCacheUpdater - A helper object that ensures that the @@ -378,16 +391,8 @@ namespace { return changed; } }; - - /// ValueCache - This is all of the cached information for all values, - /// mapped from Value* to key information. - DenseMap ValueCache; - /// OverDefinedCache - This tracks, on a per-block basis, the set of - /// values that are over-defined at the end of that block. This is required - /// for cache updating. - typedef std::pair, Value*> OverDefinedPairTy; - DenseSet OverDefinedCache; + LVILatticeVal getBlockValue(Value *Val, BasicBlock *BB); bool getEdgeValue(Value *V, BasicBlock *F, BasicBlock *T, @@ -410,8 +415,6 @@ namespace { ValueCacheEntryTy &lookup(Value *V) { return ValueCache[LVIValueHandle(V, this)]; } - - std::stack > block_value_stack; public: /// getValueInBlock - This is the query interface to determine the lattice @@ -478,10 +481,10 @@ void LazyValueInfoCache::eraseBlock(BasicBlock *BB) { } void LazyValueInfoCache::solve() { - while (!block_value_stack.empty()) { - std::pair &e = block_value_stack.top(); + while (!BlockValueStack.empty()) { + std::pair &e = BlockValueStack.top(); if (solveBlockValue(e.second, e.first)) - block_value_stack.pop(); + BlockValueStack.pop(); } } @@ -688,7 +691,7 @@ bool LazyValueInfoCache::solveBlockValueConstantRange(LVILatticeVal &BBLV, BasicBlock *BB) { // Figure out the range of the LHS. If that fails, bail. if (!hasBlockValue(BBI->getOperand(0), BB)) { - block_value_stack.push(std::make_pair(BB, BBI->getOperand(0))); + BlockValueStack.push(std::make_pair(BB, BBI->getOperand(0))); return false; } @@ -818,7 +821,7 @@ bool LazyValueInfoCache::getEdgeValue(Value *Val, BasicBlock *BBFrom, // Figure out the possible values of the query BEFORE this branch. if (!hasBlockValue(Val, BBFrom)) { - block_value_stack.push(std::make_pair(BBFrom, Val)); + BlockValueStack.push(std::make_pair(BBFrom, Val)); return false; } @@ -872,7 +875,7 @@ bool LazyValueInfoCache::getEdgeValue(Value *Val, BasicBlock *BBFrom, Result = getBlockValue(Val, BBFrom); return true; } - block_value_stack.push(std::make_pair(BBFrom, Val)); + BlockValueStack.push(std::make_pair(BBFrom, Val)); return false; } @@ -880,7 +883,7 @@ LVILatticeVal LazyValueInfoCache::getValueInBlock(Value *V, BasicBlock *BB) { DEBUG(dbgs() << "LVI Getting block end value " << *V << " at '" << BB->getName() << "'\n"); - block_value_stack.push(std::make_pair(BB, V)); + BlockValueStack.push(std::make_pair(BB, V)); solve(); LVILatticeVal Result = getBlockValue(V, BB);