diff --git a/llvm/include/llvm/Analysis/MemorySSA.h b/llvm/include/llvm/Analysis/MemorySSA.h --- a/llvm/include/llvm/Analysis/MemorySSA.h +++ b/llvm/include/llvm/Analysis/MemorySSA.h @@ -1272,11 +1272,11 @@ const_cast(Location.Ptr), OriginalAccess->getBlock()->getModule()->getDataLayout(), nullptr); - if (!Translator.translateValue(OriginalAccess->getBlock(), - DefIterator.getPhiArgBlock(), DT, true)) - if (Translator.getAddr() != CurrentPair.second.Ptr) - CurrentPair.second = - CurrentPair.second.getWithNewPtr(Translator.getAddr()); + if (Value *Addr = + Translator.translateValue(OriginalAccess->getBlock(), + DefIterator.getPhiArgBlock(), DT, true)) + if (Addr != CurrentPair.second.Ptr) + CurrentPair.second = CurrentPair.second.getWithNewPtr(Addr); // Mark size as unknown, if the location is not guaranteed to be // loop-invariant for any possible loop in the function. Setting the size diff --git a/llvm/include/llvm/Analysis/PHITransAddr.h b/llvm/include/llvm/Analysis/PHITransAddr.h --- a/llvm/include/llvm/Analysis/PHITransAddr.h +++ b/llvm/include/llvm/Analysis/PHITransAddr.h @@ -76,10 +76,9 @@ /// translateValue - PHI translate the current address up the CFG from /// CurBB to Pred, updating our state to reflect any needed changes. If - /// 'MustDominate' is true, the translated value must dominate - /// PredBB. This returns true on failure and sets Addr to null. - bool translateValue(BasicBlock *CurBB, BasicBlock *PredBB, - const DominatorTree *DT, bool MustDominate); + /// 'MustDominate' is true, the translated value must dominate PredBB. + Value *translateValue(BasicBlock *CurBB, BasicBlock *PredBB, + const DominatorTree *DT, bool MustDominate); /// translateWithInsertion - PHI translate this value into the specified /// predecessor block, inserting a computation of the value if it is diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -1298,8 +1298,8 @@ // Get the PHI translated pointer in this predecessor. This can fail if // not translatable, in which case the getAddr() returns null. PHITransAddr &PredPointer = PredList.back().second; - PredPointer.translateValue(BB, Pred, &DT, /*MustDominate=*/false); - Value *PredPtrVal = PredPointer.getAddr(); + Value *PredPtrVal = + PredPointer.translateValue(BB, Pred, &DT, /*MustDominate=*/false); // Check to see if we have already visited this pred block with another // pointer. If so, we can't do this lookup. This failure can occur diff --git a/llvm/lib/Analysis/PHITransAddr.cpp b/llvm/lib/Analysis/PHITransAddr.cpp --- a/llvm/lib/Analysis/PHITransAddr.cpp +++ b/llvm/lib/Analysis/PHITransAddr.cpp @@ -305,10 +305,10 @@ /// PHITranslateValue - PHI translate the current address up the CFG from /// CurBB to Pred, updating our state to reflect any needed changes. If -/// 'MustDominate' is true, the translated value must dominate -/// PredBB. This returns true on failure and sets Addr to null. -bool PHITransAddr::translateValue(BasicBlock *CurBB, BasicBlock *PredBB, - const DominatorTree *DT, bool MustDominate) { +/// 'MustDominate' is true, the translated value must dominate PredBB. +Value *PHITransAddr::translateValue(BasicBlock *CurBB, BasicBlock *PredBB, + const DominatorTree *DT, + bool MustDominate) { assert(DT || !MustDominate); assert(verify() && "Invalid PHITransAddr!"); if (DT && DT->isReachableFromEntry(PredBB)) @@ -323,7 +323,7 @@ if (!DT->dominates(Inst->getParent(), PredBB)) Addr = nullptr; - return Addr == nullptr; + return Addr; } /// PHITranslateWithInsertion - PHI translate this value into the specified @@ -362,8 +362,9 @@ // See if we have a version of this value already available and dominating // PredBB. If so, there is no need to insert a new instance of it. PHITransAddr Tmp(InVal, DL, AC); - if (!Tmp.translateValue(CurBB, PredBB, &DT, /*MustDominate=*/true)) - return Tmp.getAddr(); + if (Value *Addr = + Tmp.translateValue(CurBB, PredBB, &DT, /*MustDominate=*/true)) + return Addr; // We don't need to PHI translate values which aren't instructions. auto *Inst = dyn_cast(InVal); diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -465,7 +465,7 @@ if (PredAddr.needsPHITranslationFromBlock(B)) { if (!PredAddr.isPotentiallyPHITranslatable()) return false; - if (PredAddr.translateValue(B, Pred, DT, false)) + if (!PredAddr.translateValue(B, Pred, DT, false)) return false; } Value *TranslatedPtr = PredAddr.getAddr();