diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 2081811f0d1..5e5e8b77022 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -728,7 +728,7 @@ namespace { bool processNonLocalLoad(LoadInst* L, SmallVectorImpl &toErase); bool processBlock(DomTreeNode* DTN); - Value *GetValueForBlock(BasicBlock *BB, LoadInst* orig, + Value *GetValueForBlock(BasicBlock *BB, Instruction* orig, DenseMap &Phis, bool top_level = false); void dump(DenseMap& d); @@ -789,7 +789,7 @@ bool GVN::isSafeReplacement(PHINode* p, Instruction* inst) { /// GetValueForBlock - Get the value to use within the specified basic block. /// available values are in Phis. -Value *GVN::GetValueForBlock(BasicBlock *BB, LoadInst* orig, +Value *GVN::GetValueForBlock(BasicBlock *BB, Instruction* orig, DenseMap &Phis, bool top_level) { @@ -837,7 +837,11 @@ Value *GVN::GetValueForBlock(BasicBlock *BB, LoadInst* orig, Value* v = CollapsePhi(PN); if (!v) { // Cache our phi construction results - phiMap[orig->getPointerOperand()].insert(PN); + if (LoadInst* L = dyn_cast(orig)) + phiMap[L->getPointerOperand()].insert(PN); + else + phiMap[orig].insert(PN); + return PN; }