Index: lib/Analysis/LazyValueInfo.cpp =================================================================== --- lib/Analysis/LazyValueInfo.cpp +++ lib/Analysis/LazyValueInfo.cpp @@ -398,7 +398,7 @@ bool getBlockValue(ValueLatticeElement &Result, Value *Val, BasicBlock *BB); bool getEdgeValue(Value *V, BasicBlock *F, BasicBlock *T, - ValueLatticeElement &Result, Instruction *CxtI = nullptr); + ValueLatticeElement &Result); // These methods process one work item and may add more. A false value // returned means that the work item was not completely processed and must @@ -761,10 +761,7 @@ BasicBlock *PhiBB = PN->getIncomingBlock(i); Value *PhiVal = PN->getIncomingValue(i); ValueLatticeElement 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. - if (!getEdgeValue(PhiVal, PhiBB, BB, EdgeResult, PN)) + if (!getEdgeValue(PhiVal, PhiBB, BB, EdgeResult)) // Explore that input, then return here return false; @@ -1463,8 +1460,7 @@ /// the basic block if the edge does not constrain Val. bool LazyValueInfoImpl::getEdgeValue(Value *Val, BasicBlock *BBFrom, BasicBlock *BBTo, - ValueLatticeElement &Result, - Instruction *CxtI) { + ValueLatticeElement &Result) { // If already a constant, there is nothing to compute. if (Constant *VC = dyn_cast(Val)) { Result = ValueLatticeElement::get(VC); @@ -1490,15 +1486,6 @@ // Try to intersect ranges of the BB and the constraint on the edge. intersectAssumeOrGuardBlockValueConstantRange(Val, InBlock, 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 - // LazyValueInfoImpl::getValueOnEdge, the context instruction is provided, - // but then the result is not cached. - intersectAssumeOrGuardBlockValueConstantRange(Val, InBlock, CxtI); Result = intersect(LocalResult, InBlock); return true; @@ -1547,12 +1534,13 @@ << "'\n"); ValueLatticeElement Result; - if (!getEdgeValue(V, FromBB, ToBB, Result, CxtI)) { + if (!getEdgeValue(V, FromBB, ToBB, Result)) { solve(); - bool WasFastQuery = getEdgeValue(V, FromBB, ToBB, Result, CxtI); + bool WasFastQuery = getEdgeValue(V, FromBB, ToBB, Result); (void)WasFastQuery; assert(WasFastQuery && "More work to do after problem solved?"); } + intersectAssumeOrGuardBlockValueConstantRange(V, Result, CxtI); LLVM_DEBUG(dbgs() << " Result = " << Result << "\n"); return Result;