Index: llvm/include/llvm/Transforms/Scalar/GVN.h =================================================================== --- llvm/include/llvm/Transforms/Scalar/GVN.h +++ llvm/include/llvm/Transforms/Scalar/GVN.h @@ -45,9 +45,7 @@ class ImplicitControlFlowTracking; class LoadInst; class LoopInfo; -class MemDepResult; class MemoryAccess; -class MemoryDependenceResults; class MemoryLocation; class MemorySSA; class MemorySSAUpdater; @@ -78,7 +76,6 @@ Optional AllowLoadPRE = None; Optional AllowLoadInLoopPRE = None; Optional AllowLoadPRESplitBackedge = None; - Optional AllowMemDep = None; Optional AllowMemorySSA = None; GVNOptions() = default; @@ -106,12 +103,6 @@ return *this; } - /// Enables or disables use of MemDepAnalysis. - GVNOptions &setMemDep(bool MemDep) { - AllowMemDep = MemDep; - return *this; - } - /// Enables or disables use of MemorySSA. GVNOptions &setMemorySSA(bool MemSSA) { AllowMemorySSA = MemSSA; @@ -146,13 +137,11 @@ DominatorTree &getDominatorTree() const { return *DT; } AAResults *getAliasAnalysis() const { return VN.getAliasAnalysis(); } - MemoryDependenceResults &getMemDep() const { return *MD; } bool isPREEnabled() const; bool isLoadPREEnabled() const; bool isLoadInLoopPREEnabled() const; bool isLoadPRESplitBackedgeEnabled() const; - bool isMemDepEnabled() const; bool isMemorySSAEnabled() const; /// This class holds the mapping between values and value numbers. It is used @@ -184,7 +173,6 @@ PhiTranslateMap PhiTranslateTable; AAResults *AA = nullptr; - MemoryDependenceResults *MD = nullptr; MemorySSA *MSSA = nullptr; DominatorTree *DT = nullptr; @@ -227,7 +215,6 @@ void erase(Value *v); void setAliasAnalysis(AAResults *A) { AA = A; } AAResults *getAliasAnalysis() const { return AA; } - void setMemDep(MemoryDependenceResults *M) { MD = M; } void setMemorySSA(MemorySSA *M) { MSSA = M; } void setDomTree(DominatorTree *D) { DT = D; } uint32_t getNextUnusedValueNumber() { return nextValueNumber; } @@ -238,7 +225,6 @@ friend class gvn::GVNLegacyPass; friend struct DenseMapInfo; - MemoryDependenceResults *MD = nullptr; DominatorTree *DT = nullptr; const TargetLibraryInfo *TLI = nullptr; AssumptionCache *AC = nullptr; @@ -281,8 +267,7 @@ using UnavailBlkVect = SmallVector; bool runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT, - const TargetLibraryInfo &RunTLI, AAResults &RunAA, - MemoryDependenceResults *RunMD, LoopInfo *LI, + const TargetLibraryInfo &RunTLI, AAResults &RunAA, LoopInfo *LI, OptimizationRemarkEmitter *ORE, MemorySSA *MSSA = nullptr); /// Push a new Value to the LeaderTable onto the list for its value number. @@ -371,7 +356,6 @@ // Helper functions of redundant load elimination bool processLoad(LoadInst *L); - bool processNonLocalLoad(LoadInst *L); bool processNonLocalLoad(LoadInst *L, SmallVectorImpl &Deps); bool processAssumeIntrinsic(AssumeInst *II); Index: llvm/lib/Passes/PassBuilder.cpp =================================================================== --- llvm/lib/Passes/PassBuilder.cpp +++ llvm/lib/Passes/PassBuilder.cpp @@ -819,8 +819,6 @@ Result.setLoadPRE(Enable); } else if (ParamName == "split-backedge-load-pre") { Result.setLoadPRESplitBackedge(Enable); - } else if (ParamName == "memdep") { - Result.setMemDep(Enable); } else if (ParamName == "memoryssa") { Result.setMemorySSA(Enable); } else { Index: llvm/lib/Transforms/Scalar/GVN.cpp =================================================================== --- llvm/lib/Transforms/Scalar/GVN.cpp +++ llvm/lib/Transforms/Scalar/GVN.cpp @@ -35,7 +35,6 @@ #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/MemoryBuiltins.h" -#include "llvm/Analysis/MemoryDependenceAnalysis.h" #include "llvm/Analysis/MemorySSA.h" #include "llvm/Analysis/MemorySSAUpdater.h" #include "llvm/Analysis/OptimizationRemarkEmitter.h" @@ -491,119 +490,21 @@ uint32_t GVNPass::ValueTable::lookupOrAddCall(CallInst *C) { if (AA->doesNotAccessMemory(C)) { - Expression exp = createCallExpr(C); - uint32_t e = assignExpNewValueNum(exp).first; - valueNumbering[C] = e; - return e; + Expression Exp = createCallExpr(C); + uint32_t E = assignExpNewValueNum(Exp).first; + valueNumbering[C] = E; + return E; } - if (MSSA) { - if (AA->onlyReadsMemory(C)) { - Expression E = createCallExpr(C); - addMemoryStateArg(C, E); - uint32_t VN = assignExpNewValueNum(E).first; - valueNumbering[C] = VN; - return VN; - } - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; - } - - if (MD && AA->onlyReadsMemory(C)) { - Expression exp = createCallExpr(C); - auto ValNum = assignExpNewValueNum(exp); - if (ValNum.second) { - valueNumbering[C] = ValNum.first; - return ValNum.first; - } - - MemDepResult local_dep = MD->getDependency(C); - - if (!local_dep.isDef() && !local_dep.isNonLocal()) { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; - } - - if (local_dep.isDef()) { - // For masked load/store intrinsics, the local_dep may actully be - // a normal load or store instruction. - CallInst *local_cdep = dyn_cast(local_dep.getInst()); - - if (!local_cdep || local_cdep->arg_size() != C->arg_size()) { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; - } - - for (unsigned i = 0, e = C->arg_size(); i < e; ++i) { - uint32_t c_vn = lookupOrAdd(C->getArgOperand(i)); - uint32_t cd_vn = lookupOrAdd(local_cdep->getArgOperand(i)); - if (c_vn != cd_vn) { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; - } - } - - uint32_t v = lookupOrAdd(local_cdep); - valueNumbering[C] = v; - return v; - } - - // Non-local case. - const MemoryDependenceResults::NonLocalDepInfo &deps = - MD->getNonLocalCallDependency(C); - // FIXME: Move the checking logic to MemDep! - CallInst* cdep = nullptr; - - // Check to see if we have a single dominating call instruction that is - // identical to C. - for (unsigned i = 0, e = deps.size(); i != e; ++i) { - const NonLocalDepEntry *I = &deps[i]; - if (I->getResult().isNonLocal()) - continue; - - // We don't handle non-definitions. If we already have a call, reject - // instruction dependencies. - if (!I->getResult().isDef() || cdep != nullptr) { - cdep = nullptr; - break; - } - - CallInst *NonLocalDepCall = dyn_cast(I->getResult().getInst()); - // FIXME: All duplicated with non-local case. - if (NonLocalDepCall && DT->properlyDominates(I->getBB(), C->getParent())){ - cdep = NonLocalDepCall; - continue; - } - - cdep = nullptr; - break; - } - - if (!cdep) { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; - } - - if (cdep->arg_size() != C->arg_size()) { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; - } - for (unsigned i = 0, e = C->arg_size(); i < e; ++i) { - uint32_t c_vn = lookupOrAdd(C->getArgOperand(i)); - uint32_t cd_vn = lookupOrAdd(cdep->getArgOperand(i)); - if (c_vn != cd_vn) { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; - } - } - - uint32_t v = lookupOrAdd(cdep); - valueNumbering[C] = v; - return v; - } else { - valueNumbering[C] = nextValueNumber; - return nextValueNumber++; + if (MSSA && AA->onlyReadsMemory(C)) { + Expression E = createCallExpr(C); + addMemoryStateArg(C, E); + uint32_t VN = assignExpNewValueNum(E).first; + valueNumbering[C] = VN; + return VN; } + valueNumbering[C] = nextValueNumber; + return nextValueNumber++; } uint32_t GVNPass::ValueTable::lookupOrAddLoadStore(Instruction *I) { @@ -797,10 +698,6 @@ GVNEnableSplitBackedgeInLoadPRE); } -bool GVNPass::isMemDepEnabled() const { - return Options.AllowMemDep.value_or(GVNEnableMemDep); -} - bool GVNPass::isMemorySSAEnabled() const { return Options.AllowMemorySSA.getValueOr(GVNEnableMemorySSA); } @@ -814,14 +711,12 @@ auto &DT = AM.getResult(F); auto &TLI = AM.getResult(F); auto &AA = AM.getResult(F); - auto *MemDep = - isMemDepEnabled() ? &AM.getResult(F) : nullptr; auto *LI = AM.getCachedResult(F); auto *MSSA = isMemorySSAEnabled() ? &AM.getResult(F) : nullptr; auto &ORE = AM.getResult(F); - bool Changed = runImpl(F, AC, DT, TLI, AA, MemDep, LI, &ORE, - MSSA ? &MSSA->getMSSA() : nullptr); + bool Changed = + runImpl(F, AC, DT, TLI, AA, LI, &ORE, MSSA ? &MSSA->getMSSA() : nullptr); if (!Changed) return PreservedAnalyses::all(); PreservedAnalyses PA; @@ -847,8 +742,6 @@ if (Options.AllowLoadPRESplitBackedge != None) OS << (Options.AllowLoadPRESplitBackedge.getValue() ? "" : "no-") << "split-backedge-load-pre;"; - if (Options.AllowMemDep != None) - OS << (Options.AllowMemDep.getValue() ? "" : "no-") << "memdep;"; if (Options.AllowMemorySSA != None) OS << (Options.AllowMemorySSA.getValue() ? "" : "no-") << "memoryssa"; OS << ">"; @@ -1084,8 +977,6 @@ // tracks. It is potentially possible to remove the load from the table, // but then there all of the operations based on it would need to be // rehashed. Just leave the dead load around. - if (gvn.isMemDepEnabled()) - gvn.getMemDep().removeInstruction(CoercedLoad); LLVM_DEBUG(dbgs() << "GVN COERCED NONLOCAL LOAD:\nOffset: " << Offset << " " << *getCoercedLoadValue() << '\n' << *Res << '\n' @@ -1278,18 +1169,9 @@ Load->isAtomic() <= DepLoad->isAtomic()) { Type *LoadType = Load->getType(); int Offset = Dep.Offset; - if (MD) { - // If MD reported clobber, check it was nested. - if (canCoerceMustAliasedValueToLoad(DepLoad, LoadType, DL)) { - const auto ClobberOff = MD->getClobberOffset(DepLoad); - // GVN has no deal with a negative offset. - Offset = (ClobberOff == None || *ClobberOff < 0) ? -1 : *ClobberOff; - } - } else { - if (!canCoerceMustAliasedValueToLoad(DepLoad, LoadType, DL) || - Offset < 0) - Offset = -1; - } + if (!canCoerceMustAliasedValueToLoad(DepLoad, LoadType, DL) || + Offset < 0) + Offset = -1; if (Offset == -1) Offset = analyzeLoadFromClobberingLoad(LoadType, Address, DepLoad, DL); @@ -1482,8 +1364,6 @@ // Add the newly created load. ValuesPerBlock.push_back( AvailableValueInBlock::get(UnavailableBlock, NewLoad)); - if (MD) - MD->invalidateCachedPointerInfo(LoadPtr); LLVM_DEBUG(dbgs() << "GVN INSERTED " << *NewLoad << '\n'); } @@ -1494,8 +1374,6 @@ V->takeName(Load); if (Instruction *I = dyn_cast(V)) I->setDebugLoc(Load->getDebugLoc()); - if (MD && V->getType()->isPtrOrPtrVectorTy()) - MD->invalidateCachedPointerInfo(V); markInstructionForDeletion(Load); ORE->emit([&]() { return OptimizationRemark(DEBUG_TYPE, "LoadPRE", Load) @@ -1837,42 +1715,8 @@ /// Attempt to eliminate a load whose dependencies are /// non-local by performing PHI construction. -bool GVNPass::processNonLocalLoad(LoadInst *Load) { - // non-local speculations are not allowed under asan. - if (Load->getParent()->getParent()->hasFnAttribute( - Attribute::SanitizeAddress) || - Load->getParent()->getParent()->hasFnAttribute( - Attribute::SanitizeHWAddress)) - return false; - - // Find the non-local dependencies of the load. - LoadDepVect Deps; - MD->getNonLocalPointerDependency(Load, Deps); - - // If we had to process more than one hundred blocks to find the - // dependencies, this load isn't worth worrying about. Optimizing - // it will be too expensive. - unsigned NumDeps = Deps.size(); - if (NumDeps > MaxNumDeps) - return false; - - SmallVector MemVals; - for (const NonLocalDepResult &Dep : Deps) { - Value *Address = Dep.getAddress(); - BasicBlock *BB = Dep.getBB(); - Instruction *Inst = Dep.getResult().getInst(); - if (Dep.getResult().isClobber()) - MemVals.emplace_back(ReachingMemVal::getClobber(Address, Inst)); - else if (Dep.getResult().isDef()) - MemVals.emplace_back(ReachingMemVal::getDef(Address, Inst)); - else - MemVals.emplace_back(ReachingMemVal::getUnknown(BB, Address, Inst)); - } - return processNonLocalLoad(Load, MemVals); -} - -bool GVNPass ::processNonLocalLoad(LoadInst *Load, - SmallVectorImpl &Deps) { +bool GVNPass::processNonLocalLoad(LoadInst *Load, + SmallVectorImpl &Deps) { // If we had a phi translation failure, we'll have a single entry which is a // clobber in the current block. Reject this early. if (Deps.size() == 1 && Deps[0].Kind == DepKind::Other) { @@ -1920,8 +1764,6 @@ // to propagate Load's DebugLoc because Load may not post-dominate I. if (Load->getDebugLoc() && Load->getParent() == I->getParent()) I->setDebugLoc(Load->getDebugLoc()); - if (MD && V->getType()->isPtrOrPtrVectorTy()) - MD->invalidateCachedPointerInfo(V); markInstructionForDeletion(Load); ++NumGVNLoad; reportLoadElim(Load, V, ORE); @@ -2589,7 +2431,7 @@ /// Attempt to eliminate a load, first by eliminating it /// locally, and then attempting non-local elimination if that fails. bool GVNPass::processLoad(LoadInst *L) { - if (!MD && !MSSAU) + if (!MSSAU) return false; // This code hasn't been audited for ordered or volatile memory access @@ -2601,35 +2443,15 @@ return true; } - ReachingMemVal MemVal = ReachingMemVal::getUnknown(nullptr, nullptr); - if (MD) { - // ... to a pointer that has been loaded from before... - MemDepResult Dep = MD->getDependency(L); - - // If it is defined in another block, try harder. - if (Dep.isNonLocal()) - return processNonLocalLoad(L); - - // Only handle the local case below - if (Dep.isDef()) - MemVal = ReachingMemVal::getDef(L->getPointerOperand(), Dep.getInst()); - else if (Dep.isClobber()) - MemVal = - ReachingMemVal::getClobber(L->getPointerOperand(), Dep.getInst()); - } else { - SmallVector MemVals; - if (!findReachingValuesForLoad(L, *MSSAU->getMemorySSA(), *AA, MemVals)) - return false; // Too many dependencies. - assert(MemVals.size() && "Expected at least an unknown value"); - if (MemVals.size() > 1 || MemVals[0].Block != L->getParent()) - return processNonLocalLoad(L, MemVals); - - // Only handle the local case below - MemVal = MemVals[0]; - } + SmallVector MemVals; + if (!findReachingValuesForLoad(L, *MSSAU->getMemorySSA(), *AA, MemVals)) + return false; // Too many dependencies. + assert(MemVals.size() && "Expected at least an unknown value"); + if (MemVals.size() > 1 || MemVals[0].Block != L->getParent()) + return processNonLocalLoad(L, MemVals); Value *Address = L->getPointerOperand(); - if (MemVal.Kind == DepKind::Other && !isa(Address)) { + if (MemVals[0].Kind == DepKind::Other && !isa(Address)) { LLVM_DEBUG( // fast print dep, using operator<< on instruction is too slow. dbgs() << "GVN: load "; L->printAsOperand(dbgs()); @@ -2638,7 +2460,7 @@ } AvailableValue AV; - if (AnalyzeLoadAvailability(L, MemVal, Address, AV)) { + if (AnalyzeLoadAvailability(L, MemVals[0], Address, AV)) { Value *AvailableValue = AV.MaterializeAdjustedValue(L, L, *this); // Replace the load! @@ -2648,10 +2470,6 @@ MSSAU->removeMemoryAccess(L); ++NumGVNLoad; reportLoadElim(L, AvailableValue, ORE); - // Tell MDA to reexamine the reused pointer since we might have more - // information after forwarding it. - if (MD && AvailableValue->getType()->isPtrOrPtrVectorTy()) - MD->invalidateCachedPointerInfo(AvailableValue); return true; } @@ -2711,25 +2529,7 @@ Vals = Vals->Next; } - if (AA->doesNotAccessMemory(Call)) - return true; - - if (!MD || !AA->onlyReadsMemory(Call)) - return false; - - MemDepResult local_dep = MD->getDependency(Call); - if (!local_dep.isNonLocal()) - return false; - - const MemoryDependenceResults::NonLocalDepInfo &deps = - MD->getNonLocalCallDependency(Call); - - // Check to see if the Call has no function local clobber. - for (const NonLocalDepEntry &D : deps) { - if (D.getResult().isNonFuncLocal()) - return true; - } - return false; + return AA->doesNotAccessMemory(Call); } /// Translate value number \p Num using phis, so that it has the values of @@ -2958,9 +2758,6 @@ Changed |= NumReplacements > 0; NumGVNEqProp += NumReplacements; - // Cached information for anything that uses LHS will be invalid. - if (MD) - MD->invalidateCachedPointerInfo(LHS); } // Now try to deduce additional equalities from this one. For example, if @@ -3021,9 +2818,6 @@ Root.getStart()); Changed |= NumReplacements > 0; NumGVNEqProp += NumReplacements; - // Cached information for anything that uses NotCmp will be invalid. - if (MD) - MD->invalidateCachedPointerInfo(NotCmp); } } // Ensure that any instruction in scope that gets the "A < B" value number @@ -3066,8 +2860,6 @@ Changed = true; } if (Changed) { - if (MD && V->getType()->isPtrOrPtrVectorTy()) - MD->invalidateCachedPointerInfo(V); ++NumGVNSimpl; return true; } @@ -3176,8 +2968,6 @@ // Remove it! patchAndReplaceAllUsesWith(I, Repl); - if (MD && Repl->getType()->isPtrOrPtrVectorTy()) - MD->invalidateCachedPointerInfo(Repl); markInstructionForDeletion(I); return true; } @@ -3185,19 +2975,17 @@ /// runOnFunction - This is the main transformation entry point for a function. bool GVNPass::runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT, const TargetLibraryInfo &RunTLI, AAResults &RunAA, - MemoryDependenceResults *RunMD, LoopInfo *LI, - OptimizationRemarkEmitter *RunORE, MemorySSA *MSSA) { + LoopInfo *LI, OptimizationRemarkEmitter *RunORE, + MemorySSA *MSSA) { AC = &RunAC; DT = &RunDT; VN.setDomTree(DT); TLI = &RunTLI; AA = &RunAA; VN.setAliasAnalysis(&RunAA); - MD = RunMD; ImplicitControlFlowTracking ImplicitCFT; ICF = &ImplicitCFT; this->LI = LI; - VN.setMemDep(MD); VN.setMemorySSA(MSSA); ORE = RunORE; InvalidBlockRPONumbers = true; @@ -3211,7 +2999,7 @@ // Merge unconditional branches, allowing PRE to catch more // optimization opportunities. for (BasicBlock &BB : llvm::make_early_inc_range(F)) { - bool removedBlock = MergeBlockIntoPredecessor(&BB, &DTU, LI, MSSAU, MD); + bool removedBlock = MergeBlockIntoPredecessor(&BB, &DTU, LI, MSSAU, nullptr); if (removedBlock) ++NumGVNBlocks; @@ -3296,7 +3084,6 @@ LLVM_DEBUG(dbgs() << "GVN removed: " << *I << '\n'); salvageKnowledge(I, AC); salvageDebugInfo(*I); - if (MD) MD->removeInstruction(I); if (MSSAU) MSSAU->removeMemoryAccess(I); LLVM_DEBUG(verifyRemoved(I)); @@ -3527,14 +3314,10 @@ addToLeaderTable(ValNo, Phi, CurrentBlock); Phi->setDebugLoc(CurInst->getDebugLoc()); CurInst->replaceAllUsesWith(Phi); - if (MD && Phi->getType()->isPtrOrPtrVectorTy()) - MD->invalidateCachedPointerInfo(Phi); VN.erase(CurInst); removeFromLeaderTable(ValNo, CurInst, CurrentBlock); LLVM_DEBUG(dbgs() << "GVN PRE removed: " << *CurInst << '\n'); - if (MD) - MD->removeInstruction(CurInst); if (MSSAU) MSSAU->removeMemoryAccess(CurInst); LLVM_DEBUG(verifyRemoved(CurInst)); @@ -3582,11 +3365,8 @@ BasicBlock *BB = SplitCriticalEdge( Pred, Succ, CriticalEdgeSplittingOptions(DT, LI, MSSAU).unsetPreserveLoopSimplify()); - if (BB) { - if (MD) - MD->invalidateCachedPredecessors(); + if (BB) InvalidBlockRPONumbers = true; - } return BB; } @@ -3603,11 +3383,8 @@ CriticalEdgeSplittingOptions(DT, LI, MSSAU)) != nullptr; } while (!toSplit.empty()); - if (Changed) { - if (MD) - MD->invalidateCachedPredecessors(); + if (Changed) InvalidBlockRPONumbers = true; - } return Changed; } @@ -3725,11 +3502,8 @@ for (BasicBlock *P : predecessors(B)) { if (!DeadBlocks.count(P)) continue; - for (PHINode &Phi : B->phis()) { + for (PHINode &Phi : B->phis()) Phi.setIncomingValueForBlock(P, PoisonValue::get(Phi.getType())); - if (MD) - MD->invalidateCachedPointerInfo(&Phi); - } } } } @@ -3788,11 +3562,8 @@ public: static char ID; // Pass identification, replacement for typeid - explicit GVNLegacyPass(bool MemDepAnalysis = GVNEnableMemDep, - bool MemSSAAnalysis = GVNEnableMemorySSA) - : FunctionPass(ID), Impl(GVNOptions() - .setMemDep(MemDepAnalysis) - .setMemorySSA(MemSSAAnalysis)) { + explicit GVNLegacyPass(bool MemSSAAnalysis = GVNEnableMemorySSA) + : FunctionPass(ID), Impl(GVNOptions().setMemorySSA(MemSSAAnalysis)) { initializeGVNLegacyPassPass(*PassRegistry::getPassRegistry()); } @@ -3806,9 +3577,6 @@ getAnalysis().getDomTree(), getAnalysis().getTLI(F), getAnalysis().getAAResults(), - Impl.isMemDepEnabled() - ? &getAnalysis().getMemDep() - : nullptr, LIWP ? &LIWP->getLoopInfo() : nullptr, &getAnalysis().getORE(), Impl.isMemorySSAEnabled() @@ -3821,8 +3589,6 @@ AU.addRequired(); AU.addRequired(); AU.addRequired(); - if (Impl.isMemDepEnabled()) - AU.addRequired(); if (Impl.isMemorySSAEnabled()) AU.addRequired(); AU.addRequired(); @@ -3843,7 +3609,6 @@ INITIALIZE_PASS_BEGIN(GVNLegacyPass, "gvn", "Global Value Numbering", false, false) INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker) INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass) -INITIALIZE_PASS_DEPENDENCY(MemoryDependenceWrapperPass) INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) Index: llvm/lib/Transforms/Scalar/GVNHoist.cpp =================================================================== --- llvm/lib/Transforms/Scalar/GVNHoist.cpp +++ llvm/lib/Transforms/Scalar/GVNHoist.cpp @@ -43,7 +43,6 @@ #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/GlobalsModRef.h" #include "llvm/Analysis/IteratedDominanceFrontier.h" -#include "llvm/Analysis/MemoryDependenceAnalysis.h" #include "llvm/Analysis/MemorySSA.h" #include "llvm/Analysis/MemorySSAUpdater.h" #include "llvm/Analysis/PostDominators.h" @@ -259,8 +258,8 @@ class GVNHoist { public: GVNHoist(DominatorTree *DT, PostDominatorTree *PDT, AliasAnalysis *AA, - MemoryDependenceResults *MD, MemorySSA *MSSA) - : DT(DT), PDT(PDT), AA(AA), MD(MD), MSSA(MSSA), + MemorySSA *MSSA) + : DT(DT), PDT(PDT), AA(AA), MSSA(MSSA), MSSAUpdater(std::make_unique(MSSA)) { MSSA->ensureOptimizedUses(); } @@ -280,7 +279,6 @@ DominatorTree *DT; PostDominatorTree *PDT; AliasAnalysis *AA; - MemoryDependenceResults *MD; MemorySSA *MSSA; std::unique_ptr MSSAUpdater; DenseMap DFSNumber; @@ -533,10 +531,9 @@ auto &DT = getAnalysis().getDomTree(); auto &PDT = getAnalysis().getPostDomTree(); auto &AA = getAnalysis().getAAResults(); - auto &MD = getAnalysis().getMemDep(); auto &MSSA = getAnalysis().getMSSA(); - GVNHoist G(&DT, &PDT, &AA, &MD, &MSSA); + GVNHoist G(&DT, &PDT, &AA, &MSSA); return G.run(F); } @@ -544,7 +541,6 @@ AU.addRequired(); AU.addRequired(); AU.addRequired(); - AU.addRequired(); AU.addRequired(); AU.addPreserved(); AU.addPreserved(); @@ -556,7 +552,6 @@ NumFuncArgs = F.arg_size(); VN.setDomTree(DT); VN.setAliasAnalysis(AA); - VN.setMemDep(MD); bool Res = false; // Perform DFS Numbering of instructions. unsigned BBI = 0; @@ -1022,8 +1017,6 @@ Repl->andIRFlags(I); combineKnownMetadata(Repl, I); I->replaceAllUsesWith(Repl); - // Also invalidate the Alias Analysis cache. - MD->removeInstruction(I); I->eraseFromParent(); } } @@ -1143,7 +1136,6 @@ // Move the instruction at the end of HoistPt. Instruction *Last = DestBB->getTerminator(); - MD->removeInstruction(Repl); Repl->moveBefore(Last); DFSNumber[Repl] = DFSNumber[Last]++; @@ -1240,9 +1232,8 @@ DominatorTree &DT = AM.getResult(F); PostDominatorTree &PDT = AM.getResult(F); AliasAnalysis &AA = AM.getResult(F); - MemoryDependenceResults &MD = AM.getResult(F); MemorySSA &MSSA = AM.getResult(F).getMSSA(); - GVNHoist G(&DT, &PDT, &AA, &MD, &MSSA); + GVNHoist G(&DT, &PDT, &AA, &MSSA); if (!G.run(F)) return PreservedAnalyses::all(); @@ -1256,7 +1247,6 @@ INITIALIZE_PASS_BEGIN(GVNHoistLegacyPass, "gvn-hoist", "Early GVN Hoisting of Expressions", false, false) -INITIALIZE_PASS_DEPENDENCY(MemoryDependenceWrapperPass) INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass) INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(PostDominatorTreeWrapperPass)