llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lto Author: Alexey Bataev (alexey-bataev) <details> <summary>Changes</summary> This reverts commit 04c81a99735c04b2018eeb687e74f9860e1d0e1b. This patch causes massive perf regressions at all opt levels, from O0 to O3. At O0 with the debug info it creates lots of spills/reloads. At Higher opt level LoppVectorizer cannot vectorizer the expanded code, becausde it is not aware of the non-aliasing of the pointers. It also may increase register pressure. The pass should include cost modelling, should emit hints for the vectorizer. Without this, it should be disabled. --- Patch is 49.92 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/171452.diff 37 Files Affected: - (modified) clang/lib/CodeGen/BackendUtil.cpp (-6) - (modified) llvm/include/llvm/Analysis/RuntimeLibcallInfo.h (+5-17) - (modified) llvm/include/llvm/CodeGen/LibcallLoweringInfo.h (-68) - (modified) llvm/include/llvm/InitializePasses.h (-1) - (modified) llvm/lib/Analysis/RuntimeLibcallInfo.cpp (-16) - (modified) llvm/lib/CodeGen/CodeGen.cpp (-1) - (modified) llvm/lib/CodeGen/ExpandFp.cpp (+8-32) - (modified) llvm/lib/CodeGen/LibcallLoweringInfo.cpp (-42) - (modified) llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp (+17-36) - (modified) llvm/lib/LTO/LTOBackend.cpp (-6) - (modified) llvm/lib/Passes/PassRegistry.def (-1) - (modified) llvm/test/CodeGen/AArch64/O0-pipeline.ll (-2) - (modified) llvm/test/CodeGen/AArch64/O3-pipeline.ll (-2) - (modified) llvm/test/CodeGen/AMDGPU/llc-pipeline.ll (-10) - (modified) llvm/test/CodeGen/LoongArch/O0-pipeline.ll (-2) - (modified) llvm/test/CodeGen/LoongArch/opt-pipeline.ll (-2) - (modified) llvm/test/CodeGen/PowerPC/O0-pipeline.ll (-2) - (modified) llvm/test/CodeGen/PowerPC/O3-pipeline.ll (-2) - (modified) llvm/test/CodeGen/RISCV/O0-pipeline.ll (-2) - (modified) llvm/test/CodeGen/RISCV/O3-pipeline.ll (-2) - (modified) llvm/test/CodeGen/SPIRV/llc-pipeline.ll (-4) - (modified) llvm/test/CodeGen/X86/O0-pipeline.ll (-2) - (modified) llvm/test/CodeGen/X86/opt-pipeline.ll (-2) - (modified) llvm/test/Transforms/ExpandFp/AMDGPU/frem-inf.ll (+2-2) - (modified) llvm/test/Transforms/ExpandFp/AMDGPU/frem.ll (+1-1) - (removed) llvm/test/Transforms/ExpandFp/AMDGPU/missing-analysis.ll (-6) - (modified) llvm/test/Transforms/ExpandFp/AMDGPU/pass-parameters.ll (+8-8) - (modified) llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll (+1-1) - (modified) llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll (+1-1) - (modified) llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll (+1-1) - (modified) llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll (+1-1) - (modified) llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-optnone.ll (+1-1) - (modified) llvm/tools/llc/NewPMDriver.cpp (-12) - (modified) llvm/tools/llc/llc.cpp (-5) - (modified) llvm/tools/opt/NewPMDriver.cpp (+6-17) - (modified) llvm/tools/opt/NewPMDriver.h (+7-3) - (modified) llvm/tools/opt/optdriver.cpp (+7-12) ``````````diff diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 126005a5d93c2..df716e5bce23f 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -19,7 +19,6 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Analysis/GlobalsModRef.h" -#include "llvm/Analysis/RuntimeLibcallInfo.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Bitcode/BitcodeReader.h" @@ -656,11 +655,6 @@ bool EmitAssemblyHelper::AddEmitPasses(legacy::PassManager &CodeGenPasses, llvm::driver::createTLII(TargetTriple, CodeGenOpts.getVecLib())); CodeGenPasses.add(new TargetLibraryInfoWrapperPass(*TLII)); - const llvm::TargetOptions &Options = TM->Options; - CodeGenPasses.add(new RuntimeLibraryInfoWrapper( - TargetTriple, Options.ExceptionModel, Options.FloatABIType, - Options.EABIVersion, Options.MCOptions.ABIName, Options.VecLib)); - // Normal mode, emit a .s or .o file by running the code generator. Note, // this also adds codegenerator level optimization passes. CodeGenFileType CGFT = getCodeGenFileType(Action); diff --git a/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h b/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h index 609568ebc21a8..79737795e8291 100644 --- a/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h +++ b/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h @@ -22,12 +22,7 @@ class LLVM_ABI RuntimeLibraryAnalysis RuntimeLibraryAnalysis() = default; RuntimeLibraryAnalysis(RTLIB::RuntimeLibcallsInfo &&BaselineInfoImpl) : LibcallsInfo(std::move(BaselineInfoImpl)) {} - RuntimeLibraryAnalysis( - const Triple &TT, - ExceptionHandling ExceptionModel = ExceptionHandling::None, - FloatABI::ABIType FloatABI = FloatABI::Default, - EABI EABIVersion = EABI::Default, StringRef ABIName = "", - VectorLibrary VecLib = VectorLibrary::NoLibrary); + explicit RuntimeLibraryAnalysis(const Triple &T) : LibcallsInfo(T) {} RTLIB::RuntimeLibcallsInfo run(const Module &M, ModuleAnalysisManager &); @@ -45,19 +40,12 @@ class LLVM_ABI RuntimeLibraryInfoWrapper : public ImmutablePass { public: static char ID; RuntimeLibraryInfoWrapper(); - RuntimeLibraryInfoWrapper( - const Triple &TT, - ExceptionHandling ExceptionModel = ExceptionHandling::None, - FloatABI::ABIType FloatABI = FloatABI::Default, - EABI EABIVersion = EABI::Default, StringRef ABIName = "", - VectorLibrary VecLib = VectorLibrary::NoLibrary); + explicit RuntimeLibraryInfoWrapper(const Triple &T); + explicit RuntimeLibraryInfoWrapper(const RTLIB::RuntimeLibcallsInfo &RTLCI); const RTLIB::RuntimeLibcallsInfo &getRTLCI(const Module &M) { - if (!RTLCI) { - ModuleAnalysisManager DummyMAM; - RTLCI = RTLA.run(M, DummyMAM); - } - + ModuleAnalysisManager DummyMAM; + RTLCI = RTLA.run(M, DummyMAM); return *RTLCI; } diff --git a/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h b/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h index 3e0137710e8eb..8624fd2403a12 100644 --- a/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h +++ b/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h @@ -9,16 +9,12 @@ #ifndef LLVM_CODEGEN_LIBCALLLOWERINGINFO_H #define LLVM_CODEGEN_LIBCALLLOWERINGINFO_H -#include "llvm/ADT/DenseMap.h" #include "llvm/IR/RuntimeLibcalls.h" -#include "llvm/Pass.h" namespace llvm { class TargetSubtargetInfo; -class TargetMachine; -/// Tracks which library functions to use for a particular subtarget. class LibcallLoweringInfo { private: const RTLIB::RuntimeLibcallsInfo &RTLCI; @@ -77,70 +73,6 @@ class LibcallLoweringInfo { } }; -/// Record a mapping from subtarget to LibcallLoweringInfo. -class LibcallLoweringModuleAnalysisResult { -private: - using LibcallLoweringMap = - DenseMap<const TargetSubtargetInfo *, LibcallLoweringInfo>; - mutable LibcallLoweringMap LoweringMap; - const RTLIB::RuntimeLibcallsInfo *RTLCI = nullptr; - -public: - LibcallLoweringModuleAnalysisResult() = default; - LibcallLoweringModuleAnalysisResult(RTLIB::RuntimeLibcallsInfo &RTLCI) - : RTLCI(&RTLCI) {} - - void init(const RTLIB::RuntimeLibcallsInfo *RT) { RTLCI = RT; } - - void clear() { - RTLCI = nullptr; - LoweringMap.clear(); - } - - LLVM_ABI bool invalidate(Module &, const PreservedAnalyses &, - ModuleAnalysisManager::Invalidator &); - - const LibcallLoweringInfo & - getLibcallLowering(const TargetSubtargetInfo &Subtarget) const { - return LoweringMap.try_emplace(&Subtarget, *RTLCI, Subtarget).first->second; - } -}; - -class LibcallLoweringModuleAnalysis - : public AnalysisInfoMixin<LibcallLoweringModuleAnalysis> { -private: - friend AnalysisInfoMixin<LibcallLoweringModuleAnalysis>; - static AnalysisKey Key; - - LibcallLoweringModuleAnalysisResult LibcallLoweringMap; - -public: - using Result = LibcallLoweringModuleAnalysisResult; - - LLVM_ABI Result run(Module &M, ModuleAnalysisManager &); -}; - -class LLVM_ABI LibcallLoweringInfoWrapper : public ImmutablePass { - LibcallLoweringModuleAnalysisResult Result; - -public: - static char ID; - LibcallLoweringInfoWrapper(); - - const LibcallLoweringInfo & - getLibcallLowering(const TargetSubtargetInfo &Subtarget) const { - return Result.getLibcallLowering(Subtarget); - } - - const LibcallLoweringModuleAnalysisResult &getResult() const { - return Result; - } - - bool doInitialization(Module &M) override; - void getAnalysisUsage(AnalysisUsage &AU) const override; - void releaseMemory() override; -}; - } // end namespace llvm #endif // LLVM_CODEGEN_LIBCALLLOWERINGINFO_H diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h index a5491e68bbe52..18732caf78966 100644 --- a/llvm/include/llvm/InitializePasses.h +++ b/llvm/include/llvm/InitializePasses.h @@ -134,7 +134,6 @@ LLVM_ABI void initializeGlobalMergeFuncPassWrapperPass(PassRegistry &); LLVM_ABI void initializeGlobalMergePass(PassRegistry &); LLVM_ABI void initializeGlobalsAAWrapperPassPass(PassRegistry &); LLVM_ABI void initializeHardwareLoopsLegacyPass(PassRegistry &); -LLVM_ABI void initializeLibcallLoweringInfoWrapperPass(PassRegistry &); LLVM_ABI void initializeMIRProfileLoaderPassPass(PassRegistry &); LLVM_ABI void initializeIRSimilarityIdentifierWrapperPassPass(PassRegistry &); LLVM_ABI void initializeIRTranslatorPass(PassRegistry &); diff --git a/llvm/lib/Analysis/RuntimeLibcallInfo.cpp b/llvm/lib/Analysis/RuntimeLibcallInfo.cpp index 1c5a1cc75b7bd..9ea789a4ee45a 100644 --- a/llvm/lib/Analysis/RuntimeLibcallInfo.cpp +++ b/llvm/lib/Analysis/RuntimeLibcallInfo.cpp @@ -13,15 +13,6 @@ using namespace llvm; AnalysisKey RuntimeLibraryAnalysis::Key; -RuntimeLibraryAnalysis::RuntimeLibraryAnalysis(const Triple &TT, - ExceptionHandling ExceptionModel, - FloatABI::ABIType FloatABI, - EABI EABIVersion, - StringRef ABIName, - VectorLibrary VecLib) - : LibcallsInfo(std::in_place, TT, ExceptionModel, FloatABI, EABIVersion, - ABIName, VecLib) {} - RTLIB::RuntimeLibcallsInfo RuntimeLibraryAnalysis::run(const Module &M, ModuleAnalysisManager &) { if (!LibcallsInfo) @@ -35,13 +26,6 @@ INITIALIZE_PASS(RuntimeLibraryInfoWrapper, "runtime-library-info", RuntimeLibraryInfoWrapper::RuntimeLibraryInfoWrapper() : ImmutablePass(ID), RTLA(RTLIB::RuntimeLibcallsInfo(Triple())) {} -RuntimeLibraryInfoWrapper::RuntimeLibraryInfoWrapper( - const Triple &TT, ExceptionHandling ExceptionModel, - FloatABI::ABIType FloatABI, EABI EABIVersion, StringRef ABIName, - VectorLibrary VecLib) - : ImmutablePass(ID), RTLCI(std::in_place, TT, ExceptionModel, FloatABI, - EABIVersion, ABIName, VecLib) {} - char RuntimeLibraryInfoWrapper::ID = 0; ModulePass *llvm::createRuntimeLibraryInfoWrapperPass() { diff --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp index fe293c63fa762..9795a0b707fd3 100644 --- a/llvm/lib/CodeGen/CodeGen.cpp +++ b/llvm/lib/CodeGen/CodeGen.cpp @@ -57,7 +57,6 @@ void llvm::initializeCodeGen(PassRegistry &Registry) { initializeInterleavedLoadCombinePass(Registry); initializeInterleavedAccessPass(Registry); initializeJMCInstrumenterPass(Registry); - initializeLibcallLoweringInfoWrapperPass(Registry); initializeLiveDebugValuesLegacyPass(Registry); initializeLiveDebugVariablesWrapperLegacyPass(Registry); initializeLiveIntervalsWrapperPassPass(Registry); diff --git a/llvm/lib/CodeGen/ExpandFp.cpp b/llvm/lib/CodeGen/ExpandFp.cpp index 13ed4846d2bf7..f44eb227133ae 100644 --- a/llvm/lib/CodeGen/ExpandFp.cpp +++ b/llvm/lib/CodeGen/ExpandFp.cpp @@ -975,12 +975,11 @@ static RTLIB::Libcall fremToLibcall(Type *Ty) { /* Return true if, according to \p LibInfo, the target either directly supports the frem instruction for the \p Ty, has a custom lowering, or uses a libcall. */ -static bool targetSupportsFrem(const TargetLowering &TLI, - const LibcallLoweringInfo &Libcalls, Type *Ty) { +static bool targetSupportsFrem(const TargetLowering &TLI, Type *Ty) { if (!TLI.isOperationExpand(ISD::FREM, EVT::getEVT(Ty))) return true; - return Libcalls.getLibcallName(fremToLibcall(Ty->getScalarType())); + return TLI.getLibcallName(fremToLibcall(Ty->getScalarType())); } static void addToWorklist(Instruction &I, @@ -992,7 +991,7 @@ static void addToWorklist(Instruction &I, } static bool runImpl(Function &F, const TargetLowering &TLI, - const LibcallLoweringInfo &Libcalls, AssumptionCache *AC) { + AssumptionCache *AC) { SmallVector<Instruction *, 4> Worklist; unsigned MaxLegalFpConvertBitWidth = @@ -1011,7 +1010,7 @@ static bool runImpl(Function &F, const TargetLowering &TLI, switch (I.getOpcode()) { case Instruction::FRem: - return !targetSupportsFrem(TLI, Libcalls, Ty) && + return !targetSupportsFrem(TLI, Ty) && FRemExpander::canExpandType(Ty->getScalarType()); case Instruction::FPToUI: @@ -1091,27 +1090,20 @@ class ExpandFpLegacyPass : public FunctionPass { bool runOnFunction(Function &F) override { auto *TM = &getAnalysis<TargetPassConfig>().getTM<TargetMachine>(); - const TargetSubtargetInfo *Subtarget = TM->getSubtargetImpl(F); - auto *TLI = Subtarget->getTargetLowering(); + auto *TLI = TM->getSubtargetImpl(F)->getTargetLowering(); AssumptionCache *AC = nullptr; - const LibcallLoweringInfo &Libcalls = - getAnalysis<LibcallLoweringInfoWrapper>().getLibcallLowering( - *Subtarget); - if (OptLevel != CodeGenOptLevel::None && !F.hasOptNone()) AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F); - return runImpl(F, *TLI, Libcalls, AC); + return runImpl(F, *TLI, AC); } void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.addRequired<LibcallLoweringInfoWrapper>(); AU.addRequired<TargetPassConfig>(); if (OptLevel != CodeGenOptLevel::None) AU.addRequired<AssumptionCacheTracker>(); AU.addPreserved<AAResultsWrapperPass>(); AU.addPreserved<GlobalsAAWrapperPass>(); - AU.addRequired<LibcallLoweringInfoWrapper>(); } }; } // namespace @@ -1134,29 +1126,13 @@ PreservedAnalyses ExpandFpPass::run(Function &F, FunctionAnalysisManager &FAM) { AssumptionCache *AC = nullptr; if (OptLevel != CodeGenOptLevel::None) AC = &FAM.getResult<AssumptionAnalysis>(F); - - auto &MAMProxy = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F); - - const LibcallLoweringModuleAnalysisResult *LibcallLowering = - MAMProxy.getCachedResult<LibcallLoweringModuleAnalysis>(*F.getParent()); - - if (!LibcallLowering) { - F.getContext().emitError("'" + LibcallLoweringModuleAnalysis::name() + - "' analysis required"); - return PreservedAnalyses::all(); - } - - const LibcallLoweringInfo &Libcalls = - LibcallLowering->getLibcallLowering(*STI); - - return runImpl(F, TLI, Libcalls, AC) ? PreservedAnalyses::none() - : PreservedAnalyses::all(); + return runImpl(F, TLI, AC) ? PreservedAnalyses::none() + : PreservedAnalyses::all(); } char ExpandFpLegacyPass::ID = 0; INITIALIZE_PASS_BEGIN(ExpandFpLegacyPass, "expand-fp", "Expand certain fp instructions", false, false) -INITIALIZE_PASS_DEPENDENCY(LibcallLoweringInfoWrapper) INITIALIZE_PASS_END(ExpandFpLegacyPass, "expand-fp", "Expand fp", false, false) FunctionPass *llvm::createExpandFpPass(CodeGenOptLevel OptLevel) { diff --git a/llvm/lib/CodeGen/LibcallLoweringInfo.cpp b/llvm/lib/CodeGen/LibcallLoweringInfo.cpp index 0d54fac2422e2..6f3607e8db824 100644 --- a/llvm/lib/CodeGen/LibcallLoweringInfo.cpp +++ b/llvm/lib/CodeGen/LibcallLoweringInfo.cpp @@ -7,10 +7,7 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/LibcallLoweringInfo.h" -#include "llvm/Analysis/RuntimeLibcallInfo.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" -#include "llvm/InitializePasses.h" -#include "llvm/Target/TargetMachine.h" using namespace llvm; @@ -31,42 +28,3 @@ LibcallLoweringInfo::LibcallLoweringInfo( Subtarget.initLibcallLoweringInfo(*this); } - -AnalysisKey LibcallLoweringModuleAnalysis::Key; - -bool LibcallLoweringModuleAnalysisResult::invalidate( - Module &, const PreservedAnalyses &PA, - ModuleAnalysisManager::Invalidator &) { - // Passes that change the runtime libcall set must explicitly invalidate this - // pass. - auto PAC = PA.getChecker<LibcallLoweringModuleAnalysis>(); - return !PAC.preservedWhenStateless(); -} - -LibcallLoweringModuleAnalysisResult -LibcallLoweringModuleAnalysis::run(Module &M, ModuleAnalysisManager &MAM) { - LibcallLoweringMap.init(&MAM.getResult<RuntimeLibraryAnalysis>(M)); - return LibcallLoweringMap; -} - -INITIALIZE_PASS_BEGIN(LibcallLoweringInfoWrapper, "libcall-lowering-info", - "Library Function Lowering Analysis", false, true) -INITIALIZE_PASS_DEPENDENCY(RuntimeLibraryInfoWrapper) -INITIALIZE_PASS_END(LibcallLoweringInfoWrapper, "libcall-lowering-info", - "Library Function Lowering Analysis", false, true) - -char LibcallLoweringInfoWrapper::ID = 0; - -LibcallLoweringInfoWrapper::LibcallLoweringInfoWrapper() : ImmutablePass(ID) {} - -bool LibcallLoweringInfoWrapper::doInitialization(Module &M) { - Result.init(&getAnalysis<RuntimeLibraryInfoWrapper>().getRTLCI(M)); - return false; -} - -void LibcallLoweringInfoWrapper::getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired<RuntimeLibraryInfoWrapper>(); - AU.setPreservesAll(); -} - -void LibcallLoweringInfoWrapper::releaseMemory() { Result.clear(); } diff --git a/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp b/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp index 97da9abab0b7b..382d84a2ef030 100644 --- a/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp +++ b/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp @@ -17,7 +17,6 @@ #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/CodeGen/ExpandVectorPredication.h" -#include "llvm/CodeGen/LibcallLoweringInfo.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/TargetLowering.h" #include "llvm/CodeGen/TargetPassConfig.h" @@ -54,7 +53,6 @@ namespace { struct PreISelIntrinsicLowering { const TargetMachine *TM; - const LibcallLoweringModuleAnalysisResult &ModuleLibcalls; const function_ref<TargetTransformInfo &(Function &)> LookupTTI; const function_ref<TargetLibraryInfo &(Function &)> LookupTLI; @@ -65,13 +63,11 @@ struct PreISelIntrinsicLowering { explicit PreISelIntrinsicLowering( const TargetMachine *TM_, - const LibcallLoweringModuleAnalysisResult &ModuleLibcalls_, function_ref<TargetTransformInfo &(Function &)> LookupTTI_, function_ref<TargetLibraryInfo &(Function &)> LookupTLI_, bool UseMemIntrinsicLibFunc_ = true) - : TM(TM_), ModuleLibcalls(ModuleLibcalls_), LookupTTI(LookupTTI_), - LookupTLI(LookupTLI_), UseMemIntrinsicLibFunc(UseMemIntrinsicLibFunc_) { - } + : TM(TM_), LookupTTI(LookupTTI_), LookupTLI(LookupTLI_), + UseMemIntrinsicLibFunc(UseMemIntrinsicLibFunc_) {} static bool shouldExpandMemIntrinsicWithSize(Value *Size, const TargetTransformInfo &TTI); @@ -236,26 +232,21 @@ bool PreISelIntrinsicLowering::shouldExpandMemIntrinsicWithSize( return SizeVal > Threshold || Threshold == 0; } -static bool -canEmitLibcall(const LibcallLoweringModuleAnalysisResult &ModuleLowering, - const TargetMachine *TM, Function *F, RTLIB::Libcall LC) { +static bool canEmitLibcall(const TargetMachine *TM, Function *F, + RTLIB::Libcall LC) { // TODO: Should this consider the address space of the memcpy? if (!TM) return true; - const LibcallLoweringInfo &Lowering = - ModuleLowering.getLibcallLowering(*TM->getSubtargetImpl(*F)); - return Lowering.getLibcallImpl(LC) != RTLIB::Unsupported; + const TargetLowering *TLI = TM->getSubtargetImpl(*F)->getTargetLowering(); + return TLI->getLibcallName(LC) != nullptr; } -static bool -canEmitMemcpy(const LibcallLoweringModuleAnalysisResult &ModuleLowering, - const TargetMachine *TM, Function *F) { +static bool canEmitMemcpy(const TargetMachine *TM, Function *F) { // TODO: Should this consider the address space of the memcpy? if (!TM) return true; - const LibcallLoweringInfo &Lowering = - ModuleLowering.getLibcallLowering(*TM->getSubtargetImpl(*F)); - return Lowering.getMemcpyImpl() != RTLIB::Unsupported; + const TargetLowering *TLI = TM->getSubtargetImpl(*F)->getTargetLowering(); + return TLI->getMemcpyImpl() != RTLIB::Unsupported; } // Return a value appropriate for use with the memset_pattern16 libcall, if @@ -328,8 +319,7 @@ bool PreISelIntrinsicLowering::expandMemIntrinsicUses( Function *ParentFunc = Memcpy->getFunction(); const TargetTransformInfo &TTI = LookupTTI(*ParentFunc); if (shouldExpandMemIntrinsicWithSize(Memcpy->getLength(), TTI)) { - if (UseMemIntrinsicLibFunc && - canEmitMemcpy(ModuleLibcalls, TM, ParentFunc)) + if (UseMemIntrinsicLibFunc && canEmitMemcpy(TM, ParentFunc)) break; // TODO: For optsize, emit the loop into a separate function @@ -361,7 +351,7 @@ bool PreISelIntrinsicLowering::expandMemIntrinsicUses( const TargetTransformInfo &TTI = LookupTTI(*ParentFunc); if (shouldExpandMemIntrinsicWithSize(Memmove->getLength(), TTI)) { if (UseMemIntrinsicLibFunc && - canEmitLibcall(ModuleLibcalls, TM, ParentFunc, RTLIB::MEMMOVE)) + canEmitLibcall(TM, ParentFunc, RTLIB::MEMMOVE)) break; if (expandMemMoveAsLoop(Memmove, TTI)) { @@ -378,7 +368,7 @@ bool PreISelIntrinsicLowering::expandMemIntrinsicUses( const TargetTransformInfo &TTI = LookupTTI(*ParentFunc); if (shouldExpandMemIntrinsicWithSize(Memset->getLength(), TTI)) { if (UseMemIntrinsicLibFunc && - canEmitLibcall(ModuleLibcalls, TM, ParentFunc, RTLIB::MEMSET)) + canEmitLibcall(TM, ParentFunc, RTLIB::MEMSET)) break; expandMemSetAsLoop(Memset); @@ -772,14 +762,10 @@ class PreISelIntrinsicLoweringLegacyPass : public ModulePass { void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired<TargetTransformInfoWrapperPass>(); AU.addRequired<TargetLibraryInfoWrapperPass>(); - AU.addRequired<LibcallLoweringInfoWrapper>(); AU.addRequired<TargetPassConfig>(); } bool runOnModule(Module &M) override { - const LibcallLoweringModuleAnalysisResult &ModuleLibcalls = - getAnalysis<LibcallLoweringInfoWrapper>().getResult(); - auto LookupTTI = [this](Function &F) -> TargetTransformInfo & { return this->getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F); }; @@ -788,7 +774,7 @@ class PreISelIntrinsicLoweringLegacyPass : public ModulePass { }; const a... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/171452 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
