diff options
-rw-r--r-- | llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h | 4 | ||||
-rw-r--r-- | llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | 27 |
2 files changed, 13 insertions, 18 deletions
diff --git a/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h b/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h index b92dec9a7bc..b19dabbfc32 100644 --- a/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h +++ b/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h @@ -341,13 +341,13 @@ private: AliasAnalysis &AA; AssumptionCache &AC; const TargetLibraryInfo &TLI; - DominatorTree *DT; + DominatorTree &DT; PredIteratorCache PredCache; public: MemoryDependenceResults(AliasAnalysis &AA, AssumptionCache &AC, const TargetLibraryInfo &TLI, - DominatorTree *DT = nullptr) + DominatorTree &DT) : AA(AA), AC(AC), TLI(TLI), DT(DT) {} /// Returns the instruction on which a memory operation depends. diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index c99d206167c..0890489c557 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -373,7 +373,7 @@ MemoryDependenceResults::getInvariantGroupPointerDependency(LoadInst *LI, for (Use &Us : Ptr->uses()) { auto *U = dyn_cast<Instruction>(Us.getUser()); - if (!U || U == LI || !DT->dominates(U, LI)) + if (!U || U == LI || !DT.dominates(U, LI)) continue; if (auto *BCI = dyn_cast<BitCastInst>(U)) { @@ -642,7 +642,7 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom( ModRefInfo MR = AA.getModRefInfo(Inst, MemLoc); // If necessary, perform additional analysis. if (MR == MRI_ModRef) - MR = AA.callCapturesBefore(Inst, MemLoc, DT, &OBB); + MR = AA.callCapturesBefore(Inst, MemLoc, &DT, &OBB); switch (MR) { case MRI_NoModRef: // If the call has no effect on the queried pointer, just ignore it. @@ -1127,10 +1127,7 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB( continue; } - if (!DT) { - Result.push_back( - NonLocalDepResult(Entry.getBB(), MemDepResult::getUnknown(), Addr)); - } else if (DT->isReachableFromEntry(Entry.getBB())) { + if (DT.isReachableFromEntry(Entry.getBB())) { Result.push_back( NonLocalDepResult(Entry.getBB(), Entry.getResult(), Addr)); } @@ -1199,11 +1196,7 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB( // If we got a Def or Clobber, add this to the list of results. if (!Dep.isNonLocal()) { - if (!DT) { - Result.push_back(NonLocalDepResult(BB, MemDepResult::getUnknown(), - Pointer.getAddr())); - continue; - } else if (DT->isReachableFromEntry(BB)) { + if (DT.isReachableFromEntry(BB)) { Result.push_back(NonLocalDepResult(BB, Dep, Pointer.getAddr())); continue; } @@ -1274,7 +1267,7 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB( // 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.PHITranslateValue(BB, Pred, DT, /*MustDominate=*/false); + PredPointer.PHITranslateValue(BB, Pred, &DT, /*MustDominate=*/false); Value *PredPtrVal = PredPointer.getAddr(); // Check to see if we have already visited this pred block with another @@ -1397,7 +1390,7 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB( continue; assert((GotWorklistLimit || I.getResult().isNonLocal() || - !DT->isReachableFromEntry(BB)) && + !DT.isReachableFromEntry(BB)) && "Should only be here with transparent block"); foundBlock = true; I.setResult(MemDepResult::getUnknown()); @@ -1666,7 +1659,7 @@ MemoryDependenceAnalysis::run(Function &F, AnalysisManager<Function> &AM) { auto &AA = AM.getResult<AAManager>(F); auto &AC = AM.getResult<AssumptionAnalysis>(F); auto &TLI = AM.getResult<TargetLibraryAnalysis>(F); - auto *DT = AM.getCachedResult<DominatorTreeAnalysis>(F); + auto &DT = AM.getResult<DominatorTreeAnalysis>(F); return MemoryDependenceResults(AA, AC, TLI, DT); } @@ -1676,6 +1669,7 @@ INITIALIZE_PASS_BEGIN(MemoryDependenceWrapperPass, "memdep", "Memory Dependence Analysis", false, true) INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) +INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass) INITIALIZE_PASS_END(MemoryDependenceWrapperPass, "memdep", "Memory Dependence Analysis", false, true) @@ -1692,6 +1686,7 @@ void MemoryDependenceWrapperPass::releaseMemory() { void MemoryDependenceWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); AU.addRequired<AssumptionCacheTracker>(); + AU.addRequired<DominatorTreeWrapperPass>(); AU.addRequiredTransitive<AAResultsWrapperPass>(); AU.addRequiredTransitive<TargetLibraryInfoWrapperPass>(); } @@ -1700,8 +1695,8 @@ bool MemoryDependenceWrapperPass::runOnFunction(Function &F) { auto &AA = getAnalysis<AAResultsWrapperPass>().getAAResults(); auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F); auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(); - auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>(); - MemDep.emplace(AA, AC, TLI, DTWP ? &DTWP->getDomTree() : nullptr); + auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree(); + MemDep.emplace(AA, AC, TLI, DT); return false; } |