const_cast<Value *>(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
/// 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
// 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
/// 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))
if (!DT->dominates(Inst->getParent(), PredBB))
Addr = nullptr;
- return Addr == nullptr;
+ return Addr;
}
/// PHITranslateWithInsertion - PHI translate this value into the specified
// 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<Instruction>(InVal);
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();