X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAnalysis%2FLazyValueInfo.cpp;h=c712c9f487d1260c01f5f1a62369e5745cd0fce5;hb=0f06462959bcf8224e72b7c739659292dddbdc87;hp=414aaab265a3c708e3e7c2d1b25220a4c26cb059;hpb=c75d43e0c0cc110d07bf7c8738fe5bf09b3be2ce;p=oota-llvm.git diff --git a/lib/Analysis/LazyValueInfo.cpp b/lib/Analysis/LazyValueInfo.cpp index 414aaab265a..c712c9f487d 100644 --- a/lib/Analysis/LazyValueInfo.cpp +++ b/lib/Analysis/LazyValueInfo.cpp @@ -27,7 +27,6 @@ #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/PatternMatch.h" #include "llvm/IR/ValueHandle.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetLibraryInfo.h" @@ -38,20 +37,6 @@ using namespace PatternMatch; #define DEBUG_TYPE "lazy-value-info" -// Experimentally derived threshold for the number of basic blocks lowered for -// lattice value overdefined. -static cl::opt -OverdefinedBBThreshold("lvi-overdefined-BB-threshold", - cl::init(1500), cl::Hidden, - cl::desc("Threshold of the number of basic blocks lowered for lattice value" - "'overdefined'.")); - -// Experimentally derived threshold for additional lowering lattice values -// overdefined per block. -static cl::opt -OverdefinedThreshold("lvi-overdefined-threshold", cl::init(10), cl::Hidden, - cl::desc("Threshold of lowering lattice value 'overdefined'.")); - char LazyValueInfo::ID = 0; INITIALIZE_PASS_BEGIN(LazyValueInfo, "lazy-value-info", "Lazy Value Information Analysis", false, true) @@ -363,9 +348,6 @@ namespace { const DataLayout *DL; /// An optional DT pointer. DominatorTree *DT; - /// A counter to record how many times Overdefined has been tried to be - /// lowered. - DenseMap LoweringOverdefinedTimes; friend struct LVIValueHandle; @@ -498,9 +480,6 @@ void LazyValueInfoCache::eraseBlock(BasicBlock *BB) { } void LazyValueInfoCache::solve() { - // Reset the counter of lowering overdefined value. - LoweringOverdefinedTimes.clear(); - while (!BlockValueStack.empty()) { std::pair &e = BlockValueStack.top(); if (solveBlockValue(e.second, e.first)) { @@ -559,7 +538,6 @@ bool LazyValueInfoCache::solveBlockValue(Value *Val, BasicBlock *BB) { // lattice value to overdefined, so that cycles will terminate and be // conservatively correct. BBLV.markOverdefined(); - ++LoweringOverdefinedTimes[BB]; Instruction *BBI = dyn_cast(Val); if (!BBI || BBI->getParent() != BB) { @@ -714,6 +692,9 @@ bool LazyValueInfoCache::solveBlockValuePHINode(LVILatticeVal &BBLV, BasicBlock *PhiBB = PN->getIncomingBlock(i); Value *PhiVal = PN->getIncomingValue(i); LVILatticeVal EdgeResult; + // Note that we can provide PN as the context value to getEdgeValue, even + // though the results will be cached, because PN is the value being used as + // the cache key in the caller. EdgesMissing |= !getEdgeValue(PhiVal, PhiBB, BB, EdgeResult, PN); if (EdgesMissing) continue; @@ -976,6 +957,9 @@ bool LazyValueInfoCache::getEdgeValue(Value *Val, BasicBlock *BBFrom, // Try to intersect ranges of the BB and the constraint on the edge. LVILatticeVal InBlock = getBlockValue(Val, BBFrom); + mergeAssumeBlockValueConstantRange(Val, InBlock, BBFrom->getTerminator()); + // See note on the use of the CxtI with mergeAssumeBlockValueConstantRange, + // and caching, below. mergeAssumeBlockValueConstantRange(Val, InBlock, CxtI); if (!InBlock.isConstantRange()) return true; @@ -993,6 +977,15 @@ bool LazyValueInfoCache::getEdgeValue(Value *Val, BasicBlock *BBFrom, // if we couldn't compute the value on the edge, use the value from the BB Result = getBlockValue(Val, BBFrom); + mergeAssumeBlockValueConstantRange(Val, Result, BBFrom->getTerminator()); + // We can use the context instruction (generically the ultimate instruction + // the calling pass is trying to simplify) here, even though the result of + // this function is generally cached when called from the solve* functions + // (and that cached result might be used with queries using a different + // context instruction), because when this function is called from the solve* + // functions, the context instruction is not provided. When called from + // LazyValueInfoCache::getValueOnEdge, the context instruction is provided, + // but then the result is not cached. mergeAssumeBlockValueConstantRange(Val, Result, CxtI); return true; }