diff --git a/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h b/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h --- a/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h +++ b/llvm/include/llvm/Transforms/Scalar/MemCpyOptimizer.h @@ -41,7 +41,6 @@ class MemCpyOptPass : public PassInfoMixin { MemoryDependenceResults *MD = nullptr; - TargetLibraryInfo *TLI = nullptr; AAResults *AA = nullptr; AssumptionCache *AC = nullptr; DominatorTree *DT = nullptr; @@ -54,9 +53,8 @@ PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); // Glue for the old PM. - bool runImpl(Function &F, MemoryDependenceResults *MD, TargetLibraryInfo *TLI, - AAResults *AA, AssumptionCache *AC, DominatorTree *DT, - MemorySSA *MSSA); + bool runImpl(Function &F, MemoryDependenceResults *MD, AAResults *AA, + AssumptionCache *AC, DominatorTree *DT, MemorySSA *MSSA); private: // Helper functions diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp --- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -26,7 +26,6 @@ #include "llvm/Analysis/MemoryLocation.h" #include "llvm/Analysis/MemorySSA.h" #include "llvm/Analysis/MemorySSAUpdater.h" -#include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/Argument.h" #include "llvm/IR/BasicBlock.h" @@ -281,7 +280,6 @@ AU.addRequired(); AU.addPreserved(); AU.addPreserved(); - AU.addRequired(); if (!EnableMemorySSA) AU.addRequired(); AU.addPreserved(); @@ -1548,9 +1546,6 @@ /// Transforms memmove calls to memcpy calls when the src/dst are guaranteed /// not to alias. bool MemCpyOptPass::processMemMove(MemMoveInst *M) { - if (!TLI->has(LibFunc_memmove)) - return false; - // See if the pointers alias. if (!AA->isNoAlias(MemoryLocation::getForDest(M), MemoryLocation::getForSource(M))) @@ -1720,7 +1715,6 @@ PreservedAnalyses MemCpyOptPass::run(Function &F, FunctionAnalysisManager &AM) { auto *MD = !EnableMemorySSA ? &AM.getResult(F) : AM.getCachedResult(F); - auto &TLI = AM.getResult(F); auto *AA = &AM.getResult(F); auto *AC = &AM.getResult(F); auto *DT = &AM.getResult(F); @@ -1728,7 +1722,7 @@ : AM.getCachedResult(F); bool MadeChange = - runImpl(F, MD, &TLI, AA, AC, DT, MSSA ? &MSSA->getMSSA() : nullptr); + runImpl(F, MD, AA, AC, DT, MSSA ? &MSSA->getMSSA() : nullptr); if (!MadeChange) return PreservedAnalyses::all(); @@ -1742,23 +1736,16 @@ } bool MemCpyOptPass::runImpl(Function &F, MemoryDependenceResults *MD_, - TargetLibraryInfo *TLI_, AliasAnalysis *AA_, - AssumptionCache *AC_, DominatorTree *DT_, - MemorySSA *MSSA_) { + AliasAnalysis *AA_, AssumptionCache *AC_, + DominatorTree *DT_, MemorySSA *MSSA_) { bool MadeChange = false; MD = MD_; - TLI = TLI_; AA = AA_; AC = AC_; DT = DT_; MSSA = MSSA_; MemorySSAUpdater MSSAU_(MSSA_); MSSAU = MSSA_ ? &MSSAU_ : nullptr; - // If we don't have at least memset and memcpy, there is little point of doing - // anything here. These are required by a freestanding implementation, so if - // even they are disabled, there is no point in trying hard. - if (!TLI->has(LibFunc_memset) || !TLI->has(LibFunc_memcpy)) - return false; while (true) { if (!iterateOnFunction(F)) @@ -1781,7 +1768,6 @@ auto *MDWP = !EnableMemorySSA ? &getAnalysis() : getAnalysisIfAvailable(); - auto *TLI = &getAnalysis().getTLI(F); auto *AA = &getAnalysis().getAAResults(); auto *AC = &getAnalysis().getAssumptionCache(F); auto *DT = &getAnalysis().getDomTree(); @@ -1789,6 +1775,6 @@ ? &getAnalysis() : getAnalysisIfAvailable(); - return Impl.runImpl(F, MDWP ? & MDWP->getMemDep() : nullptr, TLI, AA, AC, DT, + return Impl.runImpl(F, MDWP ? &MDWP->getMemDep() : nullptr, AA, AC, DT, MSSAWP ? &MSSAWP->getMSSA() : nullptr); }