X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAnalysis%2FLazyValueInfo.cpp;h=281ff89bfe46f869a6ba4d654bf97f717c201c87;hb=7116af637cf6e3e49b6329263fb1535fb9de73bc;hp=0c38dc6fe03559e27a9c2b12f10ae4d59dacf104;hpb=570e52c6f17d8819ee4c8595fc79d17a6dc51dd9;p=oota-llvm.git diff --git a/lib/Analysis/LazyValueInfo.cpp b/lib/Analysis/LazyValueInfo.cpp index 0c38dc6fe03..281ff89bfe4 100644 --- a/lib/Analysis/LazyValueInfo.cpp +++ b/lib/Analysis/LazyValueInfo.cpp @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "lazy-value-info" #include "llvm/Analysis/LazyValueInfo.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/STLExtras.h" @@ -34,6 +33,8 @@ using namespace llvm; using namespace PatternMatch; +#define DEBUG_TYPE "lazy-value-info" + char LazyValueInfo::ID = 0; INITIALIZE_PASS_BEGIN(LazyValueInfo, "lazy-value-info", "Lazy Value Information Analysis", false, true) @@ -499,8 +500,23 @@ bool LazyValueInfoCache::solveBlockValue(Value *Val, BasicBlock *BB) { // cache needs updating, i.e. if we have solve a new value or not. OverDefinedCacheUpdater ODCacheUpdater(Val, BB, BBLV, this); - // If we've already computed this block's value, return it. - if (!BBLV.isUndefined()) { + // Once this BB is encountered, Val's value for this BB will not be Undefined + // any longer. When we encounter this BB again, if Val's value is Overdefined, + // we need to compute its value again. + // + // For example, considering this control flow, + // BB1->BB2, BB1->BB3, BB2->BB3, BB2->BB4 + // + // Suppose we have "icmp slt %v, 0" in BB1, and "icmp sgt %v, 0" in BB3. At + // the very beginning, when analyzing edge BB2->BB3, we don't know %v's value + // in BB2, and the data flow algorithm tries to compute BB2's predecessors, so + // then we know %v has negative value on edge BB1->BB2. And then we return to + // check BB2 again, and at this moment BB2 has Overdefined value for %v in + // BB2. So we should have to follow data flow propagation algorithm to get the + // value on edge BB1->BB2 propagated to BB2, and finally %v on BB2 has a + // constant range describing a negative value. + + if (!BBLV.isUndefined() && !BBLV.isOverdefined()) { DEBUG(dbgs() << " reuse BB '" << BB->getName() << "' val=" << BBLV <<'\n'); // Since we're reusing a cached value here, we don't need to update the