https://github.com/alexey-bataev created https://github.com/llvm/llvm-project/pull/171452
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. >From a0efa2f749e09f4958c2fbe13063eda0aebd949a Mon Sep 17 00:00:00 2001 From: Alexey Bataev <[email protected]> Date: Tue, 9 Dec 2025 06:52:29 -0800 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.7 --- clang/lib/CodeGen/BackendUtil.cpp | 6 -- .../llvm/Analysis/RuntimeLibcallInfo.h | 22 ++---- .../llvm/CodeGen/LibcallLoweringInfo.h | 68 ------------------- llvm/include/llvm/InitializePasses.h | 1 - llvm/lib/Analysis/RuntimeLibcallInfo.cpp | 16 ----- llvm/lib/CodeGen/CodeGen.cpp | 1 - llvm/lib/CodeGen/ExpandFp.cpp | 40 +++-------- llvm/lib/CodeGen/LibcallLoweringInfo.cpp | 42 ------------ llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp | 53 +++++---------- llvm/lib/LTO/LTOBackend.cpp | 6 -- llvm/lib/Passes/PassRegistry.def | 1 - llvm/test/CodeGen/AArch64/O0-pipeline.ll | 2 - llvm/test/CodeGen/AArch64/O3-pipeline.ll | 2 - llvm/test/CodeGen/AMDGPU/llc-pipeline.ll | 10 --- llvm/test/CodeGen/LoongArch/O0-pipeline.ll | 2 - llvm/test/CodeGen/LoongArch/opt-pipeline.ll | 2 - llvm/test/CodeGen/PowerPC/O0-pipeline.ll | 2 - llvm/test/CodeGen/PowerPC/O3-pipeline.ll | 2 - llvm/test/CodeGen/RISCV/O0-pipeline.ll | 2 - llvm/test/CodeGen/RISCV/O3-pipeline.ll | 2 - llvm/test/CodeGen/SPIRV/llc-pipeline.ll | 4 -- llvm/test/CodeGen/X86/O0-pipeline.ll | 2 - llvm/test/CodeGen/X86/opt-pipeline.ll | 2 - .../Transforms/ExpandFp/AMDGPU/frem-inf.ll | 4 +- llvm/test/Transforms/ExpandFp/AMDGPU/frem.ll | 2 +- .../ExpandFp/AMDGPU/missing-analysis.ll | 6 -- .../ExpandFp/AMDGPU/pass-parameters.ll | 16 ++--- .../X86/expand-large-fp-convert-fptosi129.ll | 2 +- .../X86/expand-large-fp-convert-fptoui129.ll | 2 +- .../X86/expand-large-fp-convert-si129tofp.ll | 2 +- .../X86/expand-large-fp-convert-ui129tofp.ll | 2 +- .../X86/expand-large-fp-optnone.ll | 2 +- llvm/tools/llc/NewPMDriver.cpp | 12 ---- llvm/tools/llc/llc.cpp | 5 -- llvm/tools/opt/NewPMDriver.cpp | 23 ++----- llvm/tools/opt/NewPMDriver.h | 10 ++- llvm/tools/opt/optdriver.cpp | 19 ++---- 37 files changed, 66 insertions(+), 331 deletions(-) delete mode 100644 llvm/test/Transforms/ExpandFp/AMDGPU/missing-analysis.ll 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 auto *TM = &getAnalysis<TargetPassConfig>().getTM<TargetMachine>(); - PreISelIntrinsicLowering Lowering(TM, ModuleLibcalls, LookupTTI, LookupTLI); + PreISelIntrinsicLowering Lowering(TM, LookupTTI, LookupTLI); return Lowering.lowerIntrinsics(M); } }; @@ -800,8 +786,6 @@ char PreISelIntrinsicLoweringLegacyPass::ID; INITIALIZE_PASS_BEGIN(PreISelIntrinsicLoweringLegacyPass, "pre-isel-intrinsic-lowering", "Pre-ISel Intrinsic Lowering", false, false) -INITIALIZE_PASS_DEPENDENCY(LibcallLoweringInfoWrapper) -INITIALIZE_PASS_DEPENDENCY(RuntimeLibraryInfoWrapper) INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass) INITIALIZE_PASS_DEPENDENCY(TargetPassConfig) INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass) @@ -813,12 +797,9 @@ ModulePass *llvm::createPreISelIntrinsicLoweringPass() { return new PreISelIntrinsicLoweringLegacyPass(); } -PreservedAnalyses -PreISelIntrinsicLoweringPass::run(Module &M, ModuleAnalysisManager &MAM) { - const LibcallLoweringModuleAnalysisResult &LibcallLowering = - MAM.getResult<LibcallLoweringModuleAnalysis>(M); - - auto &FAM = MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager(); +PreservedAnalyses PreISelIntrinsicLoweringPass::run(Module &M, + ModuleAnalysisManager &AM) { + auto &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager(); auto LookupTTI = [&FAM](Function &F) -> TargetTransformInfo & { return FAM.getResult<TargetIRAnalysis>(F); @@ -827,7 +808,7 @@ PreISelIntrinsicLoweringPass::run(Module &M, ModuleAnalysisManager &MAM) { return FAM.getResult<TargetLibraryAnalysis>(F); }; - PreISelIntrinsicLowering Lowering(TM, LibcallLowering, LookupTTI, LookupTLI); + PreISelIntrinsicLowering Lowering(TM, LookupTTI, LookupTLI); if (!Lowering.lowerIntrinsics(M)) return PreservedAnalyses::all(); else diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index f9cde383ce32d..93118becedbac 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -17,7 +17,6 @@ #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/CGSCCPassManager.h" #include "llvm/Analysis/ModuleSummaryAnalysis.h" -#include "llvm/Analysis/RuntimeLibcallInfo.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Bitcode/BitcodeReader.h" #include "llvm/Bitcode/BitcodeWriter.h" @@ -447,11 +446,6 @@ static void codegen(const Config &Conf, TargetMachine *TM, legacy::PassManager CodeGenPasses; TargetLibraryInfoImpl TLII(Mod.getTargetTriple()); CodeGenPasses.add(new TargetLibraryInfoWrapperPass(TLII)); - CodeGenPasses.add(new RuntimeLibraryInfoWrapper( - Mod.getTargetTriple(), TM->Options.ExceptionModel, - TM->Options.FloatABIType, TM->Options.EABIVersion, - TM->Options.MCOptions.ABIName, TM->Options.VecLib)); - // No need to make index available if the module is empty. // In theory these passes should not use the index for an empty // module, however, this guards against doing any unnecessary summary-based diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def index cf998f29ef38c..2bba8a2a1ac71 100644 --- a/llvm/lib/Passes/PassRegistry.def +++ b/llvm/lib/Passes/PassRegistry.def @@ -30,7 +30,6 @@ MODULE_ANALYSIS("ir2vec-vocab", IR2VecVocabAnalysis()) MODULE_ANALYSIS("ir-similarity", IRSimilarityAnalysis()) MODULE_ANALYSIS("last-run-tracking", LastRunTrackingAnalysis()) MODULE_ANALYSIS("lcg", LazyCallGraphAnalysis()) -MODULE_ANALYSIS("libcall-lowering-info", LibcallLoweringModuleAnalysis()) MODULE_ANALYSIS("module-summary", ModuleSummaryIndexAnalysis()) MODULE_ANALYSIS("no-op-module", NoOpModuleAnalysis()) MODULE_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC)) diff --git a/llvm/test/CodeGen/AArch64/O0-pipeline.ll b/llvm/test/CodeGen/AArch64/O0-pipeline.ll index 96f5e5a4afb3e..abc67eec32391 100644 --- a/llvm/test/CodeGen/AArch64/O0-pipeline.ll +++ b/llvm/test/CodeGen/AArch64/O0-pipeline.ll @@ -5,11 +5,9 @@ ; CHECK-LABEL: Pass Arguments: ; CHECK-NEXT: Target Library Information -; CHECK-NEXT: Runtime Library Function Analysis ; CHECK-NEXT: Target Pass Configuration ; CHECK-NEXT: Machine Module Information ; CHECK-NEXT: Target Transform Information -; CHECK-NEXT: Library Function Lowering Analysis ; CHECK-NEXT: Create Garbage Collector Module Metadata ; CHECK-NEXT: Profile summary info ; CHECK-NEXT: Assumption Cache Tracker diff --git a/llvm/test/CodeGen/AArch64/O3-pipeline.ll b/llvm/test/CodeGen/AArch64/O3-pipeline.ll index e8ea55e027aec..9a6f2aebdfedd 100644 --- a/llvm/test/CodeGen/AArch64/O3-pipeline.ll +++ b/llvm/test/CodeGen/AArch64/O3-pipeline.ll @@ -5,11 +5,9 @@ ; CHECK-LABEL: Pass Arguments: ; CHECK-NEXT: Target Library Information -; CHECK-NEXT: Runtime Library Function Analysis ; CHECK-NEXT: Target Pass Configuration ; CHECK-NEXT: Machine Module Information ; CHECK-NEXT: Target Transform Information -; CHECK-NEXT: Library Function Lowering Analysis ; CHECK-NEXT: Assumption Cache Tracker ; CHECK-NEXT: Profile summary info ; CHECK-NEXT: Type-Based Alias Analysis diff --git a/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll b/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll index 8364e680bc8c7..1f7888a633d62 100644 --- a/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll +++ b/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll @@ -14,11 +14,9 @@ ; REQUIRES: asserts ; GCN-O0:Target Library Information -; GCN-O0-NEXT:Runtime Library Function Analysis ; GCN-O0-NEXT:Target Pass Configuration ; GCN-O0-NEXT:Machine Module Information ; GCN-O0-NEXT:Target Transform Information -; GCN-O0-NEXT:Library Function Lowering Analysis ; GCN-O0-NEXT:Assumption Cache Tracker ; GCN-O0-NEXT:Profile summary info ; GCN-O0-NEXT:Argument Register Usage Information Storage @@ -163,11 +161,9 @@ ; GCN-O0-NEXT: Free MachineFunction ; GCN-O1:Target Library Information -; GCN-O1-NEXT:Runtime Library Function Analysis ; GCN-O1-NEXT:Target Pass Configuration ; GCN-O1-NEXT:Machine Module Information ; GCN-O1-NEXT:Target Transform Information -; GCN-O1-NEXT:Library Function Lowering Analysis ; GCN-O1-NEXT:Assumption Cache Tracker ; GCN-O1-NEXT:Profile summary info ; GCN-O1-NEXT:AMDGPU Address space based Alias Analysis @@ -457,11 +453,9 @@ ; GCN-O1-NEXT: Free MachineFunction ; GCN-O1-OPTS:Target Library Information -; GCN-O1-OPTS-NEXT:Runtime Library Function Analysis ; GCN-O1-OPTS-NEXT:Target Pass Configuration ; GCN-O1-OPTS-NEXT:Machine Module Information ; GCN-O1-OPTS-NEXT:Target Transform Information -; GCN-O1-OPTS-NEXT:Library Function Lowering Analysis ; GCN-O1-OPTS-NEXT:Assumption Cache Tracker ; GCN-O1-OPTS-NEXT:Profile summary info ; GCN-O1-OPTS-NEXT:AMDGPU Address space based Alias Analysis @@ -779,11 +773,9 @@ ; GCN-O1-OPTS-NEXT: Free MachineFunction ; GCN-O2:Target Library Information -; GCN-O2-NEXT:Runtime Library Function Analysis ; GCN-O2-NEXT:Target Pass Configuration ; GCN-O2-NEXT:Machine Module Information ; GCN-O2-NEXT:Target Transform Information -; GCN-O2-NEXT:Library Function Lowering Analysis ; GCN-O2-NEXT:Assumption Cache Tracker ; GCN-O2-NEXT:Profile summary info ; GCN-O2-NEXT:AMDGPU Address space based Alias Analysis @@ -1106,11 +1098,9 @@ ; GCN-O2-NEXT: Free MachineFunction ; GCN-O3:Target Library Information -; GCN-O3-NEXT:Runtime Library Function Analysis ; GCN-O3-NEXT:Target Pass Configuration ; GCN-O3-NEXT:Machine Module Information ; GCN-O3-NEXT:Target Transform Information -; GCN-O3-NEXT:Library Function Lowering Analysis ; GCN-O3-NEXT:Assumption Cache Tracker ; GCN-O3-NEXT:Profile summary info ; GCN-O3-NEXT:AMDGPU Address space based Alias Analysis diff --git a/llvm/test/CodeGen/LoongArch/O0-pipeline.ll b/llvm/test/CodeGen/LoongArch/O0-pipeline.ll index 5f4fccdd72b12..9006b5c8d6fe1 100644 --- a/llvm/test/CodeGen/LoongArch/O0-pipeline.ll +++ b/llvm/test/CodeGen/LoongArch/O0-pipeline.ll @@ -9,11 +9,9 @@ ; CHECK-LABEL: Pass Arguments: ; CHECK-NEXT: Target Library Information -; CHECK-NEXT: Runtime Library Function Analysis ; CHECK-NEXT: Target Pass Configuration ; CHECK-NEXT: Machine Module Information ; CHECK-NEXT: Target Transform Information -; CHECK-NEXT: Library Function Lowering Analysis ; CHECK-NEXT: Create Garbage Collector Module Metadata ; CHECK-NEXT: Assumption Cache Tracker ; CHECK-NEXT: Profile summary info diff --git a/llvm/test/CodeGen/LoongArch/opt-pipeline.ll b/llvm/test/CodeGen/LoongArch/opt-pipeline.ll index 546ed6cec5c4a..661f67d4989c4 100644 --- a/llvm/test/CodeGen/LoongArch/opt-pipeline.ll +++ b/llvm/test/CodeGen/LoongArch/opt-pipeline.ll @@ -17,11 +17,9 @@ ; LAXX-LABEL: Pass Arguments: ; LAXX-NEXT: Target Library Information -; LAXX-NEXT: Runtime Library Function Analysis ; LAXX-NEXT: Target Pass Configuration ; LAXX-NEXT: Machine Module Information ; LAXX-NEXT: Target Transform Information -; LAXX-NEXT: Library Function Lowering Analysis ; LAXX-NEXT: Assumption Cache Tracker ; LAXX-NEXT: Type-Based Alias Analysis ; LAXX-NEXT: Scoped NoAlias Alias Analysis diff --git a/llvm/test/CodeGen/PowerPC/O0-pipeline.ll b/llvm/test/CodeGen/PowerPC/O0-pipeline.ll index ac04be436f6a1..38b1074e55d22 100644 --- a/llvm/test/CodeGen/PowerPC/O0-pipeline.ll +++ b/llvm/test/CodeGen/PowerPC/O0-pipeline.ll @@ -6,11 +6,9 @@ ; CHECK-LABEL: Pass Arguments: ; CHECK-NEXT: Target Library Information -; CHECK-NEXT: Runtime Library Function Analysis ; CHECK-NEXT: Target Pass Configuration ; CHECK-NEXT: Machine Module Information ; CHECK-NEXT: Target Transform Information -; CHECK-NEXT: Library Function Lowering Analysis ; CHECK-NEXT: Create Garbage Collector Module Metadata ; CHECK-NEXT: Assumption Cache Tracker ; CHECK-NEXT: Profile summary info diff --git a/llvm/test/CodeGen/PowerPC/O3-pipeline.ll b/llvm/test/CodeGen/PowerPC/O3-pipeline.ll index fd8fd5fa34a17..7cbb1a1c98873 100644 --- a/llvm/test/CodeGen/PowerPC/O3-pipeline.ll +++ b/llvm/test/CodeGen/PowerPC/O3-pipeline.ll @@ -5,11 +5,9 @@ ; REQUIRES: asserts ; CHECK-LABEL: Pass Arguments: ; CHECK-NEXT: Target Library Information -; CHECK-NEXT: Runtime Library Function Analysis ; CHECK-NEXT: Target Pass Configuration ; CHECK-NEXT: Machine Module Information ; CHECK-NEXT: Target Transform Information -; CHECK-NEXT: Library Function Lowering Analysis ; CHECK-NEXT: Assumption Cache Tracker ; CHECK-NEXT: Type-Based Alias Analysis ; CHECK-NEXT: Scoped NoAlias Alias Analysis diff --git a/llvm/test/CodeGen/RISCV/O0-pipeline.ll b/llvm/test/CodeGen/RISCV/O0-pipeline.ll index 42d30fcef2a9b..8714b286374a5 100644 --- a/llvm/test/CodeGen/RISCV/O0-pipeline.ll +++ b/llvm/test/CodeGen/RISCV/O0-pipeline.ll @@ -9,11 +9,9 @@ ; CHECK-LABEL: Pass Arguments: ; CHECK-NEXT: Target Library Information -; CHECK-NEXT: Runtime Library Function Analysis ; CHECK-NEXT: Target Pass Configuration ; CHECK-NEXT: Machine Module Information ; CHECK-NEXT: Target Transform Information -; CHECK-NEXT: Library Function Lowering Analysis ; CHECK-NEXT: Create Garbage Collector Module Metadata ; CHECK-NEXT: Assumption Cache Tracker ; CHECK-NEXT: Profile summary info diff --git a/llvm/test/CodeGen/RISCV/O3-pipeline.ll b/llvm/test/CodeGen/RISCV/O3-pipeline.ll index 85027a56a1348..3e2de780524b6 100644 --- a/llvm/test/CodeGen/RISCV/O3-pipeline.ll +++ b/llvm/test/CodeGen/RISCV/O3-pipeline.ll @@ -9,11 +9,9 @@ ; CHECK-LABEL: Pass Arguments: ; CHECK-NEXT: Target Library Information -; CHECK-NEXT: Runtime Library Function Analysis ; CHECK-NEXT: Target Pass Configuration ; CHECK-NEXT: Machine Module Information ; CHECK-NEXT: Target Transform Information -; CHECK-NEXT: Library Function Lowering Analysis ; CHECK-NEXT: Assumption Cache Tracker ; CHECK-NEXT: Profile summary info ; CHECK-NEXT: Type-Based Alias Analysis diff --git a/llvm/test/CodeGen/SPIRV/llc-pipeline.ll b/llvm/test/CodeGen/SPIRV/llc-pipeline.ll index 3a1d0f7b5d218..6db375445e4a3 100644 --- a/llvm/test/CodeGen/SPIRV/llc-pipeline.ll +++ b/llvm/test/CodeGen/SPIRV/llc-pipeline.ll @@ -11,11 +11,9 @@ ; REQUIRES:asserts ; SPIRV-O0:Target Library Information -; SPIRV-O0-NEXT:Runtime Library Function Analysis ; SPIRV-O0-NEXT:Target Pass Configuration ; SPIRV-O0-NEXT:Machine Module Information ; SPIRV-O0-NEXT:Target Transform Information -; SPIRV-O0-NEXT:Library Function Lowering Analysis ; SPIRV-O0-NEXT:Create Garbage Collector Module Metadata ; SPIRV-O0-NEXT:Assumption Cache Tracker ; SPIRV-O0-NEXT:Profile summary info @@ -85,11 +83,9 @@ ; SPIRV-O0-NEXT: Free MachineFunction ; SPIRV-Opt:Target Library Information -; SPIRV-Opt-NEXT:Runtime Library Function Analysis ; SPIRV-Opt-NEXT:Target Pass Configuration ; SPIRV-Opt-NEXT:Machine Module Information ; SPIRV-Opt-NEXT:Target Transform Information -; SPIRV-Opt-NEXT:Library Function Lowering Analysis ; SPIRV-Opt-NEXT:Assumption Cache Tracker ; SPIRV-Opt-NEXT:Type-Based Alias Analysis ; SPIRV-Opt-NEXT:Scoped NoAlias Alias Analysis diff --git a/llvm/test/CodeGen/X86/O0-pipeline.ll b/llvm/test/CodeGen/X86/O0-pipeline.ll index 9223348abbcb9..78a02b11b17bb 100644 --- a/llvm/test/CodeGen/X86/O0-pipeline.ll +++ b/llvm/test/CodeGen/X86/O0-pipeline.ll @@ -7,11 +7,9 @@ ; CHECK-LABEL: Pass Arguments: ; CHECK-NEXT: Target Library Information -; CHECK-NEXT: Runtime Library Function Analysis ; CHECK-NEXT: Target Pass Configuration ; CHECK-NEXT: Machine Module Information ; CHECK-NEXT: Target Transform Information -; CHECK-NEXT: Library Function Lowering Analysis ; CHECK-NEXT: Create Garbage Collector Module Metadata ; CHECK-NEXT: Assumption Cache Tracker ; CHECK-NEXT: Profile summary info diff --git a/llvm/test/CodeGen/X86/opt-pipeline.ll b/llvm/test/CodeGen/X86/opt-pipeline.ll index 9f08658e067ab..276232e27c000 100644 --- a/llvm/test/CodeGen/X86/opt-pipeline.ll +++ b/llvm/test/CodeGen/X86/opt-pipeline.ll @@ -13,11 +13,9 @@ ; CHECK-LABEL: Pass Arguments: ; CHECK-NEXT: Target Library Information -; CHECK-NEXT: Runtime Library Function Analysis ; CHECK-NEXT: Target Pass Configuration ; CHECK-NEXT: Machine Module Information ; CHECK-NEXT: Target Transform Information -; CHECK-NEXT: Library Function Lowering Analysis ; CHECK-NEXT: Assumption Cache Tracker ; CHECK-NEXT: Type-Based Alias Analysis ; CHECK-NEXT: Scoped NoAlias Alias Analysis diff --git a/llvm/test/Transforms/ExpandFp/AMDGPU/frem-inf.ll b/llvm/test/Transforms/ExpandFp/AMDGPU/frem-inf.ll index 54ece8d52f08a..f70f0d25f172d 100644 --- a/llvm/test/Transforms/ExpandFp/AMDGPU/frem-inf.ll +++ b/llvm/test/Transforms/ExpandFp/AMDGPU/frem-inf.ll @@ -1,5 +1,5 @@ -; RUN: opt -mtriple=amdgcn -passes="require<libcall-lowering-info>,expand-fp<O0>" %s -S -o - | FileCheck --check-prefixes CHECK %s -; RUN: opt -mtriple=amdgcn -passes="require<libcall-lowering-info>,expand-fp<O1>" %s -S -o - | FileCheck --check-prefixes CHECK,OPT1 %s +; RUN: opt -mtriple=amdgcn -passes="expand-fp<O0>" %s -S -o - | FileCheck --check-prefixes CHECK %s +; RUN: opt -mtriple=amdgcn -passes="expand-fp<O1>" %s -S -o - | FileCheck --check-prefixes CHECK,OPT1 %s ; Check the handling of potentially infinite numerators in the frem ; expansion at different optimization levels and with different diff --git a/llvm/test/Transforms/ExpandFp/AMDGPU/frem.ll b/llvm/test/Transforms/ExpandFp/AMDGPU/frem.ll index 5cd6f1e8a6086..4c0f9db147c96 100644 --- a/llvm/test/Transforms/ExpandFp/AMDGPU/frem.ll +++ b/llvm/test/Transforms/ExpandFp/AMDGPU/frem.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 -; RUN: opt -mtriple=amdgcn -passes="require<libcall-lowering-info>,expand-fp<O1>" %s -S -o - | FileCheck %s +; RUN: opt -mtriple=amdgcn -passes="expand-fp<O1>" %s -S -o - | FileCheck %s define amdgpu_kernel void @frem_f16(ptr addrspace(1) %out, ptr addrspace(1) %in1, ; CHECK-LABEL: define amdgpu_kernel void @frem_f16( diff --git a/llvm/test/Transforms/ExpandFp/AMDGPU/missing-analysis.ll b/llvm/test/Transforms/ExpandFp/AMDGPU/missing-analysis.ll deleted file mode 100644 index 2d5f2a7223e3a..0000000000000 --- a/llvm/test/Transforms/ExpandFp/AMDGPU/missing-analysis.ll +++ /dev/null @@ -1,6 +0,0 @@ -; RUN: not opt -mtriple=amdgcn -passes=expand-fp -disable-output %s 2>&1 | FileCheck %s - -; CHECK: 'LibcallLoweringModuleAnalysis' analysis required -define void @empty() { - ret void -} diff --git a/llvm/test/Transforms/ExpandFp/AMDGPU/pass-parameters.ll b/llvm/test/Transforms/ExpandFp/AMDGPU/pass-parameters.ll index 794d5805291b0..03cafd4ff1160 100644 --- a/llvm/test/Transforms/ExpandFp/AMDGPU/pass-parameters.ll +++ b/llvm/test/Transforms/ExpandFp/AMDGPU/pass-parameters.ll @@ -1,18 +1,18 @@ -; RUN: opt -mtriple=amdgcn -passes="require<libcall-lowering-info>,expand-fp<O0>" %s -S -disable-output -; RUN: opt -mtriple=amdgcn -passes="require<libcall-lowering-info>,expand-fp<O1>" %s -S -disable-output -; RUN: opt -mtriple=amdgcn -passes="require<libcall-lowering-info>,expand-fp<O2>" %s -S -disable-output -; RUN: opt -mtriple=amdgcn -passes="require<libcall-lowering-info>,expand-fp<O3>" %s -S -disable-output +; RUN: opt -mtriple=amdgcn -passes="expand-fp<O0>" %s -S -o /dev/null +; RUN: opt -mtriple=amdgcn -passes="expand-fp<O1>" %s -S -o /dev/null +; RUN: opt -mtriple=amdgcn -passes="expand-fp<O2>" %s -S -o /dev/null +; RUN: opt -mtriple=amdgcn -passes="expand-fp<O3>" %s -S -o /dev/null -; RUN: not opt -mtriple=amdgcn -passes="require<libcall-lowering-info>,expand-fp<O4>" %s -S -disable-output 2>&1 | FileCheck --check-prefix=TOO-LARGE %s +; RUN: not opt -mtriple=amdgcn -passes="expand-fp<O4>" %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=TOO-LARGE %s ; TOO-LARGE: {{.*}}invalid optimization level for expand-fp pass: 4 -; RUN: not opt -mtriple=amdgcn -passes="require<libcall-lowering-info>,expand-fp<Os>" %s -S -disable-output 2>&1 | FileCheck --check-prefix=NON-NUMERIC %s +; RUN: not opt -mtriple=amdgcn -passes="expand-fp<Os>" %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=NON-NUMERIC %s ; NON-NUMERIC: {{.*}}invalid expand-fp pass parameter -; RUN: not opt -mtriple=amdgcn -passes="require<libcall-lowering-info>,expand-fp<O-1>" %s -S -disable-output 2>&1 | FileCheck --check-prefix=NEGATIVE %s +; RUN: not opt -mtriple=amdgcn -passes="expand-fp<O-1>" %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=NEGATIVE %s ; NEGATIVE: {{.*}}invalid expand-fp pass parameter 'O-1' -; RUN: not opt -mtriple=amdgcn -passes="require<libcall-lowering-info>,expand-fp<foo>" %s -S -disable-output 2>&1 | FileCheck --check-prefix=NO-O-PREFIX %s +; RUN: not opt -mtriple=amdgcn -passes="expand-fp<foo>" %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=NO-O-PREFIX %s ; NO-O-PREFIX: {{.*}}invalid expand-fp pass parameter 'foo' define void @empty() { diff --git a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll index 0cf8829aec037..f5bf8bb61a16e 100644 --- a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll +++ b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -S -mtriple=x86_64-- --expand-fp < %s | FileCheck %s -; RUN: opt -S -mtriple=x86_64-- -passes='require<libcall-lowering-info>,expand-fp' < %s | FileCheck %s +; RUN: opt -S -mtriple=x86_64-- -passes=expand-fp < %s | FileCheck %s define i129 @halftosi129(half %a) { ; CHECK-LABEL: @halftosi129( diff --git a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll index 055e3e0dc261d..94ed32abe46f8 100644 --- a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll +++ b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -S -mtriple=x86_64-- --expand-fp < %s | FileCheck %s -; RUN: opt -S -mtriple=x86_64-- -passes='require<libcall-lowering-info>,expand-fp' < %s | FileCheck %s +; RUN: opt -S -mtriple=x86_64-- -passes=expand-fp < %s | FileCheck %s define i129 @halftoui129(half %a) { ; CHECK-LABEL: @halftoui129( diff --git a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll index af053e82a62a4..8820b873f3818 100644 --- a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll +++ b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -S -mtriple=x86_64-- --expand-fp < %s | FileCheck %s -; RUN: opt -S -mtriple=x86_64-- -passes='require<libcall-lowering-info>,expand-fp' < %s | FileCheck %s +; RUN: opt -S -mtriple=x86_64-- -passes=expand-fp < %s | FileCheck %s define half @si129tohalf(i129 %a) { ; CHECK-LABEL: @si129tohalf( diff --git a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll index ede9b2a4cd049..b58d88bc02c79 100644 --- a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll +++ b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -S -mtriple=x86_64-- --expand-fp < %s | FileCheck %s -; RUN: opt -S -mtriple=x86_64-- -passes='require<libcall-lowering-info>,expand-fp' < %s | FileCheck %s +; RUN: opt -S -mtriple=x86_64-- -passes=expand-fp < %s | FileCheck %s define half @ui129tohalf(i129 %a) { ; CHECK-LABEL: @ui129tohalf( diff --git a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-optnone.ll b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-optnone.ll index e78eaeb70fbf1..78bc0006fda23 100644 --- a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-optnone.ll +++ b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-optnone.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 ; RUN: opt -S -mtriple=x86_64-- --expand-fp < %s | FileCheck %s -; RUN: opt -S -mtriple=x86_64-- -passes='require<libcall-lowering-info>,expand-fp' < %s | FileCheck %s +; RUN: opt -S -mtriple=x86_64-- -passes=expand-fp < %s | FileCheck %s ; expand-fp must also run with optnone diff --git a/llvm/tools/llc/NewPMDriver.cpp b/llvm/tools/llc/NewPMDriver.cpp index 6d4989e278fc1..7ba17e5b82095 100644 --- a/llvm/tools/llc/NewPMDriver.cpp +++ b/llvm/tools/llc/NewPMDriver.cpp @@ -14,10 +14,8 @@ #include "NewPMDriver.h" #include "llvm/Analysis/CGSCCPassManager.h" -#include "llvm/Analysis/RuntimeLibcallInfo.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/CodeGen/CommandFlags.h" -#include "llvm/CodeGen/LibcallLoweringInfo.h" #include "llvm/CodeGen/MIRParser/MIRParser.h" #include "llvm/CodeGen/MIRPrinter.h" #include "llvm/CodeGen/MachineFunctionAnalysis.h" @@ -138,16 +136,6 @@ int llvm::compileModuleWithNewPM( SI.registerCallbacks(PIC, &MAM); FAM.registerPass([&] { return TargetLibraryAnalysis(TLII); }); - - MAM.registerPass([&] { - const TargetOptions &Options = Target->Options; - return RuntimeLibraryAnalysis( - M->getTargetTriple(), Target->Options.ExceptionModel, - Target->Options.FloatABIType, Target->Options.EABIVersion, - Options.MCOptions.ABIName, Target->Options.VecLib); - }); - MAM.registerPass([&] { return LibcallLoweringModuleAnalysis(); }); - MAM.registerPass([&] { return MachineModuleAnalysis(MMI); }); ModulePassManager MPM; diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp index 613780ecbfb40..ad31a0ec63387 100644 --- a/llvm/tools/llc/llc.cpp +++ b/llvm/tools/llc/llc.cpp @@ -16,7 +16,6 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/Statistic.h" -#include "llvm/Analysis/RuntimeLibcallInfo.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/CodeGen/CommandFlags.h" #include "llvm/CodeGen/LinkAllAsmWriterComponents.h" @@ -728,10 +727,6 @@ static int compileModule(char **argv, LLVMContext &Context, // Build up all of the passes that we want to do to the module. legacy::PassManager PM; PM.add(new TargetLibraryInfoWrapperPass(TLII)); - PM.add(new RuntimeLibraryInfoWrapper( - M->getTargetTriple(), Target->Options.ExceptionModel, - Target->Options.FloatABIType, Target->Options.EABIVersion, - Options.MCOptions.ABIName, Target->Options.VecLib)); { raw_pwrite_stream *OS = &Out->os(); diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp index eaa1d8f958a4d..6af04bae273b5 100644 --- a/llvm/tools/opt/NewPMDriver.cpp +++ b/llvm/tools/opt/NewPMDriver.cpp @@ -21,7 +21,6 @@ #include "llvm/Analysis/RuntimeLibcallInfo.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Bitcode/BitcodeWriterPass.h" -#include "llvm/CodeGen/LibcallLoweringInfo.h" #include "llvm/Config/llvm-config.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/LLVMContext.h" @@ -353,9 +352,9 @@ static void registerEPCallbacks(PassBuilder &PB) { bool llvm::runPassPipeline( StringRef Arg0, Module &M, TargetMachine *TM, TargetLibraryInfoImpl *TLII, - ToolOutputFile *Out, ToolOutputFile *ThinLTOLinkOut, - ToolOutputFile *OptRemarkFile, StringRef PassPipeline, - ArrayRef<PassPlugin> PassPlugins, + RTLIB::RuntimeLibcallsInfo &RTLCI, ToolOutputFile *Out, + ToolOutputFile *ThinLTOLinkOut, ToolOutputFile *OptRemarkFile, + StringRef PassPipeline, ArrayRef<PassPlugin> PassPlugins, ArrayRef<std::function<void(PassBuilder &)>> PassBuilderCallbacks, OutputKind OK, VerifierKind VK, bool ShouldPreserveAssemblyUseListOrder, bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex, @@ -411,24 +410,14 @@ bool llvm::runPassPipeline( P->CSAction = PGOOptions::CSIRUse; } } + if (TM) + TM->setPGOOption(P); LoopAnalysisManager LAM; FunctionAnalysisManager FAM; CGSCCAnalysisManager CGAM; ModuleAnalysisManager MAM; - - if (TM) { - TM->setPGOOption(P); - - MAM.registerPass([&] { - const TargetOptions &Options = TM->Options; - return RuntimeLibraryAnalysis(M.getTargetTriple(), Options.ExceptionModel, - Options.FloatABIType, Options.EABIVersion, - Options.MCOptions.ABIName, Options.VecLib); - }); - - MAM.registerPass([&] { return LibcallLoweringModuleAnalysis(); }); - } + MAM.registerPass([&] { return RuntimeLibraryAnalysis(std::move(RTLCI)); }); PassInstrumentationCallbacks PIC; PrintPassOptions PrintPassOpts; diff --git a/llvm/tools/opt/NewPMDriver.h b/llvm/tools/opt/NewPMDriver.h index 042d5d4bbfe47..31da61b9c0cae 100644 --- a/llvm/tools/opt/NewPMDriver.h +++ b/llvm/tools/opt/NewPMDriver.h @@ -31,6 +31,10 @@ class TargetMachine; class ToolOutputFile; class TargetLibraryInfoImpl; +namespace RTLIB { +struct RuntimeLibcallsInfo; +} + extern cl::opt<bool> DebugifyEach; extern cl::opt<std::string> DebugifyExport; @@ -67,9 +71,9 @@ void printPasses(raw_ostream &OS); /// nullptr. bool runPassPipeline( StringRef Arg0, Module &M, TargetMachine *TM, TargetLibraryInfoImpl *TLII, - ToolOutputFile *Out, ToolOutputFile *ThinLinkOut, - ToolOutputFile *OptRemarkFile, StringRef PassPipeline, - ArrayRef<PassPlugin> PassPlugins, + RTLIB::RuntimeLibcallsInfo &RTLCI, ToolOutputFile *Out, + ToolOutputFile *ThinLinkOut, ToolOutputFile *OptRemarkFile, + StringRef PassPipeline, ArrayRef<PassPlugin> PassPlugins, ArrayRef<std::function<void(PassBuilder &)>> PassBuilderCallbacks, opt_tool::OutputKind OK, opt_tool::VerifierKind VK, bool ShouldPreserveAssemblyUseListOrder, diff --git a/llvm/tools/opt/optdriver.cpp b/llvm/tools/opt/optdriver.cpp index ac318e6bc1eb4..f8be9f16aada6 100644 --- a/llvm/tools/opt/optdriver.cpp +++ b/llvm/tools/opt/optdriver.cpp @@ -657,13 +657,6 @@ optMain(int argc, char **argv, return 1; } - TargetOptions CodeGenFlagsOptions; - const TargetOptions *Options = TM ? &TM->Options : &CodeGenFlagsOptions; - if (!TM) { - CodeGenFlagsOptions = - codegen::InitTargetOptionsFromCodeGenFlags(ModuleTriple); - } - // Override function attributes based on CPUStr, FeaturesStr, and command line // flags. codegen::setFunctionAttributes(CPUStr, FeaturesStr, *M); @@ -681,8 +674,13 @@ optMain(int argc, char **argv, M->addModuleFlag(Module::Error, "UnifiedLTO", 1); } + VectorLibrary VecLib = codegen::getVectorLibrary(); // Add an appropriate TargetLibraryInfo pass for the module's triple. - TargetLibraryInfoImpl TLII(ModuleTriple, Options->VecLib); + TargetLibraryInfoImpl TLII(ModuleTriple, VecLib); + + RTLIB::RuntimeLibcallsInfo RTLCI(ModuleTriple, codegen::getExceptionModel(), + codegen::getFloatABIForCalls(), + codegen::getEABIVersion(), ABIName, VecLib); // The -disable-simplify-libcalls flag actually disables all builtin optzns. if (DisableSimplifyLibCalls) @@ -758,7 +756,7 @@ optMain(int argc, char **argv, // string. Hand off the rest of the functionality to the new code for that // layer. if (!runPassPipeline( - argv[0], *M, TM.get(), &TLII, Out.get(), ThinLinkOut.get(), + argv[0], *M, TM.get(), &TLII, RTLCI, Out.get(), ThinLinkOut.get(), RemarksFile.get(), Pipeline, PluginList, PassBuilderCallbacks, OK, VK, /* ShouldPreserveAssemblyUseListOrder */ false, /* ShouldPreserveBitcodeUseListOrder */ true, EmitSummaryIndex, @@ -806,9 +804,6 @@ optMain(int argc, char **argv, (VerifyDebugInfoPreserve && !VerifyEachDebugInfoPreserve); Passes.add(new TargetLibraryInfoWrapperPass(TLII)); - Passes.add(new RuntimeLibraryInfoWrapper( - ModuleTriple, Options->ExceptionModel, Options->FloatABIType, - Options->EABIVersion, Options->MCOptions.ABIName, Options->VecLib)); // Add internal analysis passes from the target machine. Passes.add(createTargetTransformInfoWrapperPass(TM ? TM->getTargetIRAnalysis() _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
