diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index b967a26dd19d7..f1e20403ad668 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -481,6 +481,36 @@ static bool initTargetOptions(const CompilerInstance &CI, Options.JMCInstrument = CodeGenOpts.JMCInstrument; Options.XCOFFReadOnlyPointers = CodeGenOpts.XCOFFReadOnlyPointers; + switch (CodeGenOpts.getVecLib()) { + case llvm::driver::VectorLibrary::NoLibrary: + Options.VectorLibrary = llvm::VectorLibrary::NoLibrary; + break; + case llvm::driver::VectorLibrary::Accelerate: + Options.VectorLibrary = llvm::VectorLibrary::Accelerate; + break; + case llvm::driver::VectorLibrary::Darwin_libsystem_m: + Options.VectorLibrary = llvm::VectorLibrary::DarwinLibSystemM; + break; + case llvm::driver::VectorLibrary::LIBMVEC: + Options.VectorLibrary = llvm::VectorLibrary::LIBMVEC; + break; + case llvm::driver::VectorLibrary::MASSV: + Options.VectorLibrary = llvm::VectorLibrary::MASSV; + break; + case llvm::driver::VectorLibrary::SVML: + Options.VectorLibrary = llvm::VectorLibrary::SVML; + break; + case llvm::driver::VectorLibrary::SLEEF: + Options.VectorLibrary = llvm::VectorLibrary::SLEEFGNUABI; + break; + case llvm::driver::VectorLibrary::ArmPL: + Options.VectorLibrary = llvm::VectorLibrary::ArmPL; + break; + case llvm::driver::VectorLibrary::AMDLIBM: + Options.VectorLibrary = llvm::VectorLibrary::AMDLIBM; + break; + } + switch (CodeGenOpts.getSwiftAsyncFramePointer()) { case CodeGenOptions::SwiftAsyncFramePointerKind::Auto: Options.SwiftAsyncFramePointer = @@ -584,6 +614,7 @@ static void setCommandLineOpts(const CodeGenOptions &CodeGenOpts, BackendArgs.push_back("-limit-float-precision"); BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str()); } + // Check for the default "clang" invocation that won't set any cl::opt values. // Skip trying to parse the command line invocation to avoid the issues // described below. diff --git a/cross-project-tests/CMakeLists.txt b/cross-project-tests/CMakeLists.txt index 8e94579736537..3f932b8c7fd22 100644 --- a/cross-project-tests/CMakeLists.txt +++ b/cross-project-tests/CMakeLists.txt @@ -104,6 +104,13 @@ add_lit_testsuite(check-cross-dtlto "Running DTLTO cross-project tests" DEPENDS ${CROSS_PROJECT_TEST_DEPS} ) +# veclib tests. +add_lit_testsuite(check-cross-veclib "Running veclib cross-project tests" + ${CMAKE_CURRENT_BINARY_DIR}/veclib + EXCLUDE_FROM_CHECK_ALL + DEPENDS ${CROSS_PROJECT_TEST_DEPS} + ) + # Add check-cross-project-* targets. add_lit_testsuites(CROSS_PROJECT ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${CROSS_PROJECT_TEST_DEPS} diff --git a/cross-project-tests/veclib/lit.local.cfg b/cross-project-tests/veclib/lit.local.cfg new file mode 100644 index 0000000000000..530f4c01646ff --- /dev/null +++ b/cross-project-tests/veclib/lit.local.cfg @@ -0,0 +1,2 @@ +if "clang" not in config.available_features: + config.unsupported = True diff --git a/cross-project-tests/veclib/veclib-sincos.c b/cross-project-tests/veclib/veclib-sincos.c new file mode 100644 index 0000000000000..657d0df199522 --- /dev/null +++ b/cross-project-tests/veclib/veclib-sincos.c @@ -0,0 +1,21 @@ +// REQUIRES: aarch64-registered-target +// RUN: %clang -S -target aarch64-unknown-linux-gnu -O2 -fno-math-errno \ +// RUN: -fveclib=ArmPL -o - %s | FileCheck -check-prefix=ARMPL %s +// RUN: %clang -S -target aarch64-unknown-linux-gnu -O2 -fno-math-errno \ +// RUN: -fveclib=SLEEF -o - %s | FileCheck -check-prefix=SLEEF %s + +typedef __SIZE_TYPE__ size_t; + +void sincos(double, double *, double *); + +// ARMPL: armpl_vsincosq_f64 +// ARMPL: armpl_vsincosq_f64 + +// SLEEF: _ZGVnN2vl8l8_sincos +// SLEEF: _ZGVnN2vl8l8_sincos +void vectorize_sincos(double *restrict x, double *restrict s, + double *restrict c, size_t n) { + for (size_t i = 0; i < n; ++i) { + sincos(x[i], &s[i], &c[i]); + } +} diff --git a/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h b/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h index a3e1014b417e5..28a2ec47f81ad 100644 --- a/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h +++ b/llvm/include/llvm/Analysis/RuntimeLibcallInfo.h @@ -31,7 +31,7 @@ class LLVM_ABI RuntimeLibraryAnalysis friend AnalysisInfoMixin; LLVM_ABI static AnalysisKey Key; - RTLIB::RuntimeLibcallsInfo LibcallsInfo; + std::optional LibcallsInfo; }; class LLVM_ABI RuntimeLibraryInfoWrapper : public ImmutablePass { diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h index 78954431e81c3..3b6cc0d1944fd 100644 --- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h +++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h @@ -14,6 +14,7 @@ #include "llvm/IR/InstrTypes.h" #include "llvm/IR/Module.h" #include "llvm/IR/PassManager.h" +#include "llvm/IR/SystemLibraries.h" #include "llvm/Pass.h" #include "llvm/Support/Compiler.h" #include "llvm/TargetParser/Triple.h" @@ -23,7 +24,6 @@ namespace llvm { template class ArrayRef; -enum class VectorLibrary; /// Provides info so a possible vectorization of a function can be /// computed. Function 'VectorFnName' is equivalent to 'ScalarFnName' @@ -119,7 +119,8 @@ class TargetLibraryInfoImpl { public: TargetLibraryInfoImpl() = delete; - LLVM_ABI explicit TargetLibraryInfoImpl(const Triple &T); + LLVM_ABI explicit TargetLibraryInfoImpl( + const Triple &T, VectorLibrary VecLib = VectorLibrary::NoLibrary); // Provide value semantics. LLVM_ABI TargetLibraryInfoImpl(const TargetLibraryInfoImpl &TLI); diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h b/llvm/include/llvm/CodeGen/CommandFlags.h index 59aacc75e055d..6a907b64542ae 100644 --- a/llvm/include/llvm/CodeGen/CommandFlags.h +++ b/llvm/include/llvm/CodeGen/CommandFlags.h @@ -125,6 +125,8 @@ LLVM_ABI llvm::EABI getEABIVersion(); LLVM_ABI llvm::DebuggerKind getDebuggerTuningOpt(); +LLVM_ABI llvm::VectorLibrary getVectorLibrary(); + LLVM_ABI bool getEnableStackSizeSection(); LLVM_ABI bool getEnableAddrsig(); diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h index 0afe32a4ecc3c..cf96547063cd0 100644 --- a/llvm/include/llvm/IR/RuntimeLibcalls.h +++ b/llvm/include/llvm/IR/RuntimeLibcalls.h @@ -23,6 +23,7 @@ #include "llvm/IR/CallingConv.h" #include "llvm/IR/InstrTypes.h" #include "llvm/IR/PassManager.h" +#include "llvm/IR/SystemLibraries.h" #include "llvm/Support/AtomicOrdering.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/Compiler.h" @@ -83,7 +84,8 @@ struct RuntimeLibcallsInfo { const Triple &TT, ExceptionHandling ExceptionModel = ExceptionHandling::None, FloatABI::ABIType FloatABI = FloatABI::Default, - EABI EABIVersion = EABI::Default, StringRef ABIName = ""); + EABI EABIVersion = EABI::Default, StringRef ABIName = "", + VectorLibrary VecLib = VectorLibrary::NoLibrary); explicit RuntimeLibcallsInfo(const Module &M); diff --git a/llvm/include/llvm/IR/SystemLibraries.h b/llvm/include/llvm/IR/SystemLibraries.h index 1713b07c1c86f..5bdf67642e0e4 100644 --- a/llvm/include/llvm/IR/SystemLibraries.h +++ b/llvm/include/llvm/IR/SystemLibraries.h @@ -29,11 +29,6 @@ enum class VectorLibrary { AMDLIBM // AMD Math Vector library. }; -/// Command line flag value for the vector math library to use -/// -/// FIXME: This should come from a module flag, and not be mutually exclusive -extern VectorLibrary ClVectorLibrary; - } // namespace llvm #endif // LLVM_IR_SYSTEMLIBRARIES_H diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h index bfd2817b8d1f5..b9258c0fee692 100644 --- a/llvm/include/llvm/Target/TargetOptions.h +++ b/llvm/include/llvm/Target/TargetOptions.h @@ -15,6 +15,7 @@ #define LLVM_TARGET_TARGETOPTIONS_H #include "llvm/ADT/FloatingPointMode.h" +#include "llvm/IR/SystemLibraries.h" #include "llvm/MC/MCTargetOptions.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/Compiler.h" @@ -409,6 +410,9 @@ class TargetOptions { /// Which debugger to tune for. DebuggerKind DebuggerTuning = DebuggerKind::Default; + /// Vector math library to use. + VectorLibrary VectorLibrary = VectorLibrary::NoLibrary; + private: /// Flushing mode to assume in default FP environment. DenormalMode FPDenormalMode; diff --git a/llvm/lib/Analysis/RuntimeLibcallInfo.cpp b/llvm/lib/Analysis/RuntimeLibcallInfo.cpp index 6fb4119aa73f2..9ea789a4ee45a 100644 --- a/llvm/lib/Analysis/RuntimeLibcallInfo.cpp +++ b/llvm/lib/Analysis/RuntimeLibcallInfo.cpp @@ -15,7 +15,9 @@ AnalysisKey RuntimeLibraryAnalysis::Key; RTLIB::RuntimeLibcallsInfo RuntimeLibraryAnalysis::run(const Module &M, ModuleAnalysisManager &) { - return RTLIB::RuntimeLibcallsInfo(M); + if (!LibcallsInfo) + LibcallsInfo = RTLIB::RuntimeLibcallsInfo(M); + return *LibcallsInfo; } INITIALIZE_PASS(RuntimeLibraryInfoWrapper, "runtime-library-info", diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp index f97abc9a32707..26d0c108fb03a 100644 --- a/llvm/lib/Analysis/TargetLibraryInfo.cpp +++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp @@ -160,7 +160,8 @@ static void initializeBase(TargetLibraryInfoImpl &TLI, const Triple &T) { /// target triple. This should be carefully written so that a missing target /// triple gets a sane set of defaults. static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T, - ArrayRef StandardNames) { + ArrayRef StandardNames, + VectorLibrary VecLib) { // Set IO unlocked variants as unavailable // Set them as available per system below TLI.setUnavailable(LibFunc_getc_unlocked); @@ -924,23 +925,25 @@ static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T, if (T.isOSAIX()) TLI.setUnavailable(LibFunc_memrchr); - TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary, T); + TLI.addVectorizableFunctionsFromVecLib(VecLib, T); } /// Initialize the set of available library functions based on the specified /// target triple. This should be carefully written so that a missing target /// triple gets a sane set of defaults. static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, - ArrayRef StandardNames) { + ArrayRef StandardNames, + VectorLibrary VecLib) { initializeBase(TLI, T); - initializeLibCalls(TLI, T, StandardNames); + initializeLibCalls(TLI, T, StandardNames, VecLib); } -TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple &T) { +TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple &T, + VectorLibrary VecLib) { // Default to everything being available. memset(AvailableArray, -1, sizeof(AvailableArray)); - initialize(*this, T, StandardNames); + initialize(*this, T, StandardNames, VecLib); } TargetLibraryInfoImpl::TargetLibraryInfoImpl(const TargetLibraryInfoImpl &TLI) diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp index cf225f1f03eac..02a6bb9357ad0 100644 --- a/llvm/lib/CodeGen/CommandFlags.cpp +++ b/llvm/lib/CodeGen/CommandFlags.cpp @@ -107,6 +107,7 @@ CGOPT(bool, UniqueBasicBlockSectionNames) CGOPT(bool, SeparateNamedSections) CGOPT(EABI, EABIVersion) CGOPT(DebuggerKind, DebuggerTuningOpt) +CGOPT(VectorLibrary, VectorLibrary) CGOPT(bool, EnableStackSizeSection) CGOPT(bool, EnableAddrsig) CGOPT(bool, EnableCallGraphSection) @@ -451,6 +452,28 @@ codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() { clEnumValN(DebuggerKind::SCE, "sce", "SCE targets (e.g. PS4)"))); CGBINDOPT(DebuggerTuningOpt); + static cl::opt VectorLibrary( + "vector-library", cl::Hidden, cl::desc("Vector functions library"), + cl::init(VectorLibrary::NoLibrary), + cl::values( + clEnumValN(VectorLibrary::NoLibrary, "none", + "No vector functions library"), + clEnumValN(VectorLibrary::Accelerate, "Accelerate", + "Accelerate framework"), + clEnumValN(VectorLibrary::DarwinLibSystemM, "Darwin_libsystem_m", + "Darwin libsystem_m"), + clEnumValN(VectorLibrary::LIBMVEC, "LIBMVEC", + "GLIBC Vector Math library"), + clEnumValN(VectorLibrary::MASSV, "MASSV", "IBM MASS vector library"), + clEnumValN(VectorLibrary::SVML, "SVML", "Intel SVML library"), + clEnumValN(VectorLibrary::SLEEFGNUABI, "sleefgnuabi", + "SIMD Library for Evaluating Elementary Functions"), + clEnumValN(VectorLibrary::ArmPL, "ArmPL", + "Arm Performance Libraries"), + clEnumValN(VectorLibrary::AMDLIBM, "AMDLIBM", + "AMD vector math library"))); + CGBINDOPT(VectorLibrary); + static cl::opt EnableStackSizeSection( "stack-size-section", cl::desc("Emit a section containing stack size metadata"), @@ -609,6 +632,7 @@ codegen::InitTargetOptionsFromCodeGenFlags(const Triple &TheTriple) { Options.EnableTLSDESC = getExplicitEnableTLSDESC().value_or(TheTriple.hasDefaultTLSDESC()); Options.ExceptionModel = getExceptionModel(); + Options.VectorLibrary = getVectorLibrary(); Options.EmitStackSizeSection = getEnableStackSizeSection(); Options.EnableMachineFunctionSplitter = getEnableMachineFunctionSplitter(); Options.EnableStaticDataPartitioning = getEnableStaticDataPartitioning(); diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index 77d9b156e2672..0f1e37bbf1bfc 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -753,7 +753,8 @@ TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm) : TM(tm), RuntimeLibcallInfo(TM.getTargetTriple(), TM.Options.ExceptionModel, TM.Options.FloatABIType, TM.Options.EABIVersion, - TM.Options.MCOptions.getABIName()), + TM.Options.MCOptions.getABIName(), + TM.Options.VectorLibrary), Libcalls(RuntimeLibcallInfo) { initActions(); diff --git a/llvm/lib/IR/CMakeLists.txt b/llvm/lib/IR/CMakeLists.txt index ebdc2ca08d102..10572ff708bd3 100644 --- a/llvm/lib/IR/CMakeLists.txt +++ b/llvm/lib/IR/CMakeLists.txt @@ -67,7 +67,6 @@ add_llvm_component_library(LLVMCore ReplaceConstant.cpp Statepoint.cpp StructuralHash.cpp - SystemLibraries.cpp Type.cpp TypedPointerType.cpp TypeFinder.cpp diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp index ee23b58742b64..12d050329a302 100644 --- a/llvm/lib/IR/RuntimeLibcalls.cpp +++ b/llvm/lib/IR/RuntimeLibcalls.cpp @@ -29,7 +29,8 @@ using namespace RTLIB; RuntimeLibcallsInfo::RuntimeLibcallsInfo(const Triple &TT, ExceptionHandling ExceptionModel, FloatABI::ABIType FloatABI, - EABI EABIVersion, StringRef ABIName) { + EABI EABIVersion, StringRef ABIName, + VectorLibrary VecLib) { // FIXME: The ExceptionModel parameter is to handle the field in // TargetOptions. This interface fails to distinguish the forced disable // case for targets which support exceptions by default. This should @@ -40,7 +41,7 @@ RuntimeLibcallsInfo::RuntimeLibcallsInfo(const Triple &TT, initLibcalls(TT, ExceptionModel, FloatABI, EABIVersion, ABIName); // TODO: Tablegen should generate these sets - switch (ClVectorLibrary) { + switch (VecLib) { case VectorLibrary::SLEEFGNUABI: for (RTLIB::LibcallImpl Impl : {RTLIB::impl__ZGVnN2vl8_modf, RTLIB::impl__ZGVnN4vl4_modff, diff --git a/llvm/lib/IR/SystemLibraries.cpp b/llvm/lib/IR/SystemLibraries.cpp deleted file mode 100644 index fa4ac2adb7296..0000000000000 --- a/llvm/lib/IR/SystemLibraries.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===-----------------------------------------------------------------------==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "llvm/IR/SystemLibraries.h" -#include "llvm/Support/CommandLine.h" - -using namespace llvm; - -VectorLibrary llvm::ClVectorLibrary; - -static cl::opt ClVectorLibraryOpt( - "vector-library", cl::Hidden, cl::desc("Vector functions library"), - cl::location(llvm::ClVectorLibrary), cl::init(VectorLibrary::NoLibrary), - cl::values( - clEnumValN(VectorLibrary::NoLibrary, "none", - "No vector functions library"), - clEnumValN(VectorLibrary::Accelerate, "Accelerate", - "Accelerate framework"), - clEnumValN(VectorLibrary::DarwinLibSystemM, "Darwin_libsystem_m", - "Darwin libsystem_m"), - clEnumValN(VectorLibrary::LIBMVEC, "LIBMVEC", - "GLIBC Vector Math library"), - clEnumValN(VectorLibrary::MASSV, "MASSV", "IBM MASS vector library"), - clEnumValN(VectorLibrary::SVML, "SVML", "Intel SVML library"), - clEnumValN(VectorLibrary::SLEEFGNUABI, "sleefgnuabi", - "SIMD Library for Evaluating Elementary Functions"), - clEnumValN(VectorLibrary::ArmPL, "ArmPL", "Arm Performance Libraries"), - clEnumValN(VectorLibrary::AMDLIBM, "AMDLIBM", - "AMD vector math library"))); diff --git a/llvm/lib/Transforms/Utils/DeclareRuntimeLibcalls.cpp b/llvm/lib/Transforms/Utils/DeclareRuntimeLibcalls.cpp index dd8706cfb2855..94e8a33813b63 100644 --- a/llvm/lib/Transforms/Utils/DeclareRuntimeLibcalls.cpp +++ b/llvm/lib/Transforms/Utils/DeclareRuntimeLibcalls.cpp @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Utils/DeclareRuntimeLibcalls.h" +#include "llvm/Analysis/RuntimeLibcallInfo.h" #include "llvm/IR/Module.h" #include "llvm/IR/RuntimeLibcalls.h" @@ -49,7 +50,9 @@ static void mergeAttributes(LLVMContext &Ctx, const Module &M, PreservedAnalyses DeclareRuntimeLibcallsPass::run(Module &M, ModuleAnalysisManager &MAM) { - RTLIB::RuntimeLibcallsInfo RTLCI(M.getTargetTriple()); + const RTLIB::RuntimeLibcallsInfo &RTLCI = + MAM.getResult(M); + LLVMContext &Ctx = M.getContext(); const DataLayout &DL = M.getDataLayout(); const Triple &TT = M.getTargetTriple(); diff --git a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/codegen-opt-flags.ll b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/codegen-opt-flags.ll new file mode 100644 index 0000000000000..a5da90da6a74a --- /dev/null +++ b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/codegen-opt-flags.ll @@ -0,0 +1,17 @@ +; REQUIRES: arm-registered-target + +; Make sure that codegen flags work to change the set of libcalls +; RUN: opt -S -passes=declare-runtime-libcalls -mtriple=arm-none-linux-gnueabi -float-abi=hard -exception-model=sjlj -meabi=4 < %s | FileCheck %s + +; Depends on -exception-model +; CHECK: declare arm_aapcs_vfpcc void @_Unwind_SjLj_Register(...) +; CHECK: declare arm_aapcs_vfpcc void @_Unwind_SjLj_Resume(...) +; CHECK: declare arm_aapcs_vfpcc void @_Unwind_SjLj_Unregister(...) + +; Calling convention depends on -float-abi +; CHECK: declare arm_aapcs_vfpcc void @__addtf3(...) + +; memclr functions depend on -meabi +; CHECK: declare arm_aapcscc void @__aeabi_memclr(...) +; CHECK: declare arm_aapcscc void @__aeabi_memclr4(...) +; CHECK: declare arm_aapcscc void @__aeabi_memclr8(...) diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp index 2147945d8a416..1cfedad15ec35 100644 --- a/llvm/tools/llc/llc.cpp +++ b/llvm/tools/llc/llc.cpp @@ -696,7 +696,8 @@ static int compileModule(char **argv, LLVMContext &Context, } // Add an appropriate TargetLibraryInfo pass for the module's triple. - TargetLibraryInfoImpl TLII(M->getTargetTriple()); + TargetLibraryInfoImpl TLII(M->getTargetTriple(), + Target->Options.VectorLibrary); // The -disable-simplify-libcalls flag actually disables all builtin optzns. if (DisableSimplifyLibCalls) diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp index a383415ff1cb2..01d7ac8e3f959 100644 --- a/llvm/tools/opt/NewPMDriver.cpp +++ b/llvm/tools/opt/NewPMDriver.cpp @@ -18,6 +18,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/CGSCCPassManager.h" +#include "llvm/Analysis/RuntimeLibcallInfo.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Bitcode/BitcodeWriterPass.h" #include "llvm/Config/llvm-config.h" @@ -351,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 PassPlugins, + RTLIB::RuntimeLibcallsInfo &RTLCI, ToolOutputFile *Out, + ToolOutputFile *ThinLTOLinkOut, ToolOutputFile *OptRemarkFile, + StringRef PassPipeline, ArrayRef PassPlugins, ArrayRef> PassBuilderCallbacks, OutputKind OK, VerifierKind VK, bool ShouldPreserveAssemblyUseListOrder, bool ShouldPreserveBitcodeUseListOrder, bool EmitSummaryIndex, @@ -416,6 +417,7 @@ bool llvm::runPassPipeline( FunctionAnalysisManager FAM; CGSCCAnalysisManager CGAM; ModuleAnalysisManager MAM; + 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 DebugifyEach; extern cl::opt 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 PassPlugins, + RTLIB::RuntimeLibcallsInfo &RTLCI, ToolOutputFile *Out, + ToolOutputFile *ThinLinkOut, ToolOutputFile *OptRemarkFile, + StringRef PassPipeline, ArrayRef PassPlugins, ArrayRef> 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 ef6e5412bda48..d24c8abef31d0 100644 --- a/llvm/tools/opt/optdriver.cpp +++ b/llvm/tools/opt/optdriver.cpp @@ -17,6 +17,7 @@ #include "llvm/Analysis/CallGraphSCCPass.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/RegionPass.h" +#include "llvm/Analysis/RuntimeLibcallInfo.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/AsmParser/Parser.h" @@ -669,8 +670,15 @@ 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); + TargetLibraryInfoImpl TLII(ModuleTriple, VecLib); + + RTLIB::RuntimeLibcallsInfo RTLCI(ModuleTriple, codegen::getExceptionModel(), + codegen::getFloatABIForCalls(), + codegen::getEABIVersion(), + "", // FIXME: Get ABI name from MCOptions + VecLib); // The -disable-simplify-libcalls flag actually disables all builtin optzns. if (DisableSimplifyLibCalls) @@ -746,7 +754,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, diff --git a/llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn index 8037c8d693cb8..22aa0b6418132 100644 --- a/llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn @@ -82,7 +82,6 @@ static_library("IR") { "SafepointIRVerifier.cpp", "Statepoint.cpp", "StructuralHash.cpp", - "SystemLibraries.cpp", "Type.cpp", "TypeFinder.cpp", "TypedPointerType.cpp",