diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 04cb9064dc789..e2afc5d566281 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -314,12 +314,12 @@ getCodeModel(const CodeGenOptions &CodeGenOpts) { static CodeGenFileType getCodeGenFileType(BackendAction Action) { if (Action == Backend_EmitObj) - return CGFT_ObjectFile; + return CodeGenFileType::ObjectFile; else if (Action == Backend_EmitMCNull) - return CGFT_Null; + return CodeGenFileType::Null; else { assert(Action == Backend_EmitAssembly && "Invalid action!"); - return CGFT_AssemblyFile; + return CodeGenFileType::AssemblyFile; } } @@ -561,10 +561,10 @@ void EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) { std::string FeaturesStr = llvm::join(TargetOpts.Features.begin(), TargetOpts.Features.end(), ","); llvm::Reloc::Model RM = CodeGenOpts.RelocationModel; - std::optional OptLevelOrNone = + std::optional OptLevelOrNone = CodeGenOpt::getLevel(CodeGenOpts.OptimizationLevel); assert(OptLevelOrNone && "Invalid optimization level!"); - CodeGenOpt::Level OptLevel = *OptLevelOrNone; + CodeGenOptLevel OptLevel = *OptLevelOrNone; llvm::TargetOptions Options; if (!initTargetOptions(Diags, Options, CodeGenOpts, TargetOpts, LangOpts, @@ -1216,7 +1216,7 @@ static void runThinLTOBackend( Conf.CodeModel = getCodeModel(CGOpts); Conf.MAttrs = TOpts.Features; Conf.RelocModel = CGOpts.RelocationModel; - std::optional OptLevelOrNone = + std::optional OptLevelOrNone = CodeGenOpt::getLevel(CGOpts.OptimizationLevel); assert(OptLevelOrNone && "Invalid optimization level!"); Conf.CGOptLevel = *OptLevelOrNone; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 2dd299b5d1032..ffb4f30db0243 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -661,27 +661,27 @@ static bool FixupInvocation(CompilerInvocation &Invocation, static unsigned getOptimizationLevel(ArgList &Args, InputKind IK, DiagnosticsEngine &Diags) { - unsigned DefaultOpt = llvm::CodeGenOpt::None; + unsigned DefaultOpt = 0; if ((IK.getLanguage() == Language::OpenCL || IK.getLanguage() == Language::OpenCLCXX) && !Args.hasArg(OPT_cl_opt_disable)) - DefaultOpt = llvm::CodeGenOpt::Default; + DefaultOpt = 2; if (Arg *A = Args.getLastArg(options::OPT_O_Group)) { if (A->getOption().matches(options::OPT_O0)) - return llvm::CodeGenOpt::None; + return 0; if (A->getOption().matches(options::OPT_Ofast)) - return llvm::CodeGenOpt::Aggressive; + return 3; assert(A->getOption().matches(options::OPT_O)); StringRef S(A->getValue()); if (S == "s" || S == "z") - return llvm::CodeGenOpt::Default; + return 2; if (S == "g") - return llvm::CodeGenOpt::Less; + return 1; return getLastArgIntValue(Args, OPT_O, DefaultOpt, Diags); } diff --git a/clang/lib/Interpreter/DeviceOffload.cpp b/clang/lib/Interpreter/DeviceOffload.cpp index 8e39af6abf9d3..fb42964e4936f 100644 --- a/clang/lib/Interpreter/DeviceOffload.cpp +++ b/clang/lib/Interpreter/DeviceOffload.cpp @@ -88,7 +88,7 @@ llvm::Expected IncrementalCUDADeviceParser::GeneratePTX() { llvm::legacy::PassManager PM; if (TargetMachine->addPassesToEmitFile(PM, dest, nullptr, - llvm::CGFT_AssemblyFile)) { + llvm::CodeGenFileType::AssemblyFile)) { return llvm::make_error( "NVPTX backend cannot produce PTX code.", llvm::inconvertibleErrorCode()); diff --git a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp index bd3490e802e44..3d39d69e6c2b4 100644 --- a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp +++ b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp @@ -48,10 +48,9 @@ using namespace llvm; typedef void (*LLVMFunc)(int*, int*, int*, int); // Helper function to parse command line args and find the optimization level -static CodeGenOpt::Level -getOptLevel(const std::vector &ExtraArgs) { +static CodeGenOptLevel getOptLevel(const std::vector &ExtraArgs) { // Find the optimization level from the command line args - CodeGenOpt::Level OLvl = CodeGenOpt::Default; + CodeGenOptLevel OLvl = CodeGenOptLevel::Default; for (auto &A : ExtraArgs) { if (A[0] == '-' && A[1] == 'O') { if (auto Level = CodeGenOpt::parseLevel(A[2])) { @@ -73,19 +72,19 @@ static void ErrorAndExit(std::string message) { // Helper function to add optimization passes to the TargetMachine at the // specified optimization level, OptLevel static void RunOptimizationPasses(raw_ostream &OS, Module &M, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { llvm::OptimizationLevel OL; switch (OptLevel) { - case CodeGenOpt::None: + case CodeGenOptLevel::None: OL = OptimizationLevel::O0; break; - case CodeGenOpt::Less: + case CodeGenOptLevel::Less: OL = OptimizationLevel::O1; break; - case CodeGenOpt::Default: + case CodeGenOptLevel::Default: OL = OptimizationLevel::O2; break; - case CodeGenOpt::Aggressive: + case CodeGenOptLevel::Aggressive: OL = OptimizationLevel::O3; break; } @@ -110,7 +109,7 @@ static void RunOptimizationPasses(raw_ostream &OS, Module &M, } // Mimics the opt tool to run an optimization pass over the provided IR -static std::string OptLLVM(const std::string &IR, CodeGenOpt::Level OLvl) { +static std::string OptLLVM(const std::string &IR, CodeGenOptLevel OLvl) { // Create a module that will run the optimization passes SMDiagnostic Err; LLVMContext Context; @@ -154,7 +153,7 @@ static void RunFuncOnInputs(LLVMFunc f, int Arr[kNumArrays][kArraySize]) { } // Takes a string of IR and compiles it using LLVM's JIT Engine -static void CreateAndRunJITFunc(const std::string &IR, CodeGenOpt::Level OLvl) { +static void CreateAndRunJITFunc(const std::string &IR, CodeGenOptLevel OLvl) { SMDiagnostic Err; LLVMContext Context; std::unique_ptr M = parseIR(MemoryBufferRef(IR, "IR"), Err, Context); @@ -205,7 +204,7 @@ static void CreateAndRunJITFunc(const std::string &IR, CodeGenOpt::Level OLvl) { #endif // Figure out if we are running the optimized func or the unoptimized func - RunFuncOnInputs(f, (OLvl == CodeGenOpt::None) ? UnoptArrays : OptArrays); + RunFuncOnInputs(f, (OLvl == CodeGenOptLevel::None) ? UnoptArrays : OptArrays); EE->runStaticConstructorsDestructors(true); } @@ -219,13 +218,13 @@ void clang_fuzzer::HandleLLVM(const std::string &IR, memcpy(UnoptArrays, InputArrays, kTotalSize); // Parse ExtraArgs to set the optimization level - CodeGenOpt::Level OLvl = getOptLevel(ExtraArgs); + CodeGenOptLevel OLvl = getOptLevel(ExtraArgs); // First we optimize the IR by running a loop vectorizer pass std::string OptIR = OptLLVM(IR, OLvl); CreateAndRunJITFunc(OptIR, OLvl); - CreateAndRunJITFunc(IR, CodeGenOpt::None); + CreateAndRunJITFunc(IR, CodeGenOptLevel::None); if (memcmp(OptArrays, UnoptArrays, kTotalSize)) ErrorAndExit("!!!BUG!!!"); diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 432a34730f923..b5f6fb35f2273 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -528,7 +528,7 @@ std::unique_ptr createLTO( StringRef OptLevel = Args.getLastArgValue(OPT_opt_level, "O2"); Conf.MAttrs = Features; - std::optional CGOptLevelOrNone = + std::optional CGOptLevelOrNone = CodeGenOpt::parseLevel(OptLevel[1]); assert(CGOptLevelOrNone && "Invalid optimization level"); Conf.CGOptLevel = *CGOptLevelOrNone; @@ -569,8 +569,9 @@ std::unique_ptr createLTO( }; } Conf.PostOptModuleHook = Hook; - Conf.CGFileType = - (Triple.isNVPTX() || SaveTemps) ? CGFT_AssemblyFile : CGFT_ObjectFile; + Conf.CGFileType = (Triple.isNVPTX() || SaveTemps) + ? CodeGenFileType::AssemblyFile + : CodeGenFileType::ObjectFile; // TODO: Handle remark files Conf.HasWholeProgramVisibility = Args.hasArg(OPT_whole_program); @@ -840,7 +841,8 @@ Expected compileModule(Module &M) { legacy::PassManager CodeGenPasses; TargetLibraryInfoImpl TLII(Triple(M.getTargetTriple())); CodeGenPasses.add(new TargetLibraryInfoWrapperPass(TLII)); - if (TM->addPassesToEmitFile(CodeGenPasses, *OS, nullptr, CGFT_ObjectFile)) + if (TM->addPassesToEmitFile(CodeGenPasses, *OS, nullptr, + CodeGenFileType::ObjectFile)) return createStringError(inconvertibleErrorCode(), "Failed to execute host backend"); CodeGenPasses.run(M); diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index dba2ac1a335f9..6c0b90cfac434 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -98,12 +98,12 @@ static bool parseShowColorsArgs(const llvm::opt::ArgList &args, /// Extracts the optimisation level from \a args. static unsigned getOptimizationLevel(llvm::opt::ArgList &args, clang::DiagnosticsEngine &diags) { - unsigned defaultOpt = llvm::CodeGenOpt::None; + unsigned defaultOpt = 0; if (llvm::opt::Arg *a = args.getLastArg(clang::driver::options::OPT_O_Group)) { if (a->getOption().matches(clang::driver::options::OPT_O0)) - return llvm::CodeGenOpt::None; + return 0; assert(a->getOption().matches(clang::driver::options::OPT_O)); diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp index 3ca667e64ec25..1cb253a9c0416 100644 --- a/flang/lib/Frontend/FrontendActions.cpp +++ b/flang/lib/Frontend/FrontendActions.cpp @@ -777,10 +777,10 @@ bool CodeGenAction::setUpTargetMachine() { // Create `TargetMachine` const auto &CGOpts = ci.getInvocation().getCodeGenOpts(); - std::optional OptLevelOrNone = + std::optional OptLevelOrNone = llvm::CodeGenOpt::getLevel(CGOpts.OptimizationLevel); assert(OptLevelOrNone && "Invalid optimization level!"); - llvm::CodeGenOpt::Level OptLevel = *OptLevelOrNone; + llvm::CodeGenOptLevel OptLevel = *OptLevelOrNone; std::string featuresStr = getTargetFeatures(ci); tm.reset(theTarget->createTargetMachine( theTriple, /*CPU=*/targetOpts.cpu, @@ -848,8 +848,8 @@ static void generateMachineCodeOrAssemblyImpl(clang::DiagnosticsEngine &diags, codeGenPasses.add(new llvm::TargetLibraryInfoWrapperPass(*tlii)); llvm::CodeGenFileType cgft = (act == BackendActionTy::Backend_EmitAssembly) - ? llvm::CodeGenFileType::CGFT_AssemblyFile - : llvm::CodeGenFileType::CGFT_ObjectFile; + ? llvm::CodeGenFileType::AssemblyFile + : llvm::CodeGenFileType::ObjectFile; if (tm.addPassesToEmitFile(codeGenPasses, os, nullptr, cgft)) { unsigned diagID = diags.getCustomDiagID(clang::DiagnosticsEngine::Error, diff --git a/lld/COFF/LTO.cpp b/lld/COFF/LTO.cpp index 67f5a62920e98..c185da5370fa3 100644 --- a/lld/COFF/LTO.cpp +++ b/lld/COFF/LTO.cpp @@ -88,7 +88,7 @@ lto::Config BitcodeCompiler::createConfig() { c.OptLevel = ctx.config.ltoo; c.CPU = getCPUStr(); c.MAttrs = getMAttrs(); - std::optional optLevelOrNone = CodeGenOpt::getLevel( + std::optional optLevelOrNone = CodeGenOpt::getLevel( ctx.config.ltoCgo.value_or(args::getCGOptLevel(ctx.config.ltoo))); assert(optLevelOrNone && "Invalid optimization level!"); c.CGOptLevel = *optLevelOrNone; diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index 3e93a0e654dca..5d58fc13256f9 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -341,7 +341,7 @@ struct Config { uint64_t zStackSize; unsigned ltoPartitions; unsigned ltoo; - llvm::CodeGenOpt::Level ltoCgo; + llvm::CodeGenOptLevel ltoCgo; unsigned optimize; StringRef thinLTOJobs; unsigned timeTraceGranularity; diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp index e8bfa903726d0..1e68d20022c05 100644 --- a/lld/ELF/LTO.cpp +++ b/lld/ELF/LTO.cpp @@ -174,7 +174,7 @@ static lto::Config createConfig() { } if (config->ltoEmitAsm) { - c.CGFileType = CGFT_AssemblyFile; + c.CGFileType = CodeGenFileType::AssemblyFile; c.Options.MCOptions.AsmVerbose = true; } diff --git a/lld/MachO/Config.h b/lld/MachO/Config.h index 3191396f65b83..f820513a111ea 100644 --- a/lld/MachO/Config.h +++ b/lld/MachO/Config.h @@ -26,9 +26,9 @@ #include -namespace llvm::CodeGenOpt { -enum Level : int; -} // namespace llvm::CodeGenOpt +namespace llvm { +enum class CodeGenOptLevel; +} // namespace llvm namespace lld { namespace macho { @@ -167,7 +167,7 @@ struct Configuration { llvm::StringRef thinLTOJobs; llvm::StringRef umbrella; uint32_t ltoo = 2; - llvm::CodeGenOpt::Level ltoCgo; + llvm::CodeGenOptLevel ltoCgo; llvm::CachePruningPolicy thinLTOCachePolicy; llvm::StringRef thinLTOCacheDir; llvm::StringRef thinLTOIndexOnlyArg; diff --git a/lld/wasm/Config.h b/lld/wasm/Config.h index 2ca92674d6dc5..876c7e80ba80d 100644 --- a/lld/wasm/Config.h +++ b/lld/wasm/Config.h @@ -16,9 +16,9 @@ #include "llvm/Support/CachePruning.h" #include -namespace llvm::CodeGenOpt { -enum Level : int; -} // namespace llvm::CodeGenOpt +namespace llvm { +enum class CodeGenOptLevel; +} // namespace llvm namespace lld::wasm { @@ -72,7 +72,7 @@ struct Configuration { uint64_t zStackSize; unsigned ltoPartitions; unsigned ltoo; - llvm::CodeGenOpt::Level ltoCgo; + llvm::CodeGenOptLevel ltoCgo; unsigned optimize; llvm::StringRef thinLTOJobs; bool ltoDebugPassManager; diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index ac9cea7e731f0..562bf3cdd2ed0 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -285,7 +285,7 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr, .setRelocationModel(triple.isOSBinFormatMachO() ? llvm::Reloc::PIC_ : llvm::Reloc::Static) .setMCJITMemoryManager(std::make_unique(*this)) - .setOptLevel(llvm::CodeGenOpt::Less); + .setOptLevel(llvm::CodeGenOptLevel::Less); llvm::StringRef mArch; llvm::StringRef mCPU; diff --git a/llvm/docs/OptBisect.rst b/llvm/docs/OptBisect.rst index a0dc2bd8fdf80..809f54883e5a9 100644 --- a/llvm/docs/OptBisect.rst +++ b/llvm/docs/OptBisect.rst @@ -19,7 +19,7 @@ skipped while still allowing correct code generation call a function to check the opt-bisect limit before performing optimizations. Passes which either must be run or do not modify the IR do not perform this check and are therefore never skipped. Generally, this means analysis passes, passes -that are run at CodeGenOpt::None and passes which are required for register +that are run at CodeGenOptLevel::None and passes which are required for register allocation. The -opt-bisect-limit option can be used with any tool, including front ends diff --git a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl08.rst b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl08.rst index 6c7034eb2b84d..33ee7d209d4c5 100644 --- a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl08.rst +++ b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl08.rst @@ -155,7 +155,7 @@ pass: .. code-block:: c++ legacy::PassManager pass; - auto FileType = CGFT_ObjectFile; + auto FileType = CodeGenFileType::ObjectFile; if (TargetMachine->addPassesToEmitFile(pass, dest, nullptr, FileType)) { errs() << "TargetMachine can't emit a file of this type"; diff --git a/llvm/examples/Kaleidoscope/Chapter8/toy.cpp b/llvm/examples/Kaleidoscope/Chapter8/toy.cpp index 3ebc36aa5e899..1d36a7e67e3d2 100644 --- a/llvm/examples/Kaleidoscope/Chapter8/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter8/toy.cpp @@ -1258,7 +1258,7 @@ int main() { } legacy::PassManager pass; - auto FileType = CGFT_ObjectFile; + auto FileType = CodeGenFileType::ObjectFile; if (TheTargetMachine->addPassesToEmitFile(pass, dest, nullptr, FileType)) { errs() << "TheTargetMachine can't emit a file of this type"; diff --git a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h index 9236f14a3c864..d7739e8bb597e 100644 --- a/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h +++ b/llvm/include/llvm/CodeGen/CodeGenPassBuilder.h @@ -115,7 +115,7 @@ template class CodeGenPassBuilder { TM.Options.GlobalISelAbort = *Opt.EnableGlobalISelAbort; if (!Opt.OptimizeRegAlloc) - Opt.OptimizeRegAlloc = getOptLevel() != CodeGenOpt::None; + Opt.OptimizeRegAlloc = getOptLevel() != CodeGenOptLevel::None; } Error buildPipeline(ModulePassManager &MPM, MachineFunctionPassManager &MFPM, @@ -243,7 +243,7 @@ template class CodeGenPassBuilder { } template TMC &getTM() const { return static_cast(TM); } - CodeGenOpt::Level getOptLevel() const { return TM.getOptLevel(); } + CodeGenOptLevel getOptLevel() const { return TM.getOptLevel(); } /// Check whether or not GlobalISel should abort on error. /// When this is disabled, GlobalISel will fall back on SDISel instead of @@ -597,7 +597,7 @@ void CodeGenPassBuilder::addIRPasses(AddIRPass &addPass) const { addPass(VerifierPass()); // Run loop strength reduction before anything else. - if (getOptLevel() != CodeGenOpt::None && !Opt.DisableLSR) { + if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableLSR) { addPass(createFunctionToLoopPassAdaptor( LoopStrengthReducePass(), /*UseMemorySSA*/ true, Opt.DebugPM)); // FIXME: use -stop-after so we could remove PrintLSR @@ -605,7 +605,7 @@ void CodeGenPassBuilder::addIRPasses(AddIRPass &addPass) const { addPass(PrintFunctionPass(dbgs(), "\n\n*** Code after LSR ***\n")); } - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { // The MergeICmpsPass tries to create memcmp calls by grouping sequences of // loads and compares. ExpandMemCmpPass then tries to expand those calls // into optimally-sized loads and compares. The transforms are enabled by a @@ -625,15 +625,16 @@ void CodeGenPassBuilder::addIRPasses(AddIRPass &addPass) const { addPass(UnreachableBlockElimPass()); // Prepare expensive constants for SelectionDAG. - if (getOptLevel() != CodeGenOpt::None && !Opt.DisableConstantHoisting) + if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableConstantHoisting) addPass(ConstantHoistingPass()); // Replace calls to LLVM intrinsics (e.g., exp, log) operating on vector // operands with calls to the corresponding functions in a vector library. - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(ReplaceWithVeclib()); - if (getOptLevel() != CodeGenOpt::None && !Opt.DisablePartialLibcallInlining) + if (getOptLevel() != CodeGenOptLevel::None && + !Opt.DisablePartialLibcallInlining) addPass(PartiallyInlineLibCallsPass()); // Instrument function entry and exit, e.g. with calls to mcount(). @@ -648,7 +649,7 @@ void CodeGenPassBuilder::addIRPasses(AddIRPass &addPass) const { addPass(ExpandReductionsPass()); // Convert conditional moves to conditional jumps when profitable. - if (getOptLevel() != CodeGenOpt::None && !Opt.DisableSelectOptimize) + if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize) addPass(SelectOptimizePass()); } @@ -702,7 +703,7 @@ void CodeGenPassBuilder::addPassesToHandleExceptions( /// before exception handling preparation passes. template void CodeGenPassBuilder::addCodeGenPrepare(AddIRPass &addPass) const { - if (getOptLevel() != CodeGenOpt::None && !Opt.DisableCGP) + if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableCGP) addPass(CodeGenPreparePass()); // TODO: Default ctor'd RewriteSymbolPass is no-op. // addPass(RewriteSymbolPass()); @@ -748,7 +749,7 @@ Error CodeGenPassBuilder::addCoreISelPasses( (!Opt.EnableGlobalISelOption || *Opt.EnableGlobalISelOption == false))) Selector = SelectorType::GlobalISel; - else if (TM.getOptLevel() == CodeGenOpt::None && TM.getO0WantsFastISel()) + else if (TM.getOptLevel() == CodeGenOptLevel::None && TM.getO0WantsFastISel()) Selector = SelectorType::FastISel; else Selector = SelectorType::SelectionDAG; @@ -826,7 +827,7 @@ template Error CodeGenPassBuilder::addMachinePasses( AddMachinePass &addPass) const { // Add passes that optimize machine instructions in SSA form. - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { derived().addMachineSSAOptimization(addPass); } else { // If the target requests it, assign local variables to stack slots relative @@ -855,7 +856,7 @@ Error CodeGenPassBuilder::addMachinePasses( addPass(RemoveRedundantDebugValuesPass()); // Insert prolog/epilog code. Eliminate abstract frame index references... - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { addPass(PostRAMachineSinkingPass()); addPass(ShrinkWrapPass()); } @@ -863,7 +864,7 @@ Error CodeGenPassBuilder::addMachinePasses( addPass(PrologEpilogInserterPass()); /// Add passes that optimize machine instructions after register allocation. - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) derived().addMachineLateOptimization(addPass); // Expand pseudo instructions before second scheduling pass. @@ -878,7 +879,7 @@ Error CodeGenPassBuilder::addMachinePasses( // Second pass scheduler. // Let Target optionally insert this pass by itself at some other // point. - if (getOptLevel() != CodeGenOpt::None && + if (getOptLevel() != CodeGenOptLevel::None && !TM.targetSchedulesPostRAScheduling()) { if (Opt.MISchedPostRA) addPass(PostMachineSchedulerPass()); @@ -890,7 +891,7 @@ Error CodeGenPassBuilder::addMachinePasses( derived().addGCPasses(addPass); // Basic block placement. - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) derived().addBlockPlacement(addPass); // Insert before XRay Instrumentation. @@ -912,7 +913,8 @@ Error CodeGenPassBuilder::addMachinePasses( addPass(LiveDebugValuesPass()); addPass(MachineSanitizerBinaryMetadata()); - if (TM.Options.EnableMachineOutliner && getOptLevel() != CodeGenOpt::None && + if (TM.Options.EnableMachineOutliner && + getOptLevel() != CodeGenOptLevel::None && Opt.EnableMachineOutliner != RunOutliner::NeverOutline) { bool RunOnAllFunctions = (Opt.EnableMachineOutliner == RunOutliner::AlwaysOutline); diff --git a/llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h index 09d6192a2bd5c..816e94362f026 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h @@ -54,7 +54,7 @@ class CSEConfigConstantOnly : public CSEConfigBase { // TargetPassConfig, but can't put this logic into TargetPassConfig directly // because the CodeGen library can't depend on GlobalISel. std::unique_ptr -getStandardCSEConfigForOpt(CodeGenOpt::Level Level); +getStandardCSEConfigForOpt(CodeGenOptLevel Level); /// The CSE Analysis object. /// This installs itself as a delegate to the MachineFunction to track diff --git a/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h b/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h index 0f803bf6c538e..bffc03ed0187e 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h @@ -579,7 +579,7 @@ class IRTranslator : public MachineFunctionPass { /// Current target configuration. Controls how the pass handles errors. const TargetPassConfig *TPC = nullptr; - CodeGenOpt::Level OptLevel; + CodeGenOptLevel OptLevel; /// Current optimization remark emitter. Used to report failures. std::unique_ptr ORE; @@ -716,7 +716,7 @@ class IRTranslator : public MachineFunctionPass { BranchProbability Prob = BranchProbability::getUnknown()); public: - IRTranslator(CodeGenOpt::Level OptLevel = CodeGenOpt::None); + IRTranslator(CodeGenOptLevel OptLevel = CodeGenOptLevel::None); StringRef getPassName() const override { return "IRTranslator"; } diff --git a/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelect.h b/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelect.h index 60c7694725a5a..cada7f30072e2 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelect.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/InstructionSelect.h @@ -49,7 +49,7 @@ class InstructionSelect : public MachineFunctionPass { MachineFunctionProperties::Property::Selected); } - InstructionSelect(CodeGenOpt::Level OL); + InstructionSelect(CodeGenOptLevel OL); InstructionSelect(); bool runOnMachineFunction(MachineFunction &MF) override; @@ -58,7 +58,7 @@ class InstructionSelect : public MachineFunctionPass { BlockFrequencyInfo *BFI = nullptr; ProfileSummaryInfo *PSI = nullptr; - CodeGenOpt::Level OptLevel = CodeGenOpt::None; + CodeGenOptLevel OptLevel = CodeGenOptLevel::None; }; } // End namespace llvm. diff --git a/llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h b/llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h index 565d1c36d3001..6f56682dce5fa 100644 --- a/llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h +++ b/llvm/include/llvm/CodeGen/LinkAllCodegenComponents.h @@ -37,16 +37,18 @@ namespace { (void) llvm::createGreedyRegisterAllocator(); (void) llvm::createDefaultPBQPRegisterAllocator(); - (void) llvm::createBURRListDAGScheduler(nullptr, - llvm::CodeGenOpt::Default); - (void) llvm::createSourceListDAGScheduler(nullptr, - llvm::CodeGenOpt::Default); - (void) llvm::createHybridListDAGScheduler(nullptr, - llvm::CodeGenOpt::Default); - (void) llvm::createFastDAGScheduler(nullptr, llvm::CodeGenOpt::Default); - (void) llvm::createDefaultScheduler(nullptr, llvm::CodeGenOpt::Default); - (void) llvm::createVLIWDAGScheduler(nullptr, llvm::CodeGenOpt::Default); - + (void)llvm::createBURRListDAGScheduler(nullptr, + llvm::CodeGenOptLevel::Default); + (void)llvm::createSourceListDAGScheduler(nullptr, + llvm::CodeGenOptLevel::Default); + (void)llvm::createHybridListDAGScheduler(nullptr, + llvm::CodeGenOptLevel::Default); + (void)llvm::createFastDAGScheduler(nullptr, + llvm::CodeGenOptLevel::Default); + (void)llvm::createDefaultScheduler(nullptr, + llvm::CodeGenOptLevel::Default); + (void)llvm::createVLIWDAGScheduler(nullptr, + llvm::CodeGenOptLevel::Default); } } ForceCodegenLinking; // Force link by creating a global definition. } diff --git a/llvm/include/llvm/CodeGen/ParallelCG.h b/llvm/include/llvm/CodeGen/ParallelCG.h index 70ce2ff474213..fc50dc1442541 100644 --- a/llvm/include/llvm/CodeGen/ParallelCG.h +++ b/llvm/include/llvm/CodeGen/ParallelCG.h @@ -36,7 +36,8 @@ void splitCodeGen( Module &M, ArrayRef OSs, ArrayRef BCOSs, const std::function()> &TMFactory, - CodeGenFileType FileType = CGFT_ObjectFile, bool PreserveLocals = false); + CodeGenFileType FileType = CodeGenFileType::ObjectFile, + bool PreserveLocals = false); } // namespace llvm diff --git a/llvm/include/llvm/CodeGen/Passes.h b/llvm/include/llvm/CodeGen/Passes.h index 04888ad90b5d5..befa8a6eb9a27 100644 --- a/llvm/include/llvm/CodeGen/Passes.h +++ b/llvm/include/llvm/CodeGen/Passes.h @@ -393,7 +393,7 @@ namespace llvm { /// createDwarfEHPass - This pass mulches exception handling code into a form /// adapted to code generation. Required if using dwarf exception handling. - FunctionPass *createDwarfEHPass(CodeGenOpt::Level OptLevel); + FunctionPass *createDwarfEHPass(CodeGenOptLevel OptLevel); /// createWinEHPass - Prepares personality functions used by MSVC on Windows, /// in addition to the Itanium LSDA based personalities. diff --git a/llvm/include/llvm/CodeGen/SchedulerRegistry.h b/llvm/include/llvm/CodeGen/SchedulerRegistry.h index 0ccfaafd9e502..0c356e62ae4ee 100644 --- a/llvm/include/llvm/CodeGen/SchedulerRegistry.h +++ b/llvm/include/llvm/CodeGen/SchedulerRegistry.h @@ -29,11 +29,11 @@ class ScheduleDAGSDNodes; class SelectionDAGISel; class RegisterScheduler - : public MachinePassRegistryNode< - ScheduleDAGSDNodes *(*)(SelectionDAGISel *, CodeGenOpt::Level)> { + : public MachinePassRegistryNode { public: - using FunctionPassCtor = ScheduleDAGSDNodes *(*)(SelectionDAGISel*, - CodeGenOpt::Level); + using FunctionPassCtor = ScheduleDAGSDNodes *(*)(SelectionDAGISel *, + CodeGenOptLevel); static MachinePassRegistry Registry; @@ -61,46 +61,46 @@ class RegisterScheduler /// createBURRListDAGScheduler - This creates a bottom up register usage /// reduction list scheduler. ScheduleDAGSDNodes *createBURRListDAGScheduler(SelectionDAGISel *IS, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); /// createBURRListDAGScheduler - This creates a bottom up list scheduler that /// schedules nodes in source code order when possible. ScheduleDAGSDNodes *createSourceListDAGScheduler(SelectionDAGISel *IS, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); /// createHybridListDAGScheduler - This creates a bottom up register pressure /// aware list scheduler that make use of latency information to avoid stalls /// for long latency instructions in low register pressure mode. In high /// register pressure mode it schedules to reduce register pressure. ScheduleDAGSDNodes *createHybridListDAGScheduler(SelectionDAGISel *IS, - CodeGenOpt::Level); + CodeGenOptLevel); /// createILPListDAGScheduler - This creates a bottom up register pressure /// aware list scheduler that tries to increase instruction level parallelism /// in low register pressure mode. In high register pressure mode it schedules /// to reduce register pressure. ScheduleDAGSDNodes *createILPListDAGScheduler(SelectionDAGISel *IS, - CodeGenOpt::Level); + CodeGenOptLevel); /// createFastDAGScheduler - This creates a "fast" scheduler. /// ScheduleDAGSDNodes *createFastDAGScheduler(SelectionDAGISel *IS, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); /// createVLIWDAGScheduler - Scheduler for VLIW targets. This creates top down /// DFA driven list scheduler with clustering heuristic to control /// register pressure. ScheduleDAGSDNodes *createVLIWDAGScheduler(SelectionDAGISel *IS, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); /// createDefaultScheduler - This creates an instruction scheduler appropriate /// for the target. ScheduleDAGSDNodes *createDefaultScheduler(SelectionDAGISel *IS, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); /// createDAGLinearizer - This creates a "no-scheduling" scheduler which /// linearize the DAG using topological order. ScheduleDAGSDNodes *createDAGLinearizer(SelectionDAGISel *IS, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); } // end namespace llvm diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h index f25b3ae4b2d81..2c629f3f96a0c 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAG.h +++ b/llvm/include/llvm/CodeGen/SelectionDAG.h @@ -231,7 +231,7 @@ class SelectionDAG { MachineFunction *MF; Pass *SDAGISelPass = nullptr; LLVMContext *Context; - CodeGenOpt::Level OptLevel; + CodeGenOptLevel OptLevel; UniformityInfo *UA = nullptr; FunctionLoweringInfo * FLI = nullptr; @@ -447,7 +447,7 @@ class SelectionDAG { // Maximum depth for recursive analysis such as computeKnownBits, etc. static constexpr unsigned MaxRecursionDepth = 6; - explicit SelectionDAG(const TargetMachine &TM, CodeGenOpt::Level); + explicit SelectionDAG(const TargetMachine &TM, CodeGenOptLevel); SelectionDAG(const SelectionDAG &) = delete; SelectionDAG &operator=(const SelectionDAG &) = delete; ~SelectionDAG(); @@ -576,8 +576,7 @@ class SelectionDAG { /// certain types of nodes together, or eliminating superfluous nodes. The /// Level argument controls whether Combine is allowed to produce nodes and /// types that are illegal on the target. - void Combine(CombineLevel Level, AAResults *AA, - CodeGenOpt::Level OptLevel); + void Combine(CombineLevel Level, AAResults *AA, CodeGenOptLevel OptLevel); /// This transforms the SelectionDAG into a SelectionDAG that /// only uses types natively supported by the target. diff --git a/llvm/include/llvm/CodeGen/SelectionDAGISel.h b/llvm/include/llvm/CodeGen/SelectionDAGISel.h index 0179cf8a1f592..884fdfadfcbef 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAGISel.h +++ b/llvm/include/llvm/CodeGen/SelectionDAGISel.h @@ -51,7 +51,7 @@ class SelectionDAGISel : public MachineFunctionPass { AAResults *AA = nullptr; AssumptionCache *AC = nullptr; GCFunctionInfo *GFI = nullptr; - CodeGenOpt::Level OptLevel; + CodeGenOptLevel OptLevel; const TargetInstrInfo *TII; const TargetLowering *TLI; bool FastISelFailed; @@ -62,7 +62,7 @@ class SelectionDAGISel : public MachineFunctionPass { std::unique_ptr ORE; explicit SelectionDAGISel(char &ID, TargetMachine &tm, - CodeGenOpt::Level OL = CodeGenOpt::Default); + CodeGenOptLevel OL = CodeGenOptLevel::Default); ~SelectionDAGISel() override; const TargetLowering *getTargetLowering() const { return TLI; } @@ -105,7 +105,7 @@ class SelectionDAGISel : public MachineFunctionPass { /// FIXME: This is a static member function because the MSP430/X86 /// targets, which uses it during isel. This could become a proper member. static bool IsLegalToFold(SDValue N, SDNode *U, SDNode *Root, - CodeGenOpt::Level OptLevel, + CodeGenOptLevel OptLevel, bool IgnoreChains = false); static void InvalidateNodeId(SDNode *N); diff --git a/llvm/include/llvm/CodeGen/SelectionDAGTargetInfo.h b/llvm/include/llvm/CodeGen/SelectionDAGTargetInfo.h index e7d6089691241..720c9463867c3 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAGTargetInfo.h +++ b/llvm/include/llvm/CodeGen/SelectionDAGTargetInfo.h @@ -158,7 +158,7 @@ class SelectionDAGTargetInfo { } // Return true if the DAG Combiner should disable generic combines. - virtual bool disableGenericCombines(CodeGenOpt::Level OptLevel) const { + virtual bool disableGenericCombines(CodeGenOptLevel OptLevel) const { return false; } }; diff --git a/llvm/include/llvm/CodeGen/TargetInstrInfo.h b/llvm/include/llvm/CodeGen/TargetInstrInfo.h index 1c2ca86783464..d55250bd04ab3 100644 --- a/llvm/include/llvm/CodeGen/TargetInstrInfo.h +++ b/llvm/include/llvm/CodeGen/TargetInstrInfo.h @@ -2108,8 +2108,8 @@ class TargetInstrInfo : public MCInstrInfo { /// Returns the target-specific default value for tail duplication. /// This value will be used if the tail-dup-placement-threshold argument is /// not provided. - virtual unsigned getTailDuplicateSize(CodeGenOpt::Level OptLevel) const { - return OptLevel >= CodeGenOpt::Aggressive ? 4 : 2; + virtual unsigned getTailDuplicateSize(CodeGenOptLevel OptLevel) const { + return OptLevel >= CodeGenOptLevel::Aggressive ? 4 : 2; } /// Returns the callee operand from the given \p MI. diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h index f4feab4959322..dabf1bedafe63 100644 --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -3130,7 +3130,7 @@ class TargetLoweringBase { // Return true when the decision to generate FMA's (or FMS, FMLA etc) rather // than FMUL and ADD is delegated to the machine combiner. virtual bool generateFMAsInMachineCombiner(EVT VT, - CodeGenOpt::Level OptLevel) const { + CodeGenOptLevel OptLevel) const { return false; } diff --git a/llvm/include/llvm/CodeGen/TargetPassConfig.h b/llvm/include/llvm/CodeGen/TargetPassConfig.h index 9e8052de12376..dac327899e33f 100644 --- a/llvm/include/llvm/CodeGen/TargetPassConfig.h +++ b/llvm/include/llvm/CodeGen/TargetPassConfig.h @@ -155,7 +155,7 @@ class TargetPassConfig : public ImmutablePass { // void setInitialized() { Initialized = true; } - CodeGenOpt::Level getOptLevel() const; + CodeGenOptLevel getOptLevel() const; /// Returns true if one of the `-start-after`, `-start-before`, `-stop-after` /// or `-stop-before` options is set. diff --git a/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h b/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h index 9b98ef353d73e..55ef95c285431 100644 --- a/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h +++ b/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h @@ -116,7 +116,7 @@ class TargetSubtargetInfo : public MCSubtargetInfo { /// Target can subclass this hook to select a different DAG scheduler. virtual RegisterScheduler::FunctionPassCtor - getDAGScheduler(CodeGenOpt::Level) const { + getDAGScheduler(CodeGenOptLevel) const { return nullptr; } @@ -265,15 +265,15 @@ class TargetSubtargetInfo : public MCSubtargetInfo { // For use with PostRAScheduling: get the minimum optimization level needed // to enable post-RA scheduling. - virtual CodeGenOpt::Level getOptLevelToEnablePostRAScheduler() const { - return CodeGenOpt::Default; + virtual CodeGenOptLevel getOptLevelToEnablePostRAScheduler() const { + return CodeGenOptLevel::Default; } /// True if the subtarget should run the local reassignment /// heuristic of the register allocator. /// This heuristic may be compile time intensive, \p OptLevel provides /// a finer grain to tune the register allocator. - virtual bool enableRALocalReassignment(CodeGenOpt::Level OptLevel) const; + virtual bool enableRALocalReassignment(CodeGenOptLevel OptLevel) const; /// Enable use of alias analysis during code generation (during MI /// scheduling, DAGCombine, etc.). diff --git a/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h b/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h index 5cd43ffebcdf3..ee6084ada1dd4 100644 --- a/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -536,7 +536,7 @@ class EngineBuilder { std::unique_ptr M; EngineKind::Kind WhichEngine; std::string *ErrorStr; - CodeGenOpt::Level OptLevel; + CodeGenOptLevel OptLevel; std::shared_ptr MemMgr; std::shared_ptr Resolver; TargetOptions Options; @@ -586,8 +586,8 @@ class EngineBuilder { } /// setOptLevel - Set the optimization level for the JIT. This option - /// defaults to CodeGenOpt::Default. - EngineBuilder &setOptLevel(CodeGenOpt::Level l) { + /// defaults to CodeGenOptLevel::Default. + EngineBuilder &setOptLevel(CodeGenOptLevel l) { OptLevel = l; return *this; } diff --git a/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h b/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h index 0e72194aec9b1..62f779c6ac503 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h @@ -99,7 +99,7 @@ class JITTargetMachineBuilder { const std::optional &getCodeModel() const { return CM; } /// Set the LLVM CodeGen optimization level. - JITTargetMachineBuilder &setCodeGenOptLevel(CodeGenOpt::Level OptLevel) { + JITTargetMachineBuilder &setCodeGenOptLevel(CodeGenOptLevel OptLevel) { this->OptLevel = OptLevel; return *this; } @@ -150,7 +150,7 @@ class JITTargetMachineBuilder { TargetOptions Options; std::optional RM; std::optional CM; - CodeGenOpt::Level OptLevel = CodeGenOpt::Default; + CodeGenOptLevel OptLevel = CodeGenOptLevel::Default; }; #ifndef NDEBUG diff --git a/llvm/include/llvm/LTO/Config.h b/llvm/include/llvm/LTO/Config.h index 5c23ba4f7ac49..9e1e5111dbf72 100644 --- a/llvm/include/llvm/LTO/Config.h +++ b/llvm/include/llvm/LTO/Config.h @@ -54,8 +54,8 @@ struct Config { std::function PreCodeGenPassesHook; std::optional RelocModel = Reloc::PIC_; std::optional CodeModel; - CodeGenOpt::Level CGOptLevel = CodeGenOpt::Default; - CodeGenFileType CGFileType = CGFT_ObjectFile; + CodeGenOptLevel CGOptLevel = CodeGenOptLevel::Default; + CodeGenFileType CGFileType = CodeGenFileType::ObjectFile; unsigned OptLevel = 2; bool VerifyEach = false; bool DisableVerify = false; diff --git a/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h b/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h index 2093eaa93c854..07c3046b9e5e5 100644 --- a/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h +++ b/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h @@ -94,7 +94,7 @@ struct LTOCodeGenerator { } /// Set the file type to be emitted (assembly or object code). - /// The default is CGFT_ObjectFile. + /// The default is CodeGenFileType::ObjectFile. void setFileType(CodeGenFileType FT) { Config.CGFileType = FT; } void setCpu(StringRef MCpu) { Config.CPU = std::string(MCpu); } diff --git a/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h b/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h index 37e9b175c452f..c450acda82ad0 100644 --- a/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h +++ b/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h @@ -38,7 +38,7 @@ struct TargetMachineBuilder { std::string MAttr; TargetOptions Options; std::optional RelocModel; - CodeGenOpt::Level CGOptLevel = CodeGenOpt::Aggressive; + CodeGenOptLevel CGOptLevel = CodeGenOptLevel::Aggressive; std::unique_ptr create() const; }; @@ -216,7 +216,7 @@ class ThinLTOCodeGenerator { } /// CodeGen optimization level - void setCodeGenOptLevel(CodeGenOpt::Level CGOptLevel) { + void setCodeGenOptLevel(CodeGenOptLevel CGOptLevel) { TMBuilder.CGOptLevel = CGOptLevel; } diff --git a/llvm/include/llvm/MC/TargetRegistry.h b/llvm/include/llvm/MC/TargetRegistry.h index 3fa150fc1349c..bf23313c0f900 100644 --- a/llvm/include/llvm/MC/TargetRegistry.h +++ b/llvm/include/llvm/MC/TargetRegistry.h @@ -167,7 +167,7 @@ class Target { using TargetMachineCtorTy = TargetMachine *(*)(const Target &T, const Triple &TT, StringRef CPU, StringRef Features, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, bool JIT); + std::optional CM, CodeGenOptLevel OL, bool JIT); // If it weren't for layering issues (this header is in llvm/Support, but // depends on MC?) this should take the Streamer by value rather than rvalue // reference. @@ -482,7 +482,7 @@ class Target { StringRef TT, StringRef CPU, StringRef Features, const TargetOptions &Options, std::optional RM, std::optional CM = std::nullopt, - CodeGenOpt::Level OL = CodeGenOpt::Default, bool JIT = false) const { + CodeGenOptLevel OL = CodeGenOptLevel::Default, bool JIT = false) const { if (!TargetMachineCtorFn) return nullptr; return TargetMachineCtorFn(*this, Triple(TT), CPU, Features, Options, RM, @@ -1357,12 +1357,10 @@ template struct RegisterTargetMachine { } private: - static TargetMachine *Allocator(const Target &T, const Triple &TT, - StringRef CPU, StringRef FS, - const TargetOptions &Options, - std::optional RM, - std::optional CM, - CodeGenOpt::Level OL, bool JIT) { + static TargetMachine * + Allocator(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, + const TargetOptions &Options, std::optional RM, + std::optional CM, CodeGenOptLevel OL, bool JIT) { return new TargetMachineImpl(T, TT, CPU, FS, Options, RM, CM, OL, JIT); } }; diff --git a/llvm/include/llvm/Support/CodeGen.h b/llvm/include/llvm/Support/CodeGen.h index 7f95bcb9e9d7b..46f99811763a8 100644 --- a/llvm/include/llvm/Support/CodeGen.h +++ b/llvm/include/llvm/Support/CodeGen.h @@ -50,41 +50,40 @@ namespace llvm { }; } - namespace CodeGenOpt { - /// Type for the unique integer IDs of code generation optimization levels. - using IDType = int; /// Code generation optimization level. - enum Level : IDType { + enum class CodeGenOptLevel { None = 0, ///< -O0 Less = 1, ///< -O1 Default = 2, ///< -O2, -Os Aggressive = 3 ///< -O3 }; - /// Get the \c Level identified by the integer \p ID. + + namespace CodeGenOpt { + /// Get the \c Level identified by the integer \p OL. /// - /// Returns std::nullopt if \p ID is invalid. - inline std::optional getLevel(IDType ID) { - if (ID < 0 || ID > 3) + /// Returns std::nullopt if \p OL is invalid. + inline std::optional getLevel(int OL) { + if (OL < 0 || OL > 3) return std::nullopt; - return static_cast(ID); + return static_cast(OL); } - /// Parse \p C as a single digit integer ID and get matching \c Level. + /// Parse \p C as a single digit integer and get matching \c CodeGenLevel. /// - /// Returns std::nullopt if the input is not a valid digit or not a valid ID. - inline std::optional parseLevel(char C) { + /// Returns std::nullopt if the input is not a valid optimization level. + inline std::optional parseLevel(char C) { if (C < '0') return std::nullopt; - return getLevel(static_cast(C - '0')); + return getLevel(static_cast(C - '0')); } } // namespace CodeGenOpt /// These enums are meant to be passed into addPassesToEmitFile to indicate /// what type of file to emit, and returned by it to indicate what type of /// file could actually be made. - enum CodeGenFileType { - CGFT_AssemblyFile, - CGFT_ObjectFile, - CGFT_Null // Do not emit any output. + enum class CodeGenFileType { + AssemblyFile, + ObjectFile, + Null // Do not emit any output. }; // Specify what functions should keep the frame pointer. diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h index 5838758748fa8..38070f42b4957 100644 --- a/llvm/include/llvm/Target/TargetMachine.h +++ b/llvm/include/llvm/Target/TargetMachine.h @@ -100,7 +100,7 @@ class TargetMachine { Reloc::Model RM = Reloc::Static; CodeModel::Model CMModel = CodeModel::Small; - CodeGenOpt::Level OptLevel = CodeGenOpt::Default; + CodeGenOptLevel OptLevel = CodeGenOptLevel::Default; /// Contains target specific asm information. std::unique_ptr AsmInfo; @@ -251,10 +251,10 @@ class TargetMachine { TLSModel::Model getTLSModel(const GlobalValue *GV) const; /// Returns the optimization level: None, Less, Default, or Aggressive. - CodeGenOpt::Level getOptLevel() const; + CodeGenOptLevel getOptLevel() const; /// Overrides the optimization level. - void setOptLevel(CodeGenOpt::Level Level); + void setOptLevel(CodeGenOptLevel Level); void setFastISel(bool Enable) { Options.EnableFastISel = Enable; } bool getO0WantsFastISel() { return O0WantsFastISel; } @@ -424,7 +424,7 @@ class LLVMTargetMachine : public TargetMachine { LLVMTargetMachine(const Target &T, StringRef DataLayoutString, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, - CodeModel::Model CM, CodeGenOpt::Level OL); + CodeModel::Model CM, CodeGenOptLevel OL); void initAsmInfo(); diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index c43ca255505d7..b25a38b263441 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -1537,8 +1537,8 @@ void CodeViewDebug::beginFunctionImpl(const MachineFunction *MF) { } FPO |= FrameProcedureOptions(uint32_t(CurFn->EncodedLocalFramePtrReg) << 14U); FPO |= FrameProcedureOptions(uint32_t(CurFn->EncodedParamFramePtrReg) << 16U); - if (Asm->TM.getOptLevel() != CodeGenOpt::None && - !GV.hasOptSize() && !GV.hasOptNone()) + if (Asm->TM.getOptLevel() != CodeGenOptLevel::None && !GV.hasOptSize() && + !GV.hasOptNone()) FPO |= FrameProcedureOptions::OptimizedForSpeed; if (GV.hasProfileData()) { FPO |= FrameProcedureOptions::ValidProfileCounts; diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp index c34a52a6f2de9..59bd6dad3b6ff 100644 --- a/llvm/lib/CodeGen/CommandFlags.cpp +++ b/llvm/lib/CodeGen/CommandFlags.cpp @@ -180,15 +180,15 @@ codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() { CGBINDOPT(ExceptionModel); static cl::opt FileType( - "filetype", cl::init(CGFT_AssemblyFile), + "filetype", cl::init(CodeGenFileType::AssemblyFile), cl::desc( "Choose a file type (not all types are supported by all targets):"), - cl::values( - clEnumValN(CGFT_AssemblyFile, "asm", "Emit an assembly ('.s') file"), - clEnumValN(CGFT_ObjectFile, "obj", - "Emit a native object ('.o') file"), - clEnumValN(CGFT_Null, "null", - "Emit nothing, for performance testing"))); + cl::values(clEnumValN(CodeGenFileType::AssemblyFile, "asm", + "Emit an assembly ('.s') file"), + clEnumValN(CodeGenFileType::ObjectFile, "obj", + "Emit a native object ('.o') file"), + clEnumValN(CodeGenFileType::Null, "null", + "Emit nothing, for performance testing"))); CGBINDOPT(FileType); static cl::opt FramePointerUsage( diff --git a/llvm/lib/CodeGen/DwarfEHPrepare.cpp b/llvm/lib/CodeGen/DwarfEHPrepare.cpp index 32c94de7280cb..1d02f53e51e56 100644 --- a/llvm/lib/CodeGen/DwarfEHPrepare.cpp +++ b/llvm/lib/CodeGen/DwarfEHPrepare.cpp @@ -54,7 +54,7 @@ STATISTIC(NumUnwind, "Number of functions with unwind"); namespace { class DwarfEHPrepare { - CodeGenOpt::Level OptLevel; + CodeGenOptLevel OptLevel; Function &F; const TargetLowering &TLI; @@ -78,7 +78,7 @@ class DwarfEHPrepare { bool InsertUnwindResumeCalls(); public: - DwarfEHPrepare(CodeGenOpt::Level OptLevel_, Function &F_, + DwarfEHPrepare(CodeGenOptLevel OptLevel_, Function &F_, const TargetLowering &TLI_, DomTreeUpdater *DTU_, const TargetTransformInfo *TTI_, const Triple &TargetTriple_) : OptLevel(OptLevel_), F(F_), TLI(TLI_), DTU(DTU_), TTI(TTI_), @@ -194,7 +194,7 @@ bool DwarfEHPrepare::InsertUnwindResumeCalls() { LLVMContext &Ctx = F.getContext(); size_t ResumesLeft = Resumes.size(); - if (OptLevel != CodeGenOpt::None) { + if (OptLevel != CodeGenOptLevel::None) { ResumesLeft = pruneUnreachableResumes(Resumes, CleanupLPads); #if LLVM_ENABLE_STATS unsigned NumRemainingLPs = 0; @@ -309,7 +309,7 @@ bool DwarfEHPrepare::run() { return Changed; } -static bool prepareDwarfEH(CodeGenOpt::Level OptLevel, Function &F, +static bool prepareDwarfEH(CodeGenOptLevel OptLevel, Function &F, const TargetLowering &TLI, DominatorTree *DT, const TargetTransformInfo *TTI, const Triple &TargetTriple) { @@ -324,12 +324,12 @@ namespace { class DwarfEHPrepareLegacyPass : public FunctionPass { - CodeGenOpt::Level OptLevel; + CodeGenOptLevel OptLevel; public: static char ID; // Pass identification, replacement for typeid. - DwarfEHPrepareLegacyPass(CodeGenOpt::Level OptLevel = CodeGenOpt::Default) + DwarfEHPrepareLegacyPass(CodeGenOptLevel OptLevel = CodeGenOptLevel::Default) : FunctionPass(ID), OptLevel(OptLevel) {} bool runOnFunction(Function &F) override { @@ -340,7 +340,7 @@ class DwarfEHPrepareLegacyPass : public FunctionPass { const TargetTransformInfo *TTI = nullptr; if (auto *DTWP = getAnalysisIfAvailable()) DT = &DTWP->getDomTree(); - if (OptLevel != CodeGenOpt::None) { + if (OptLevel != CodeGenOptLevel::None) { if (!DT) DT = &getAnalysis().getDomTree(); TTI = &getAnalysis().getTTI(F); @@ -351,7 +351,7 @@ class DwarfEHPrepareLegacyPass : public FunctionPass { void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired(); AU.addRequired(); - if (OptLevel != CodeGenOpt::None) { + if (OptLevel != CodeGenOptLevel::None) { AU.addRequired(); AU.addRequired(); } @@ -375,6 +375,6 @@ INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass) INITIALIZE_PASS_END(DwarfEHPrepareLegacyPass, DEBUG_TYPE, "Prepare DWARF exceptions", false, false) -FunctionPass *llvm::createDwarfEHPass(CodeGenOpt::Level OptLevel) { +FunctionPass *llvm::createDwarfEHPass(CodeGenOptLevel OptLevel) { return new DwarfEHPrepareLegacyPass(OptLevel); } diff --git a/llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp b/llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp index d966fae82985a..ca4d0986b4426 100644 --- a/llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp +++ b/llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp @@ -76,9 +76,9 @@ bool CSEConfigConstantOnly::shouldCSEOpc(unsigned Opc) { } std::unique_ptr -llvm::getStandardCSEConfigForOpt(CodeGenOpt::Level Level) { +llvm::getStandardCSEConfigForOpt(CodeGenOptLevel Level) { std::unique_ptr Config; - if (Level == CodeGenOpt::None) + if (Level == CodeGenOptLevel::None) Config = std::make_unique(); else Config = std::make_unique(); diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index 41a0295ddbae2..3e2a74422b2ed 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -127,7 +127,7 @@ static void reportTranslationError(MachineFunction &MF, ORE.emit(R); } -IRTranslator::IRTranslator(CodeGenOpt::Level optlevel) +IRTranslator::IRTranslator(CodeGenOptLevel optlevel) : MachineFunctionPass(ID), OptLevel(optlevel) {} #ifndef NDEBUG @@ -173,7 +173,7 @@ void IRTranslator::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); AU.addRequired(); AU.addRequired(); - if (OptLevel != CodeGenOpt::None) { + if (OptLevel != CodeGenOptLevel::None) { AU.addRequired(); AU.addRequired(); } @@ -578,7 +578,8 @@ bool IRTranslator::translateBr(const User &U, MachineIRBuilder &MIRBuilder) { if (BrInst.isUnconditional()) { // If the unconditional target is the layout successor, fallthrough. - if (OptLevel == CodeGenOpt::None || !CurMBB.isLayoutSuccessor(Succ0MBB)) + if (OptLevel == CodeGenOptLevel::None || + !CurMBB.isLayoutSuccessor(Succ0MBB)) MIRBuilder.buildBr(*Succ0MBB); // Link successors. @@ -1974,7 +1975,7 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, case Intrinsic::lifetime_start: case Intrinsic::lifetime_end: { // No stack colouring in O0, discard region information. - if (MF->getTarget().getOptLevel() == CodeGenOpt::None) + if (MF->getTarget().getOptLevel() == CodeGenOptLevel::None) return true; unsigned Op = ID == Intrinsic::lifetime_start ? TargetOpcode::LIFETIME_START @@ -3488,7 +3489,7 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &CurMF) { ORE = std::make_unique(&F); const TargetMachine &TM = MF->getTarget(); TM.resetTargetOptions(F); - EnableOpts = OptLevel != CodeGenOpt::None && !skipFunction(F); + EnableOpts = OptLevel != CodeGenOptLevel::None && !skipFunction(F); FuncInfo.MF = MF; if (EnableOpts) { AA = &getAnalysis().getAAResults(); diff --git a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp index 9bbef11067ae7..75f1fbc3b2d1b 100644 --- a/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp +++ b/llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp @@ -58,21 +58,21 @@ INITIALIZE_PASS_END(InstructionSelect, DEBUG_TYPE, "Select target instructions out of generic instructions", false, false) -InstructionSelect::InstructionSelect(CodeGenOpt::Level OL) +InstructionSelect::InstructionSelect(CodeGenOptLevel OL) : MachineFunctionPass(ID), OptLevel(OL) {} // In order not to crash when calling getAnalysis during testing with -run-pass // we use the default opt level here instead of None, so that the addRequired() // calls are made in getAnalysisUsage(). InstructionSelect::InstructionSelect() - : MachineFunctionPass(ID), OptLevel(CodeGenOpt::Default) {} + : MachineFunctionPass(ID), OptLevel(CodeGenOptLevel::Default) {} void InstructionSelect::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); AU.addRequired(); AU.addPreserved(); - if (OptLevel != CodeGenOpt::None) { + if (OptLevel != CodeGenOptLevel::None) { AU.addRequired(); LazyBlockFrequencyInfoPass::getLazyBFIAnalysisUsage(AU); } @@ -91,13 +91,13 @@ bool InstructionSelect::runOnMachineFunction(MachineFunction &MF) { const TargetPassConfig &TPC = getAnalysis(); InstructionSelector *ISel = MF.getSubtarget().getInstructionSelector(); - CodeGenOpt::Level OldOptLevel = OptLevel; + CodeGenOptLevel OldOptLevel = OptLevel; auto RestoreOptLevel = make_scope_exit([=]() { OptLevel = OldOptLevel; }); - OptLevel = MF.getFunction().hasOptNone() ? CodeGenOpt::None + OptLevel = MF.getFunction().hasOptNone() ? CodeGenOptLevel::None : MF.getTarget().getOptLevel(); GISelKnownBits *KB = &getAnalysis().get(MF); - if (OptLevel != CodeGenOpt::None) { + if (OptLevel != CodeGenOptLevel::None) { PSI = &getAnalysis().getPSI(); if (PSI && PSI->hasProfileSummary()) BFI = &getAnalysis().getBFI(); diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp index d02ec1db1165d..7ec8390033fba 100644 --- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp +++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp @@ -87,7 +87,7 @@ LLVMTargetMachine::LLVMTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, - CodeGenOpt::Level OL) + CodeGenOptLevel OL) : TargetMachine(T, DataLayoutString, TT, CPU, FS, Options) { this->RM = RM; this->CMModel = CM; @@ -156,7 +156,7 @@ Expected> LLVMTargetMachine::createMCStreamer( std::unique_ptr AsmStreamer; switch (FileType) { - case CGFT_AssemblyFile: { + case CodeGenFileType::AssemblyFile: { MCInstPrinter *InstPrinter = getTarget().createMCInstPrinter( getTargetTriple(), MAI.getAssemblerDialect(), MAI, MII, MRI); @@ -188,7 +188,7 @@ Expected> LLVMTargetMachine::createMCStreamer( AsmStreamer.reset(S); break; } - case CGFT_ObjectFile: { + case CodeGenFileType::ObjectFile: { // Create the code emitter for the target if it exists. If not, .o file // emission fails. MCCodeEmitter *MCE = getTarget().createMCCodeEmitter(MII, Context); @@ -211,7 +211,7 @@ Expected> LLVMTargetMachine::createMCStreamer( /*DWARFMustBeAtTheEnd*/ true)); break; } - case CGFT_Null: + case CodeGenFileType::Null: // The Null output is intended for use for performance analysis and testing, // not real users. AsmStreamer.reset(getTarget().createNullStreamer(Context)); @@ -238,7 +238,7 @@ bool LLVMTargetMachine::addPassesToEmitFile( return true; } else { // MIR printing is redundant with -filetype=null. - if (FileType != CGFT_Null) + if (FileType != CodeGenFileType::Null) PM.add(createPrintMIRPass(Out)); } diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index 912e9ec993e3c..24f0197b41979 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -3376,7 +3376,7 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &MF) { TargetPassConfig *PassConfig = &getAnalysis(); // For aggressive optimization, we can adjust some thresholds to be less // conservative. - if (PassConfig->getOptLevel() >= CodeGenOpt::Aggressive) { + if (PassConfig->getOptLevel() >= CodeGenOptLevel::Aggressive) { // At O3 we should be more willing to copy blocks for tail duplication. This // increases size pressure, so we only do it at O3 // Do this unless only the regular threshold is explicitly set. @@ -3388,7 +3388,7 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &MF) { // If there's no threshold provided through options, query the target // information for a threshold instead. if (TailDupPlacementThreshold.getNumOccurrences() == 0 && - (PassConfig->getOptLevel() < CodeGenOpt::Aggressive || + (PassConfig->getOptLevel() < CodeGenOptLevel::Aggressive || TailDupPlacementAggressiveThreshold.getNumOccurrences() == 0)) TailDupSize = TII->getTailDuplicateSize(PassConfig->getOptLevel()); diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index e1f9488a1c88f..1f14546a25b1c 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -1206,7 +1206,7 @@ bool MachineFunction::shouldUseDebugInstrRef() const { // have optimized code inlined into this unoptimized code, however with // fewer and less aggressive optimizations happening, coverage and accuracy // should not suffer. - if (getTarget().getOptLevel() == CodeGenOpt::None) + if (getTarget().getOptLevel() == CodeGenOptLevel::None) return false; // Don't use instr-ref if this function is marked optnone. diff --git a/llvm/lib/CodeGen/PostRASchedulerList.cpp b/llvm/lib/CodeGen/PostRASchedulerList.cpp index 170008ab67cb6..ffd70a29f1715 100644 --- a/llvm/lib/CodeGen/PostRASchedulerList.cpp +++ b/llvm/lib/CodeGen/PostRASchedulerList.cpp @@ -101,7 +101,7 @@ namespace { private: bool enablePostRAScheduler( - const TargetSubtargetInfo &ST, CodeGenOpt::Level OptLevel, + const TargetSubtargetInfo &ST, CodeGenOptLevel OptLevel, TargetSubtargetInfo::AntiDepBreakMode &Mode, TargetSubtargetInfo::RegClassVector &CriticalPathRCs) const; }; @@ -260,8 +260,7 @@ LLVM_DUMP_METHOD void SchedulePostRATDList::dumpSchedule() const { #endif bool PostRAScheduler::enablePostRAScheduler( - const TargetSubtargetInfo &ST, - CodeGenOpt::Level OptLevel, + const TargetSubtargetInfo &ST, CodeGenOptLevel OptLevel, TargetSubtargetInfo::AntiDepBreakMode &Mode, TargetSubtargetInfo::RegClassVector &CriticalPathRCs) const { Mode = ST.getAntiDepBreakMode(); diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp index 6c8be5cff7536..9514a0875a785 100644 --- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp +++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp @@ -1083,7 +1083,7 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &MF) { MaxAlign); // Give the targets a chance to order the objects the way they like it. - if (MF.getTarget().getOptLevel() != CodeGenOpt::None && + if (MF.getTarget().getOptLevel() != CodeGenOptLevel::None && MF.getTarget().Options.StackSymbolOrdering) TFI.orderFrameObjects(MF, ObjectsToAllocate); @@ -1093,7 +1093,7 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &MF) { // optimizing. BitVector StackBytesFree; if (!ObjectsToAllocate.empty() && - MF.getTarget().getOptLevel() != CodeGenOpt::None && + MF.getTarget().getOptLevel() != CodeGenOptLevel::None && MFI.getStackProtectorIndex() < 0 && TFI.enableStackSlotScavenging(MF)) computeFreeStackSlots(MFI, StackGrowsDown, MinCSFrameIndex, MaxCSFrameIndex, FixedCSEnd, StackBytesFree); diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index cd34c0dce0f95..c6412221662e3 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -149,7 +149,7 @@ namespace { const TargetLowering &TLI; const SelectionDAGTargetInfo *STI; CombineLevel Level = BeforeLegalizeTypes; - CodeGenOpt::Level OptLevel; + CodeGenOptLevel OptLevel; bool LegalDAG = false; bool LegalOperations = false; bool LegalTypes = false; @@ -242,7 +242,7 @@ namespace { SDValue visit(SDNode *N); public: - DAGCombiner(SelectionDAG &D, AliasAnalysis *AA, CodeGenOpt::Level OL) + DAGCombiner(SelectionDAG &D, AliasAnalysis *AA, CodeGenOptLevel OL) : DAG(D), TLI(D.getTargetLoweringInfo()), STI(D.getSubtarget().getSelectionDAGInfo()), OptLevel(OL), AA(AA) { ForCodeSize = DAG.shouldOptForSize(); @@ -2153,7 +2153,7 @@ SDValue DAGCombiner::visitTokenFactor(SDNode *N) { } // Don't simplify token factors if optnone. - if (OptLevel == CodeGenOpt::None) + if (OptLevel == CodeGenOptLevel::None) return SDValue(); // Don't simplify the token factor if the node itself has too many operands. @@ -8789,7 +8789,7 @@ SDValue DAGCombiner::mergeTruncStores(StoreSDNode *N) { // TODO: If there is evidence that running this later would help, this // limitation could be removed. Legality checks may need to be added // for the created store and optional bswap/rotate. - if (LegalOperations || OptLevel == CodeGenOpt::None) + if (LegalOperations || OptLevel == CodeGenOptLevel::None) return SDValue(); // We only handle merging simple stores of 1-4 bytes. @@ -18178,7 +18178,7 @@ StoreSDNode *DAGCombiner::getUniqueStoreFeeding(LoadSDNode *LD, } SDValue DAGCombiner::ForwardStoreValueToDirectLoad(LoadSDNode *LD) { - if (OptLevel == CodeGenOpt::None || !LD->isSimple()) + if (OptLevel == CodeGenOptLevel::None || !LD->isSimple()) return SDValue(); SDValue Chain = LD->getOperand(0); int64_t Offset; @@ -18378,7 +18378,8 @@ SDValue DAGCombiner::visitLOAD(SDNode *N) { return V; // Try to infer better alignment information than the load already has. - if (OptLevel != CodeGenOpt::None && LD->isUnindexed() && !LD->isAtomic()) { + if (OptLevel != CodeGenOptLevel::None && LD->isUnindexed() && + !LD->isAtomic()) { if (MaybeAlign Alignment = DAG.InferPtrAlign(Ptr)) { if (*Alignment > LD->getAlign() && isAligned(*Alignment, LD->getSrcValueOffset())) { @@ -20401,7 +20402,7 @@ bool DAGCombiner::tryStoreMergeOfLoads(SmallVectorImpl &StoreNodes, } bool DAGCombiner::mergeConsecutiveStores(StoreSDNode *St) { - if (OptLevel == CodeGenOpt::None || !EnableStoreMerging) + if (OptLevel == CodeGenOptLevel::None || !EnableStoreMerging) return false; // TODO: Extend this function to merge stores of scalable vectors. @@ -20680,7 +20681,8 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) { return Chain; // Try to infer better alignment information than the store already has. - if (OptLevel != CodeGenOpt::None && ST->isUnindexed() && !ST->isAtomic()) { + if (OptLevel != CodeGenOptLevel::None && ST->isUnindexed() && + !ST->isAtomic()) { if (MaybeAlign Alignment = DAG.InferPtrAlign(Ptr)) { if (*Alignment > ST->getAlign() && isAligned(*Alignment, ST->getSrcValueOffset())) { @@ -20796,7 +20798,7 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) { if (StoreSDNode *ST1 = dyn_cast(Chain)) { if (ST->isUnindexed() && ST->isSimple() && ST1->isUnindexed() && ST1->isSimple()) { - if (OptLevel != CodeGenOpt::None && ST1->getBasePtr() == Ptr && + if (OptLevel != CodeGenOptLevel::None && ST1->getBasePtr() == Ptr && ST1->getValue() == Value && ST->getMemoryVT() == ST1->getMemoryVT() && ST->getAddressSpace() == ST1->getAddressSpace()) { // If this is a store followed by a store with the same value to the @@ -20804,7 +20806,7 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) { return Chain; } - if (OptLevel != CodeGenOpt::None && ST1->hasOneUse() && + if (OptLevel != CodeGenOptLevel::None && ST1->hasOneUse() && !ST1->getBasePtr().isUndef() && ST->getAddressSpace() == ST1->getAddressSpace()) { // If we consider two stores and one smaller in size is a scalable @@ -20967,7 +20969,7 @@ SDValue DAGCombiner::visitLIFETIME_END(SDNode *N) { /// } /// SDValue DAGCombiner::splitMergedValStore(StoreSDNode *ST) { - if (OptLevel == CodeGenOpt::None) + if (OptLevel == CodeGenOptLevel::None) return SDValue(); // Can't change the number of memory accesses for a volatile store or break @@ -27540,7 +27542,7 @@ void DAGCombiner::GatherAllAliases(SDNode *N, SDValue OriginalChain, /// Walk up chain skipping non-aliasing memory nodes, looking for a better chain /// (aliasing node.) SDValue DAGCombiner::FindBetterChain(SDNode *N, SDValue OldChain) { - if (OptLevel == CodeGenOpt::None) + if (OptLevel == CodeGenOptLevel::None) return OldChain; // Ops for replacing token factor. @@ -27697,7 +27699,7 @@ bool DAGCombiner::parallelizeChainedStores(StoreSDNode *St) { } bool DAGCombiner::findBetterNeighborChains(StoreSDNode *St) { - if (OptLevel == CodeGenOpt::None) + if (OptLevel == CodeGenOptLevel::None) return false; const BaseIndexOffset BasePtr = BaseIndexOffset::match(St, DAG); @@ -27725,7 +27727,7 @@ bool DAGCombiner::findBetterNeighborChains(StoreSDNode *St) { /// This is the entry point for the file. void SelectionDAG::Combine(CombineLevel Level, AliasAnalysis *AA, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { /// This is the main entry point to this class. DAGCombiner(*this, AA, OptLevel).Run(Level); } diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp index 5abfe16839ee7..ab4c33c9e976b 100644 --- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp @@ -808,12 +808,12 @@ ScheduleDAGLinearize::EmitSchedule(MachineBasicBlock::iterator &InsertPos) { // Public Constructor Functions //===----------------------------------------------------------------------===// -llvm::ScheduleDAGSDNodes * -llvm::createFastDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level) { +llvm::ScheduleDAGSDNodes *llvm::createFastDAGScheduler(SelectionDAGISel *IS, + CodeGenOptLevel) { return new ScheduleDAGFast(*IS->MF); } -llvm::ScheduleDAGSDNodes * -llvm::createDAGLinearizer(SelectionDAGISel *IS, CodeGenOpt::Level) { +llvm::ScheduleDAGSDNodes *llvm::createDAGLinearizer(SelectionDAGISel *IS, + CodeGenOptLevel) { return new ScheduleDAGLinearize(*IS->MF); } diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp index 4ca3385ef501f..36f68e9363ebd 100644 --- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp @@ -188,10 +188,9 @@ class ScheduleDAGRRList : public ScheduleDAGSDNodes { public: ScheduleDAGRRList(MachineFunction &mf, bool needlatency, SchedulingPriorityQueue *availqueue, - CodeGenOpt::Level OptLevel) - : ScheduleDAGSDNodes(mf), - NeedLatency(needlatency), AvailableQueue(availqueue), - Topo(SUnits, nullptr) { + CodeGenOptLevel OptLevel) + : ScheduleDAGSDNodes(mf), NeedLatency(needlatency), + AvailableQueue(availqueue), Topo(SUnits, nullptr) { const TargetSubtargetInfo &STI = mf.getSubtarget(); if (DisableSchedCycles || !NeedLatency) HazardRec = new ScheduleHazardRecognizer(); @@ -3150,9 +3149,8 @@ void RegReductionPQBase::AddPseudoTwoAddrDeps() { // Public Constructor Functions //===----------------------------------------------------------------------===// -ScheduleDAGSDNodes * -llvm::createBURRListDAGScheduler(SelectionDAGISel *IS, - CodeGenOpt::Level OptLevel) { +ScheduleDAGSDNodes *llvm::createBURRListDAGScheduler(SelectionDAGISel *IS, + CodeGenOptLevel OptLevel) { const TargetSubtargetInfo &STI = IS->MF->getSubtarget(); const TargetInstrInfo *TII = STI.getInstrInfo(); const TargetRegisterInfo *TRI = STI.getRegisterInfo(); @@ -3166,7 +3164,7 @@ llvm::createBURRListDAGScheduler(SelectionDAGISel *IS, ScheduleDAGSDNodes * llvm::createSourceListDAGScheduler(SelectionDAGISel *IS, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { const TargetSubtargetInfo &STI = IS->MF->getSubtarget(); const TargetInstrInfo *TII = STI.getInstrInfo(); const TargetRegisterInfo *TRI = STI.getRegisterInfo(); @@ -3180,7 +3178,7 @@ llvm::createSourceListDAGScheduler(SelectionDAGISel *IS, ScheduleDAGSDNodes * llvm::createHybridListDAGScheduler(SelectionDAGISel *IS, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { const TargetSubtargetInfo &STI = IS->MF->getSubtarget(); const TargetInstrInfo *TII = STI.getInstrInfo(); const TargetRegisterInfo *TRI = STI.getRegisterInfo(); @@ -3194,9 +3192,8 @@ llvm::createHybridListDAGScheduler(SelectionDAGISel *IS, return SD; } -ScheduleDAGSDNodes * -llvm::createILPListDAGScheduler(SelectionDAGISel *IS, - CodeGenOpt::Level OptLevel) { +ScheduleDAGSDNodes *llvm::createILPListDAGScheduler(SelectionDAGISel *IS, + CodeGenOptLevel OptLevel) { const TargetSubtargetInfo &STI = IS->MF->getSubtarget(); const TargetInstrInfo *TII = STI.getInstrInfo(); const TargetRegisterInfo *TRI = STI.getRegisterInfo(); diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGVLIW.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGVLIW.cpp index 1ba1fd65b8c90..ae42a870ea2fe 100644 --- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGVLIW.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGVLIW.cpp @@ -265,7 +265,7 @@ void ScheduleDAGVLIW::listScheduleTopDown() { //===----------------------------------------------------------------------===// /// createVLIWDAGScheduler - This creates a top-down list scheduler. -ScheduleDAGSDNodes * -llvm::createVLIWDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level) { +ScheduleDAGSDNodes *llvm::createVLIWDAGScheduler(SelectionDAGISel *IS, + CodeGenOptLevel) { return new ScheduleDAGVLIW(*IS->MF, IS->AA, new ResourcePriorityQueue(IS)); } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 8d6d328e8a1f1..60f4ea7fac479 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1303,9 +1303,9 @@ Align SelectionDAG::getEVTAlign(EVT VT) const { } // EntryNode could meaningfully have debug info if we can find it... -SelectionDAG::SelectionDAG(const TargetMachine &tm, CodeGenOpt::Level OL) - : TM(tm), OptLevel(OL), - EntryNode(ISD::EntryToken, 0, DebugLoc(), getVTList(MVT::Other, MVT::Glue)), +SelectionDAG::SelectionDAG(const TargetMachine &tm, CodeGenOptLevel OL) + : TM(tm), OptLevel(OL), EntryNode(ISD::EntryToken, 0, DebugLoc(), + getVTList(MVT::Other, MVT::Glue)), Root(getEntryNode()) { InsertNode(&EntryNode); DbgInfo = new SDDbgInfo(); @@ -10291,7 +10291,7 @@ SDNode *SelectionDAG::SelectNodeTo(SDNode *N, unsigned MachineOpc, /// For IROrder, we keep the smaller of the two SDNode *SelectionDAG::UpdateSDLocOnMergeSDNode(SDNode *N, const SDLoc &OLoc) { DebugLoc NLoc = N->getDebugLoc(); - if (NLoc && OptLevel == CodeGenOpt::None && OLoc.getDebugLoc() != NLoc) { + if (NLoc && OptLevel == CodeGenOptLevel::None && OLoc.getDebugLoc() != NLoc) { N->setDebugLoc(DebugLoc()); } unsigned Order = std::min(N->getIROrder(), OLoc.getIROrder()); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 720fc49441612..7a85f19f3df5d 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1822,7 +1822,7 @@ void SelectionDAGBuilder::visitCatchRet(const CatchReturnInst &I) { // If this is not a fall-through branch or optimizations are switched off, // emit the branch. if (TargetMBB != NextBlock(FuncInfo.MBB) || - TM.getOptLevel() == CodeGenOpt::None) + TM.getOptLevel() == CodeGenOptLevel::None) DAG.setRoot(DAG.getNode(ISD::BR, getCurSDLoc(), MVT::Other, getControlRoot(), DAG.getBasicBlock(TargetMBB))); return; @@ -2478,7 +2478,8 @@ void SelectionDAGBuilder::visitBr(const BranchInst &I) { // If this is not a fall-through branch or optimizations are switched off, // emit the branch. - if (Succ0MBB != NextBlock(BrMBB) || TM.getOptLevel() == CodeGenOpt::None) { + if (Succ0MBB != NextBlock(BrMBB) || + TM.getOptLevel() == CodeGenOptLevel::None) { auto Br = DAG.getNode(ISD::BR, getCurSDLoc(), MVT::Other, getControlRoot(), DAG.getBasicBlock(Succ0MBB)); setValue(&I, Br); @@ -7107,7 +7108,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, case Intrinsic::lifetime_end: { bool IsStart = (Intrinsic == Intrinsic::lifetime_start); // Stack coloring is not enabled in O0, discard region information. - if (TM.getOptLevel() == CodeGenOpt::None) + if (TM.getOptLevel() == CodeGenOptLevel::None) return; const int64_t ObjectSize = @@ -11293,7 +11294,7 @@ void SelectionDAGBuilder::lowerWorkItem(SwitchWorkListItem W, Value *Cond, } } - if (TM.getOptLevel() != CodeGenOpt::None) { + if (TM.getOptLevel() != CodeGenOptLevel::None) { // Here, we order cases by probability so the most likely case will be // checked first. However, two clusters can have the same probability in // which case their relative ordering is non-deterministic. So we use Low @@ -11651,7 +11652,7 @@ MachineBasicBlock *SelectionDAGBuilder::peelDominantCaseCluster( MachineBasicBlock *SwitchMBB = FuncInfo.MBB; // Don't perform if there is only one cluster or optimizing for size. if (SwitchPeelThreshold > 100 || !FuncInfo.BPI || Clusters.size() < 2 || - TM.getOptLevel() == CodeGenOpt::None || + TM.getOptLevel() == CodeGenOptLevel::None || SwitchMBB->getParent()->getFunction().hasMinSize()) return SwitchMBB; @@ -11773,7 +11774,7 @@ void SelectionDAGBuilder::visitSwitch(const SwitchInst &SI) { SwitchWorkListItem W = WorkList.pop_back_val(); unsigned NumClusters = W.LastCluster - W.FirstCluster + 1; - if (NumClusters > 3 && TM.getOptLevel() != CodeGenOpt::None && + if (NumClusters > 3 && TM.getOptLevel() != CodeGenOptLevel::None && !DefaultMBB->getParent()->getFunction().hasMinSize()) { // For optimized builds, lower large range as a balanced binary tree. splitWorkItem(WorkList, W, SI.getCondition(), SwitchMBB); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h index 55a63ec7fd3f4..ec23445b01640 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h @@ -295,10 +295,10 @@ class SelectionDAGBuilder { LLVMContext *Context = nullptr; SelectionDAGBuilder(SelectionDAG &dag, FunctionLoweringInfo &funcinfo, - SwiftErrorValueTracking &swifterror, CodeGenOpt::Level ol) + SwiftErrorValueTracking &swifterror, CodeGenOptLevel ol) : SDNodeOrder(LowestSDNodeOrder), TM(dag.getTarget()), DAG(dag), - SL(std::make_unique(this, funcinfo)), FuncInfo(funcinfo), - SwiftError(swifterror) {} + SL(std::make_unique(this, funcinfo)), + FuncInfo(funcinfo), SwiftError(swifterror) {} void init(GCFunctionInfo *gfi, AAResults *AA, AssumptionCache *AC, const TargetLibraryInfo *li); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 91b9d77eed705..70e78afd9b520 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -211,12 +211,12 @@ namespace llvm { /// the optimization level on a per-function basis. class OptLevelChanger { SelectionDAGISel &IS; - CodeGenOpt::Level SavedOptLevel; + CodeGenOptLevel SavedOptLevel; bool SavedFastISel; public: - OptLevelChanger(SelectionDAGISel &ISel, - CodeGenOpt::Level NewOptLevel) : IS(ISel) { + OptLevelChanger(SelectionDAGISel &ISel, CodeGenOptLevel NewOptLevel) + : IS(ISel) { SavedOptLevel = IS.OptLevel; SavedFastISel = IS.TM.Options.EnableFastISel; if (NewOptLevel == SavedOptLevel) @@ -225,9 +225,9 @@ namespace llvm { IS.TM.setOptLevel(NewOptLevel); LLVM_DEBUG(dbgs() << "\nChanging optimization level for Function " << IS.MF->getFunction().getName() << "\n"); - LLVM_DEBUG(dbgs() << "\tBefore: -O" << SavedOptLevel << " ; After: -O" - << NewOptLevel << "\n"); - if (NewOptLevel == CodeGenOpt::None) { + LLVM_DEBUG(dbgs() << "\tBefore: -O" << static_cast(SavedOptLevel) << " ; After: -O" + << static_cast(NewOptLevel) << "\n"); + if (NewOptLevel == CodeGenOptLevel::None) { IS.TM.setFastISel(IS.TM.getO0WantsFastISel()); LLVM_DEBUG( dbgs() << "\tFastISel is " @@ -241,8 +241,8 @@ namespace llvm { return; LLVM_DEBUG(dbgs() << "\nRestoring optimization level for Function " << IS.MF->getFunction().getName() << "\n"); - LLVM_DEBUG(dbgs() << "\tBefore: -O" << IS.OptLevel << " ; After: -O" - << SavedOptLevel << "\n"); + LLVM_DEBUG(dbgs() << "\tBefore: -O" << static_cast(IS.OptLevel) + << " ; After: -O" << static_cast(SavedOptLevel) << "\n"); IS.OptLevel = SavedOptLevel; IS.TM.setOptLevel(SavedOptLevel); IS.TM.setFastISel(SavedFastISel); @@ -252,8 +252,8 @@ namespace llvm { //===--------------------------------------------------------------------===// /// createDefaultScheduler - This creates an instruction scheduler appropriate /// for the target. - ScheduleDAGSDNodes* createDefaultScheduler(SelectionDAGISel *IS, - CodeGenOpt::Level OptLevel) { + ScheduleDAGSDNodes *createDefaultScheduler(SelectionDAGISel *IS, + CodeGenOptLevel OptLevel) { const TargetLowering *TLI = IS->TLI; const TargetSubtargetInfo &ST = IS->MF->getSubtarget(); @@ -262,7 +262,7 @@ namespace llvm { return SchedulerCtor(IS, OptLevel); } - if (OptLevel == CodeGenOpt::None || + if (OptLevel == CodeGenOptLevel::None || (ST.enableMachineScheduler() && ST.enableMachineSchedDefaultSched()) || TLI->getSchedulingPreference() == Sched::Source) return createSourceListDAGScheduler(IS, OptLevel); @@ -315,7 +315,7 @@ void TargetLowering::AdjustInstrPostInstrSelection(MachineInstr &MI, //===----------------------------------------------------------------------===// SelectionDAGISel::SelectionDAGISel(char &ID, TargetMachine &tm, - CodeGenOpt::Level OL) + CodeGenOptLevel OL) : MachineFunctionPass(ID), TM(tm), FuncInfo(new FunctionLoweringInfo()), SwiftError(new SwiftErrorValueTracking()), CurDAG(new SelectionDAG(tm, OL)), @@ -335,23 +335,23 @@ SelectionDAGISel::~SelectionDAGISel() { } void SelectionDAGISel::getAnalysisUsage(AnalysisUsage &AU) const { - if (OptLevel != CodeGenOpt::None) - AU.addRequired(); + if (OptLevel != CodeGenOptLevel::None) + AU.addRequired(); AU.addRequired(); AU.addRequired(); AU.addPreserved(); AU.addRequired(); AU.addRequired(); AU.addRequired(); - if (UseMBPI && OptLevel != CodeGenOpt::None) - AU.addRequired(); + if (UseMBPI && OptLevel != CodeGenOptLevel::None) + AU.addRequired(); AU.addRequired(); // AssignmentTrackingAnalysis only runs if assignment tracking is enabled for // the module. AU.addRequired(); AU.addPreserved(); - if (OptLevel != CodeGenOpt::None) - LazyBlockFrequencyInfoPass::getLazyBFIAnalysisUsage(AU); + if (OptLevel != CodeGenOptLevel::None) + LazyBlockFrequencyInfoPass::getLazyBFIAnalysisUsage(AU); MachineFunctionPass::getAnalysisUsage(AU); } @@ -403,9 +403,9 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) { // it wants to look at it. TM.resetTargetOptions(Fn); // Reset OptLevel to None for optnone functions. - CodeGenOpt::Level NewOptLevel = OptLevel; - if (OptLevel != CodeGenOpt::None && skipFunction(Fn)) - NewOptLevel = CodeGenOpt::None; + CodeGenOptLevel NewOptLevel = OptLevel; + if (OptLevel != CodeGenOptLevel::None && skipFunction(Fn)) + NewOptLevel = CodeGenOptLevel::None; OptLevelChanger OLC(*this, NewOptLevel); TII = MF->getSubtarget().getInstrInfo(); @@ -417,7 +417,7 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) { AC = &getAnalysis().getAssumptionCache(mf.getFunction()); auto *PSI = &getAnalysis().getPSI(); BlockFrequencyInfo *BFI = nullptr; - if (PSI && PSI->hasProfileSummary() && OptLevel != CodeGenOpt::None) + if (PSI && PSI->hasProfileSummary() && OptLevel != CodeGenOptLevel::None) BFI = &getAnalysis().getBFI(); FunctionVarLocs const *FnVarLocs = nullptr; @@ -438,12 +438,12 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) { // into account). That's unfortunate but OK because it just means we won't // ask for passes that have been required anyway. - if (UseMBPI && OptLevel != CodeGenOpt::None) + if (UseMBPI && OptLevel != CodeGenOptLevel::None) FuncInfo->BPI = &getAnalysis().getBPI(); else FuncInfo->BPI = nullptr; - if (OptLevel != CodeGenOpt::None) + if (OptLevel != CodeGenOptLevel::None) AA = &getAnalysis().getAAResults(); else AA = nullptr; @@ -456,7 +456,7 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) { // We split CSR if the target supports it for the given function // and the function has only return exits. - if (OptLevel != CodeGenOpt::None && TLI->supportSplitCSR(MF)) { + if (OptLevel != CodeGenOptLevel::None && TLI->supportSplitCSR(MF)) { FuncInfo->SplitCSR = true; // Collect all the return blocks. @@ -935,7 +935,7 @@ void SelectionDAGISel::CodeGenAndEmitDAG() { CurDAG->VerifyDAGDivergence(); #endif - if (OptLevel != CodeGenOpt::None) + if (OptLevel != CodeGenOptLevel::None) ComputeLiveOutVRegInfo(); if (ViewISelDAGs && MatchFilterBB) @@ -1512,7 +1512,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(const Function &Fn) { // Iterate over all basic blocks in the function. StackProtector &SP = getAnalysis(); for (const BasicBlock *LLVMBB : RPOT) { - if (OptLevel != CodeGenOpt::None) { + if (OptLevel != CodeGenOptLevel::None) { bool AllPredsVisited = true; for (const BasicBlock *Pred : predecessors(LLVMBB)) { if (!FuncInfo->VisitedBBs.count(Pred)) { @@ -2180,16 +2180,18 @@ static bool findNonImmUse(SDNode *Root, SDNode *Def, SDNode *ImmedUse, /// operand node N of U during instruction selection that starts at Root. bool SelectionDAGISel::IsProfitableToFold(SDValue N, SDNode *U, SDNode *Root) const { - if (OptLevel == CodeGenOpt::None) return false; + if (OptLevel == CodeGenOptLevel::None) + return false; return N.hasOneUse(); } /// IsLegalToFold - Returns true if the specific operand node N of /// U can be folded during instruction selection that starts at Root. bool SelectionDAGISel::IsLegalToFold(SDValue N, SDNode *U, SDNode *Root, - CodeGenOpt::Level OptLevel, + CodeGenOptLevel OptLevel, bool IgnoreChains) { - if (OptLevel == CodeGenOpt::None) return false; + if (OptLevel == CodeGenOptLevel::None) + return false; // If Root use can somehow reach N through a path that doesn't contain // U then folding N would create a cycle. e.g. In the following diff --git a/llvm/lib/CodeGen/SwitchLoweringUtils.cpp b/llvm/lib/CodeGen/SwitchLoweringUtils.cpp index 36a02d5beb4b2..b01a8bed0a394 100644 --- a/llvm/lib/CodeGen/SwitchLoweringUtils.cpp +++ b/llvm/lib/CodeGen/SwitchLoweringUtils.cpp @@ -95,7 +95,7 @@ void SwitchCG::SwitchLowering::findJumpTables(CaseClusterVector &Clusters, } // The algorithm below is not suitable for -O0. - if (TM->getOptLevel() == CodeGenOpt::None) + if (TM->getOptLevel() == CodeGenOptLevel::None) return; // Split Clusters into minimum number of dense partitions. The algorithm uses @@ -278,7 +278,7 @@ void SwitchCG::SwitchLowering::findBitTestClusters(CaseClusterVector &Clusters, #endif // The algorithm below is not suitable for -O0. - if (TM->getOptLevel() == CodeGenOpt::None) + if (TM->getOptLevel() == CodeGenOptLevel::None) return; // If target does not have legal shift left, do not emit bit tests at all. diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp index 87ac68c834a86..e6ecbc9b03f71 100644 --- a/llvm/lib/CodeGen/TargetPassConfig.cpp +++ b/llvm/lib/CodeGen/TargetPassConfig.cpp @@ -631,7 +631,7 @@ TargetPassConfig::TargetPassConfig(LLVMTargetMachine &TM, PassManagerBase &pm) setStartStopPasses(); } -CodeGenOpt::Level TargetPassConfig::getOptLevel() const { +CodeGenOptLevel TargetPassConfig::getOptLevel() const { return TM->getOptLevel(); } @@ -846,7 +846,7 @@ void TargetPassConfig::addIRPasses() { if (!DisableVerify) addPass(createVerifierPass()); - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { // Basic AliasAnalysis support. // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that // BasicAliasAnalysis wins if they disagree. This is intended to help @@ -889,13 +889,13 @@ void TargetPassConfig::addIRPasses() { addPass(createUnreachableBlockEliminationPass()); // Prepare expensive constants for SelectionDAG. - if (getOptLevel() != CodeGenOpt::None && !DisableConstantHoisting) + if (getOptLevel() != CodeGenOptLevel::None && !DisableConstantHoisting) addPass(createConstantHoistingPass()); - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(createReplaceWithVeclibLegacyPass()); - if (getOptLevel() != CodeGenOpt::None && !DisablePartialLibcallInlining) + if (getOptLevel() != CodeGenOptLevel::None && !DisablePartialLibcallInlining) addPass(createPartiallyInlineLibCallsPass()); // Expand vector predication intrinsics into standard IR instructions. @@ -913,11 +913,11 @@ void TargetPassConfig::addIRPasses() { if (!DisableExpandReductions) addPass(createExpandReductionsPass()); - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(createTLSVariableHoistPass()); // Convert conditional moves to conditional jumps when profitable. - if (getOptLevel() != CodeGenOpt::None && !DisableSelectOptimize) + if (getOptLevel() != CodeGenOptLevel::None && !DisableSelectOptimize) addPass(createSelectOptimizePass()); } @@ -968,7 +968,7 @@ void TargetPassConfig::addPassesToHandleExceptions() { /// Add pass to prepare the LLVM IR for code generation. This should be done /// before exception handling preparation passes. void TargetPassConfig::addCodeGenPrepare() { - if (getOptLevel() != CodeGenOpt::None && !DisableCGP) + if (getOptLevel() != CodeGenOptLevel::None && !DisableCGP) addPass(createCodeGenPreparePass()); } @@ -1012,7 +1012,8 @@ bool TargetPassConfig::addCoreISelPasses() { (TM->Options.EnableGlobalISel && EnableGlobalISelOption != cl::BOU_FALSE)) Selector = SelectorType::GlobalISel; - else if (TM->getOptLevel() == CodeGenOpt::None && TM->getO0WantsFastISel()) + else if (TM->getOptLevel() == CodeGenOptLevel::None && + TM->getO0WantsFastISel()) Selector = SelectorType::FastISel; else Selector = SelectorType::SelectionDAG; @@ -1129,7 +1130,7 @@ void TargetPassConfig::addMachinePasses() { AddingMachinePasses = true; // Add passes that optimize machine instructions in SSA form. - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { addMachineSSAOptimization(); } else { // If the target requests it, assign local variables to stack slots relative @@ -1175,7 +1176,7 @@ void TargetPassConfig::addMachinePasses() { addPass(&FixupStatepointCallerSavedID); // Insert prolog/epilog code. Eliminate abstract frame index references... - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { addPass(&PostRAMachineSinkingID); addPass(&ShrinkWrapID); } @@ -1186,8 +1187,8 @@ void TargetPassConfig::addMachinePasses() { addPass(createPrologEpilogInserterPass()); /// Add passes that optimize machine instructions after register allocation. - if (getOptLevel() != CodeGenOpt::None) - addMachineLateOptimization(); + if (getOptLevel() != CodeGenOptLevel::None) + addMachineLateOptimization(); // Expand pseudo instructions before second scheduling pass. addPass(&ExpandPostRAPseudosID); @@ -1201,7 +1202,7 @@ void TargetPassConfig::addMachinePasses() { // Second pass scheduler. // Let Target optionally insert this pass by itself at some other // point. - if (getOptLevel() != CodeGenOpt::None && + if (getOptLevel() != CodeGenOptLevel::None && !TM->targetSchedulesPostRAScheduling()) { if (MISchedPostRA) addPass(&PostMachineSchedulerID); @@ -1216,7 +1217,7 @@ void TargetPassConfig::addMachinePasses() { } // Basic block placement. - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addBlockPlacement(); // Insert before XRay Instrumentation. @@ -1240,7 +1241,8 @@ void TargetPassConfig::addMachinePasses() { addPass(&LiveDebugValuesID); addPass(&MachineSanitizerBinaryMetadataID); - if (TM->Options.EnableMachineOutliner && getOptLevel() != CodeGenOpt::None && + if (TM->Options.EnableMachineOutliner && + getOptLevel() != CodeGenOptLevel::None && EnableMachineOutliner != RunOutliner::NeverOutline) { bool RunOnAllFunctions = (EnableMachineOutliner == RunOutliner::AlwaysOutline); @@ -1344,7 +1346,8 @@ void TargetPassConfig::addMachineSSAOptimization() { bool TargetPassConfig::getOptimizeRegAlloc() const { switch (OptimizeRegAlloc) { - case cl::BOU_UNSET: return getOptLevel() != CodeGenOpt::None; + case cl::BOU_UNSET: + return getOptLevel() != CodeGenOptLevel::None; case cl::BOU_TRUE: return true; case cl::BOU_FALSE: return false; } diff --git a/llvm/lib/CodeGen/TargetSubtargetInfo.cpp b/llvm/lib/CodeGen/TargetSubtargetInfo.cpp index ba2c8dda7de59..6c97bc0568bde 100644 --- a/llvm/lib/CodeGen/TargetSubtargetInfo.cpp +++ b/llvm/lib/CodeGen/TargetSubtargetInfo.cpp @@ -41,7 +41,7 @@ bool TargetSubtargetInfo::enableJoinGlobalCopies() const { } bool TargetSubtargetInfo::enableRALocalReassignment( - CodeGenOpt::Level OptLevel) const { + CodeGenOptLevel OptLevel) const { return true; } diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp index 45f61262faf93..79fe7f4a9e9ff 100644 --- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -95,7 +95,7 @@ class TwoAddressInstructionPass : public MachineFunctionPass { LiveVariables *LV = nullptr; LiveIntervals *LIS = nullptr; AliasAnalysis *AA = nullptr; - CodeGenOpt::Level OptLevel = CodeGenOpt::None; + CodeGenOptLevel OptLevel = CodeGenOptLevel::None; // The current basic block being processed. MachineBasicBlock *MBB = nullptr; @@ -551,7 +551,7 @@ bool TwoAddressInstructionPass::isProfitableToCommute(Register RegA, Register RegC, MachineInstr *MI, unsigned Dist) { - if (OptLevel == CodeGenOpt::None) + if (OptLevel == CodeGenOptLevel::None) return false; // Determine if it's profitable to commute this two address instruction. In @@ -1231,7 +1231,7 @@ tryInstructionTransform(MachineBasicBlock::iterator &mi, MachineBasicBlock::iterator &nmi, unsigned SrcIdx, unsigned DstIdx, unsigned &Dist, bool shouldOnlyCommute) { - if (OptLevel == CodeGenOpt::None) + if (OptLevel == CodeGenOptLevel::None) return false; MachineInstr &MI = *mi; @@ -1757,7 +1757,7 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &Func) { // Disable optimizations if requested. We cannot skip the whole pass as some // fixups are necessary for correctness. if (skipFunction(Func.getFunction())) - OptLevel = CodeGenOpt::None; + OptLevel = CodeGenOptLevel::None; bool MadeChange = false; diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp index 98d7dcb8ec12b..9e81cca0b103a 100644 --- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp @@ -471,7 +471,7 @@ EngineBuilder::EngineBuilder() : EngineBuilder(nullptr) {} EngineBuilder::EngineBuilder(std::unique_ptr M) : M(std::move(M)), WhichEngine(EngineKind::Either), ErrorStr(nullptr), - OptLevel(CodeGenOpt::Default), MemMgr(nullptr), Resolver(nullptr) { + OptLevel(CodeGenOptLevel::Default), MemMgr(nullptr), Resolver(nullptr) { // IR module verification is enabled by default in debug builds, and disabled // by default in release builds. #ifndef NDEBUG diff --git a/llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp b/llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp index dc9a07e3f2123..772a3fa93c51e 100644 --- a/llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp +++ b/llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp @@ -138,8 +138,8 @@ LLVMBool LLVMCreateJITCompilerForModule(LLVMExecutionEngineRef *OutJIT, std::string Error; EngineBuilder builder(std::unique_ptr(unwrap(M))); builder.setEngineKind(EngineKind::JIT) - .setErrorStr(&Error) - .setOptLevel((CodeGenOpt::Level)OptLevel); + .setErrorStr(&Error) + .setOptLevel((CodeGenOptLevel)OptLevel); if (ExecutionEngine *JIT = builder.create()) { *OutJIT = wrap(JIT); return 0; @@ -196,9 +196,9 @@ LLVMBool LLVMCreateMCJITCompilerForModule( std::string Error; EngineBuilder builder(std::move(Mod)); builder.setEngineKind(EngineKind::JIT) - .setErrorStr(&Error) - .setOptLevel((CodeGenOpt::Level)options.OptLevel) - .setTargetOptions(targetOptions); + .setErrorStr(&Error) + .setOptLevel((CodeGenOptLevel)options.OptLevel) + .setTargetOptions(targetOptions); bool JIT; if (std::optional CM = unwrap(options.CodeModel, JIT)) builder.setCodeModel(*CM); diff --git a/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp b/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp index b66f52f1ec5d6..17a96dee1000b 100644 --- a/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp +++ b/llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp @@ -126,16 +126,16 @@ void JITTargetMachineBuilderPrinter::print(raw_ostream &OS) const { OS << "\n" << Indent << " Optimization Level = "; switch (JTMB.OptLevel) { - case CodeGenOpt::None: + case CodeGenOptLevel::None: OS << "None"; break; - case CodeGenOpt::Less: + case CodeGenOptLevel::Less: OS << "Less"; break; - case CodeGenOpt::Default: + case CodeGenOptLevel::Default: OS << "Default"; break; - case CodeGenOpt::Aggressive: + case CodeGenOptLevel::Aggressive: OS << "Aggressive"; break; } diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index 9341c529c603e..8e9200aa18219 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -3394,7 +3394,7 @@ void OpenMPIRBuilder::applySimd(CanonicalLoopInfo *CanonicalLoop, /// "target-features" that determine the TargetMachine are per-function and can /// be overrided using __attribute__((target("OPTIONS"))). static std::unique_ptr -createTargetMachine(Function *F, CodeGenOpt::Level OptLevel) { +createTargetMachine(Function *F, CodeGenOptLevel OptLevel) { Module *M = F->getParent(); StringRef CPU = F->getFnAttribute("target-cpu").getValueAsString(); @@ -3420,7 +3420,7 @@ static int32_t computeHeuristicUnrollFactor(CanonicalLoopInfo *CLI) { // Assume the user requests the most aggressive unrolling, even if the rest of // the code is optimized using a lower setting. - CodeGenOpt::Level OptLevel = CodeGenOpt::Aggressive; + CodeGenOptLevel OptLevel = CodeGenOptLevel::Aggressive; std::unique_ptr TM = createTargetMachine(F, OptLevel); FunctionAnalysisManager FAM; @@ -3453,7 +3453,7 @@ static int32_t computeHeuristicUnrollFactor(CanonicalLoopInfo *CLI) { TargetTransformInfo::UnrollingPreferences UP = gatherUnrollingPreferences(L, SE, TTI, /*BlockFrequencyInfo=*/nullptr, - /*ProfileSummaryInfo=*/nullptr, ORE, OptLevel, + /*ProfileSummaryInfo=*/nullptr, ORE, static_cast(OptLevel), /*UserThreshold=*/std::nullopt, /*UserCount=*/std::nullopt, /*UserAllowPartial=*/true, diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 2a3f44d41cbfd..3e008edd3ee0b 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -142,8 +142,8 @@ void llvm::computeLTOCacheKey( AddUnsigned(-1); for (const auto &S : Conf.MllvmArgs) AddString(S); - AddUnsigned(Conf.CGOptLevel); - AddUnsigned(Conf.CGFileType); + AddUnsigned(static_cast(Conf.CGOptLevel)); + AddUnsigned(static_cast(Conf.CGFileType)); AddUnsigned(Conf.OptLevel); AddUnsigned(Conf.Freestanding); AddString(Conf.OptPipeline); diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index 1402da7fbbd27..52a4a9ba85e81 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -200,7 +200,7 @@ void LTOCodeGenerator::setOptLevel(unsigned Level) { Config.OptLevel = Level; Config.PTO.LoopVectorization = Config.OptLevel > 1; Config.PTO.SLPVectorization = Config.OptLevel > 1; - std::optional CGOptLevelOrNone = + std::optional CGOptLevelOrNone = CodeGenOpt::getLevel(Config.OptLevel); assert(CGOptLevelOrNone && "Unknown optimization level!"); Config.CGOptLevel = *CGOptLevelOrNone; @@ -306,7 +306,7 @@ bool LTOCodeGenerator::runAIXSystemAssembler(SmallString<128> &AssemblyFile) { bool LTOCodeGenerator::compileOptimizedToFile(const char **Name) { if (useAIXSystemAssembler()) - setFileType(CGFT_AssemblyFile); + setFileType(CodeGenFileType::AssemblyFile); // make unique temp output file to put generated code SmallString<128> Filename; @@ -314,7 +314,8 @@ bool LTOCodeGenerator::compileOptimizedToFile(const char **Name) { auto AddStream = [&](size_t Task, const Twine &ModuleName) -> std::unique_ptr { - StringRef Extension(Config.CGFileType == CGFT_AssemblyFile ? "s" : "o"); + StringRef Extension( + Config.CGFileType == CodeGenFileType::AssemblyFile ? "s" : "o"); int FD; std::error_code EC = diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index f207b279ac09c..02a45351462da 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -338,7 +338,7 @@ std::unique_ptr codegenModule(Module &TheModule, PM.add(createObjCARCContractPass()); // Setup the codegen now. - if (TM.addPassesToEmitFile(PM, OS, nullptr, CGFT_ObjectFile, + if (TM.addPassesToEmitFile(PM, OS, nullptr, CodeGenFileType::ObjectFile, /* DisableVerify */ true)) report_fatal_error("Failed to setup codegen"); diff --git a/llvm/lib/Target/AArch64/AArch64.h b/llvm/lib/Target/AArch64/AArch64.h index 76f55666e7435..1a86fc45adc07 100644 --- a/llvm/lib/Target/AArch64/AArch64.h +++ b/llvm/lib/Target/AArch64/AArch64.h @@ -36,7 +36,7 @@ FunctionPass *createAArch64CompressJumpTablesPass(); FunctionPass *createAArch64ConditionalCompares(); FunctionPass *createAArch64AdvSIMDScalar(); FunctionPass *createAArch64ISelDag(AArch64TargetMachine &TM, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); FunctionPass *createAArch64StorePairSuppressPass(); FunctionPass *createAArch64ExpandPseudoPass(); FunctionPass *createAArch64SLSHardeningPass(); diff --git a/llvm/lib/Target/AArch64/AArch64FastISel.cpp b/llvm/lib/Target/AArch64/AArch64FastISel.cpp index b2c46939e5846..ce1c1f7d403ad 100644 --- a/llvm/lib/Target/AArch64/AArch64FastISel.cpp +++ b/llvm/lib/Target/AArch64/AArch64FastISel.cpp @@ -5034,7 +5034,7 @@ bool AArch64FastISel::selectGetElementPtr(const Instruction *I) { } bool AArch64FastISel::selectAtomicCmpXchg(const AtomicCmpXchgInst *I) { - assert(TM.getOptLevel() == CodeGenOpt::None && + assert(TM.getOptLevel() == CodeGenOptLevel::None && "cmpxchg survived AtomicExpand at optlevel > -O0"); auto *RetPairTy = cast(I->getType()); diff --git a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp index 16ab662ca34aa..38759a2474518 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp @@ -49,7 +49,7 @@ class AArch64DAGToDAGISel : public SelectionDAGISel { AArch64DAGToDAGISel() = delete; explicit AArch64DAGToDAGISel(AArch64TargetMachine &tm, - CodeGenOpt::Level OptLevel) + CodeGenOptLevel OptLevel) : SelectionDAGISel(ID, tm, OptLevel), Subtarget(nullptr) {} bool runOnMachineFunction(MachineFunction &MF) override { @@ -6604,7 +6604,7 @@ void AArch64DAGToDAGISel::Select(SDNode *Node) { /// createAArch64ISelDag - This pass converts a legalized DAG into a /// AArch64-specific DAG, ready for instruction scheduling. FunctionPass *llvm::createAArch64ISelDag(AArch64TargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new AArch64DAGToDAGISel(TM, OptLevel); } diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 5da41ec6376dc..30a66c7ae4be8 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -15707,8 +15707,8 @@ bool AArch64TargetLowering::isFMAFasterThanFMulAndFAdd(const Function &F, } bool AArch64TargetLowering::generateFMAsInMachineCombiner( - EVT VT, CodeGenOpt::Level OptLevel) const { - return (OptLevel >= CodeGenOpt::Aggressive) && !VT.isScalableVector() && + EVT VT, CodeGenOptLevel OptLevel) const { + return (OptLevel >= CodeGenOptLevel::Aggressive) && !VT.isScalableVector() && !useSVEForFixedLengthVectorVT(VT); } @@ -24427,7 +24427,7 @@ AArch64TargetLowering::shouldExpandAtomicLoadInIR(LoadInst *LI) const { // stack and close enough to the spill slot, this can lead to a situation // where the monitor always gets cleared and the atomic operation can never // succeed. So at -O0 lower this operation to a CAS loop. - if (getTargetMachine().getOptLevel() == CodeGenOpt::None) + if (getTargetMachine().getOptLevel() == CodeGenOptLevel::None) return AtomicExpansionKind::CmpXChg; // Using CAS for an atomic load has a better chance of succeeding under high @@ -24479,7 +24479,7 @@ AArch64TargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const { // where the monitor always gets cleared and the atomic operation can never // succeed. So at -O0 lower this operation to a CAS loop. Also worthwhile if // we have a single CAS instruction that can replace the loop. - if (getTargetMachine().getOptLevel() == CodeGenOpt::None || + if (getTargetMachine().getOptLevel() == CodeGenOptLevel::None || Subtarget->hasLSE()) return AtomicExpansionKind::CmpXChg; @@ -24497,7 +24497,7 @@ AArch64TargetLowering::shouldExpandAtomicCmpXchgInIR( // on the stack and close enough to the spill slot, this can lead to a // situation where the monitor always gets cleared and the atomic operation // can never succeed. So at -O0 we need a late-expanded pseudo-inst instead. - if (getTargetMachine().getOptLevel() == CodeGenOpt::None) + if (getTargetMachine().getOptLevel() == CodeGenOptLevel::None) return AtomicExpansionKind::None; // 128-bit atomic cmpxchg is weird; AtomicExpand doesn't know how to expand diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h index f2696b6b97593..48b5bc16b3653 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h @@ -681,7 +681,7 @@ class AArch64TargetLowering : public TargetLowering { bool isFMAFasterThanFMulAndFAdd(const Function &F, Type *Ty) const override; bool generateFMAsInMachineCombiner(EVT VT, - CodeGenOpt::Level OptLevel) const override; + CodeGenOptLevel OptLevel) const override; const MCPhysReg *getScratchRegisters(CallingConv::ID CC) const override; ArrayRef getRoundingControlRegisters() const override; diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index 3a18f37e31185..5ad2e4837e3db 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -8533,8 +8533,8 @@ bool AArch64InstrInfo::isWhileOpcode(unsigned Opc) const { } unsigned int -AArch64InstrInfo::getTailDuplicateSize(CodeGenOpt::Level OptLevel) const { - return OptLevel >= CodeGenOpt::Aggressive ? 6 : 2; +AArch64InstrInfo::getTailDuplicateSize(CodeGenOptLevel OptLevel) const { + return OptLevel >= CodeGenOptLevel::Aggressive ? 6 : 2; } unsigned llvm::getBLRCallOpcode(const MachineFunction &MF) { diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.h b/llvm/lib/Target/AArch64/AArch64InstrInfo.h index 24ff676218cbe..2cd028d263f69 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.h +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.h @@ -343,7 +343,7 @@ class AArch64InstrInfo final : public AArch64GenInstrInfo { std::optional describeLoadedValue(const MachineInstr &MI, Register Reg) const override; - unsigned int getTailDuplicateSize(CodeGenOpt::Level OptLevel) const override; + unsigned int getTailDuplicateSize(CodeGenOptLevel OptLevel) const override; bool isExtendLikelyToBeFolded(MachineInstr &ExtMI, MachineRegisterInfo &MRI) const override; diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp index 6f7fccdf84fed..a3aa4a5a73c35 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp @@ -320,7 +320,7 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT, + CodeGenOptLevel OL, bool JIT, bool LittleEndian) : LLVMTargetMachine(T, computeDataLayout(TT, Options.MCOptions, LittleEndian), @@ -358,7 +358,7 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, const Triple &TT, // Enable GlobalISel at or below EnableGlobalISelAt0, unless this is // MachO/CodeModel::Large, which GlobalISel does not support. - if (getOptLevel() <= EnableGlobalISelAtO && + if (static_cast(getOptLevel()) <= EnableGlobalISelAtO && TT.getArch() != Triple::aarch64_32 && TT.getEnvironment() != Triple::GNUILP32 && !(getCodeModel() == CodeModel::Large && TT.isOSBinFormatMachO())) { @@ -451,7 +451,7 @@ void AArch64leTargetMachine::anchor() { } AArch64leTargetMachine::AArch64leTargetMachine( const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, bool JIT) + std::optional CM, CodeGenOptLevel OL, bool JIT) : AArch64TargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, true) {} void AArch64beTargetMachine::anchor() { } @@ -459,7 +459,7 @@ void AArch64beTargetMachine::anchor() { } AArch64beTargetMachine::AArch64beTargetMachine( const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, bool JIT) + std::optional CM, CodeGenOptLevel OL, bool JIT) : AArch64TargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, false) {} namespace { @@ -469,7 +469,7 @@ class AArch64PassConfig : public TargetPassConfig { public: AArch64PassConfig(AArch64TargetMachine &TM, PassManagerBase &PM) : TargetPassConfig(TM, PM) { - if (TM.getOptLevel() != CodeGenOpt::None) + if (TM.getOptLevel() != CodeGenOptLevel::None) substitutePass(&PostRASchedulerID, &PostMachineSchedulerID); } @@ -547,13 +547,14 @@ void AArch64PassConfig::addIRPasses() { addPass(createAtomicExpandPass()); // Expand any SVE vector library calls that we can't code generate directly. - if (EnableSVEIntrinsicOpts && TM->getOptLevel() == CodeGenOpt::Aggressive) + if (EnableSVEIntrinsicOpts && + TM->getOptLevel() == CodeGenOptLevel::Aggressive) addPass(createSVEIntrinsicOptsPass()); // Cmpxchg instructions are often used with a subsequent comparison to // determine whether it succeeded. We can exploit existing control-flow in // ldrex/strex loops to simplify this, but it needs tidying up. - if (TM->getOptLevel() != CodeGenOpt::None && EnableAtomicTidy) + if (TM->getOptLevel() != CodeGenOptLevel::None && EnableAtomicTidy) addPass(createCFGSimplificationPass(SimplifyCFGOptions() .forwardSwitchCondToPhi(true) .convertSwitchRangeToICmp(true) @@ -566,14 +567,14 @@ void AArch64PassConfig::addIRPasses() { // // Run this before LSR to remove the multiplies involved in computing the // pointer values N iterations ahead. - if (TM->getOptLevel() != CodeGenOpt::None) { + if (TM->getOptLevel() != CodeGenOptLevel::None) { if (EnableLoopDataPrefetch) addPass(createLoopDataPrefetchPass()); if (EnableFalkorHWPFFix) addPass(createFalkorMarkStridedAccessesPass()); } - if (TM->getOptLevel() == CodeGenOpt::Aggressive && EnableGEPOpt) { + if (TM->getOptLevel() == CodeGenOptLevel::Aggressive && EnableGEPOpt) { // Call SeparateConstOffsetFromGEP pass to extract constants within indices // and lower a GEP with multiple indices to either arithmetic operations or // multiple GEPs with single index. @@ -588,19 +589,19 @@ void AArch64PassConfig::addIRPasses() { TargetPassConfig::addIRPasses(); - if (getOptLevel() == CodeGenOpt::Aggressive && EnableSelectOpt) + if (getOptLevel() == CodeGenOptLevel::Aggressive && EnableSelectOpt) addPass(createSelectOptimizePass()); addPass(createAArch64GlobalsTaggingPass()); addPass(createAArch64StackTaggingPass( - /*IsOptNone=*/TM->getOptLevel() == CodeGenOpt::None)); + /*IsOptNone=*/TM->getOptLevel() == CodeGenOptLevel::None)); // Match complex arithmetic patterns - if (TM->getOptLevel() >= CodeGenOpt::Default) + if (TM->getOptLevel() >= CodeGenOptLevel::Default) addPass(createComplexDeinterleavingPass(TM)); // Match interleaved memory accesses to ldN/stN intrinsics. - if (TM->getOptLevel() != CodeGenOpt::None) { + if (TM->getOptLevel() != CodeGenOptLevel::None) { addPass(createInterleavedLoadCombinePass()); addPass(createInterleavedAccessPass()); } @@ -622,16 +623,17 @@ void AArch64PassConfig::addIRPasses() { bool AArch64PassConfig::addPreISel() { // Run promote constant before global merge, so that the promoted constants // get a chance to be merged - if (TM->getOptLevel() != CodeGenOpt::None && EnablePromoteConstant) + if (TM->getOptLevel() != CodeGenOptLevel::None && EnablePromoteConstant) addPass(createAArch64PromoteConstantPass()); // FIXME: On AArch64, this depends on the type. // Basically, the addressable offsets are up to 4095 * Ty.getSizeInBytes(). // and the offset has to be a multiple of the related size in bytes. - if ((TM->getOptLevel() != CodeGenOpt::None && + if ((TM->getOptLevel() != CodeGenOptLevel::None && EnableGlobalMerge == cl::BOU_UNSET) || EnableGlobalMerge == cl::BOU_TRUE) { - bool OnlyOptimizeForSize = (TM->getOptLevel() < CodeGenOpt::Aggressive) && - (EnableGlobalMerge == cl::BOU_UNSET); + bool OnlyOptimizeForSize = + (TM->getOptLevel() < CodeGenOptLevel::Aggressive) && + (EnableGlobalMerge == cl::BOU_UNSET); // Merging of extern globals is enabled by default on non-Mach-O as we // expect it to be generally either beneficial or harmless. On Mach-O it @@ -652,7 +654,7 @@ bool AArch64PassConfig::addPreISel() { } void AArch64PassConfig::addCodeGenPrepare() { - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(createTypePromotionLegacyPass()); TargetPassConfig::addCodeGenPrepare(); } @@ -663,7 +665,7 @@ bool AArch64PassConfig::addInstSelector() { // For ELF, cleanup any local-dynamic TLS accesses (i.e. combine as many // references to _TLS_MODULE_BASE_ as possible. if (TM->getTargetTriple().isOSBinFormatELF() && - getOptLevel() != CodeGenOpt::None) + getOptLevel() != CodeGenOptLevel::None) addPass(createAArch64CleanupLocalDynamicTLSPass()); return false; @@ -675,7 +677,7 @@ bool AArch64PassConfig::addIRTranslator() { } void AArch64PassConfig::addPreLegalizeMachineIR() { - if (getOptLevel() == CodeGenOpt::None) { + if (getOptLevel() == CodeGenOptLevel::None) { addPass(createAArch64O0PreLegalizerCombiner()); addPass(new Localizer()); } else { @@ -692,7 +694,7 @@ bool AArch64PassConfig::addLegalizeMachineIR() { } void AArch64PassConfig::addPreRegBankSelect() { - bool IsOptNone = getOptLevel() == CodeGenOpt::None; + bool IsOptNone = getOptLevel() == CodeGenOptLevel::None; if (!IsOptNone) { addPass(createAArch64PostLegalizerCombiner(IsOptNone)); if (EnableGISelLoadStoreOptPostLegal) @@ -708,7 +710,7 @@ bool AArch64PassConfig::addRegBankSelect() { bool AArch64PassConfig::addGlobalInstructionSelect() { addPass(new InstructionSelect(getOptLevel())); - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(createAArch64PostSelectOptimize()); return false; } @@ -717,7 +719,7 @@ void AArch64PassConfig::addMachineSSAOptimization() { // Run default MachineSSAOptimization first. TargetPassConfig::addMachineSSAOptimization(); - if (TM->getOptLevel() != CodeGenOpt::None) + if (TM->getOptLevel() != CodeGenOptLevel::None) addPass(createAArch64MIPeepholeOptPass()); } @@ -735,18 +737,19 @@ bool AArch64PassConfig::addILPOpts() { if (EnableStPairSuppress) addPass(createAArch64StorePairSuppressPass()); addPass(createAArch64SIMDInstrOptPass()); - if (TM->getOptLevel() != CodeGenOpt::None) + if (TM->getOptLevel() != CodeGenOptLevel::None) addPass(createAArch64StackTaggingPreRAPass()); return true; } void AArch64PassConfig::addPreRegAlloc() { // Change dead register definitions to refer to the zero register. - if (TM->getOptLevel() != CodeGenOpt::None && EnableDeadRegisterElimination) + if (TM->getOptLevel() != CodeGenOptLevel::None && + EnableDeadRegisterElimination) addPass(createAArch64DeadRegisterDefinitions()); // Use AdvSIMD scalar instructions whenever profitable. - if (TM->getOptLevel() != CodeGenOpt::None && EnableAdvSIMDScalar) { + if (TM->getOptLevel() != CodeGenOptLevel::None && EnableAdvSIMDScalar) { addPass(createAArch64AdvSIMDScalar()); // The AdvSIMD pass may produce copies that can be rewritten to // be register coalescer friendly. @@ -756,10 +759,11 @@ void AArch64PassConfig::addPreRegAlloc() { void AArch64PassConfig::addPostRegAlloc() { // Remove redundant copy instructions. - if (TM->getOptLevel() != CodeGenOpt::None && EnableRedundantCopyElimination) + if (TM->getOptLevel() != CodeGenOptLevel::None && + EnableRedundantCopyElimination) addPass(createAArch64RedundantCopyEliminationPass()); - if (TM->getOptLevel() != CodeGenOpt::None && usingDefaultRegAlloc()) + if (TM->getOptLevel() != CodeGenOptLevel::None && usingDefaultRegAlloc()) // Improve performance for some FP/SIMD code for A57. addPass(createAArch64A57FPLoadBalancing()); } @@ -771,7 +775,7 @@ void AArch64PassConfig::addPreSched2() { // Expand some pseudo instructions to allow proper scheduling. addPass(createAArch64ExpandPseudoPass()); // Use load/store pair instructions when possible. - if (TM->getOptLevel() != CodeGenOpt::None) { + if (TM->getOptLevel() != CodeGenOptLevel::None) { if (EnableLoadStoreOpt) addPass(createAArch64LoadStoreOptimizationPass()); } @@ -788,7 +792,7 @@ void AArch64PassConfig::addPreSched2() { addPass(createAArch64IndirectThunks()); addPass(createAArch64SLSHardeningPass()); - if (TM->getOptLevel() != CodeGenOpt::None) { + if (TM->getOptLevel() != CodeGenOptLevel::None) { if (EnableFalkorHWPFFix) addPass(createFalkorHWPFFixPass()); } @@ -798,10 +802,10 @@ void AArch64PassConfig::addPreEmitPass() { // Machine Block Placement might have created new opportunities when run // at O3, where the Tail Duplication Threshold is set to 4 instructions. // Run the load/store optimizer once more. - if (TM->getOptLevel() >= CodeGenOpt::Aggressive && EnableLoadStoreOpt) + if (TM->getOptLevel() >= CodeGenOptLevel::Aggressive && EnableLoadStoreOpt) addPass(createAArch64LoadStoreOptimizationPass()); - if (TM->getOptLevel() >= CodeGenOpt::Aggressive && + if (TM->getOptLevel() >= CodeGenOptLevel::Aggressive && EnableAArch64CopyPropagation) addPass(createMachineCopyPropagationPass(true)); @@ -817,7 +821,7 @@ void AArch64PassConfig::addPreEmitPass() { addPass(createEHContGuardCatchretPass()); } - if (TM->getOptLevel() != CodeGenOpt::None && EnableCollectLOH && + if (TM->getOptLevel() != CodeGenOptLevel::None && EnableCollectLOH && TM->getTargetTriple().isOSBinFormatMachO()) addPass(createAArch64CollectLOHPass()); } @@ -828,7 +832,7 @@ void AArch64PassConfig::addPostBBSections() { if (BranchRelaxation) addPass(&BranchRelaxationPassID); - if (TM->getOptLevel() != CodeGenOpt::None && EnableCompressJumpTables) + if (TM->getOptLevel() != CodeGenOptLevel::None && EnableCompressJumpTables) addPass(createAArch64CompressJumpTablesPass()); } diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.h b/llvm/lib/Target/AArch64/AArch64TargetMachine.h index e9b5f4820b79c..12b971853f847 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetMachine.h +++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.h @@ -30,7 +30,7 @@ class AArch64TargetMachine : public LLVMTargetMachine { AArch64TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT, bool IsLittleEndian); ~AArch64TargetMachine() override; @@ -80,8 +80,8 @@ class AArch64leTargetMachine : public AArch64TargetMachine { AArch64leTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, - CodeGenOpt::Level OL, bool JIT); + std::optional CM, CodeGenOptLevel OL, + bool JIT); }; // AArch64 big endian target machine. @@ -93,8 +93,8 @@ class AArch64beTargetMachine : public AArch64TargetMachine { AArch64beTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, - CodeGenOpt::Level OL, bool JIT); + std::optional CM, CodeGenOptLevel OL, + bool JIT); }; } // end namespace llvm diff --git a/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp b/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp index 5e248f568effc..09636bf61cd3b 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerCombiner.cpp @@ -434,7 +434,7 @@ bool AArch64PostLegalizerCombiner::runOnMachineFunction(MachineFunction &MF) { auto *TPC = &getAnalysis(); const Function &F = MF.getFunction(); bool EnableOpt = - MF.getTarget().getOptLevel() != CodeGenOpt::None && !skipFunction(F); + MF.getTarget().getOptLevel() != CodeGenOptLevel::None && !skipFunction(F); const AArch64Subtarget &ST = MF.getSubtarget(); const auto *LI = ST.getLegalizerInfo(); diff --git a/llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp b/llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp index cf131613802d3..d9678bea214dd 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp @@ -479,7 +479,7 @@ bool AArch64PreLegalizerCombiner::runOnMachineFunction(MachineFunction &MF) { const Function &F = MF.getFunction(); bool EnableOpt = - MF.getTarget().getOptLevel() != CodeGenOpt::None && !skipFunction(F); + MF.getTarget().getOptLevel() != CodeGenOptLevel::None && !skipFunction(F); GISelKnownBits *KB = &getAnalysis().get(MF); MachineDominatorTree *MDT = &getAnalysis(); CombinerInfo CInfo(/*AllowIllegalOps*/ true, /*ShouldLegalizeIllegal*/ false, diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.h b/llvm/lib/Target/AMDGPU/AMDGPU.h index 3d00df59cfe48..b7101f4011547 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPU.h +++ b/llvm/lib/Target/AMDGPU/AMDGPU.h @@ -215,8 +215,7 @@ struct AMDGPUAtomicOptimizerPass : PassInfoMixin { }; Pass *createAMDGPUStructurizeCFGPass(); -FunctionPass *createAMDGPUISelDag(TargetMachine &TM, - CodeGenOpt::Level OptLevel); +FunctionPass *createAMDGPUISelDag(TargetMachine &TM, CodeGenOptLevel OptLevel); ModulePass *createAMDGPUAlwaysInlinePass(bool GlobalOpt = true); struct AMDGPUAlwaysInlinePass : PassInfoMixin { diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp index 5c115499f8816..05deb69b2bfc1 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp @@ -112,12 +112,12 @@ INITIALIZE_PASS_END(AMDGPUDAGToDAGISel, "amdgpu-isel", /// This pass converts a legalized DAG into a AMDGPU-specific // DAG, ready for instruction scheduling. FunctionPass *llvm::createAMDGPUISelDag(TargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new AMDGPUDAGToDAGISel(TM, OptLevel); } AMDGPUDAGToDAGISel::AMDGPUDAGToDAGISel(TargetMachine &TM, - CodeGenOpt::Level OptLevel) + CodeGenOptLevel OptLevel) : SelectionDAGISel(ID, TM, OptLevel) { EnableLateStructurizeCFG = AMDGPUTargetMachine::EnableLateStructurizeCFG; } diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h index 06a03cfe02579..7b4a1a4aedaf7 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h +++ b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h @@ -92,7 +92,7 @@ class AMDGPUDAGToDAGISel : public SelectionDAGISel { AMDGPUDAGToDAGISel() = delete; - explicit AMDGPUDAGToDAGISel(TargetMachine &TM, CodeGenOpt::Level OptLevel); + explicit AMDGPUDAGToDAGISel(TargetMachine &TM, CodeGenOptLevel OptLevel); ~AMDGPUDAGToDAGISel() override = default; void getAnalysisUsage(AnalysisUsage &AU) const override; diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp index 1bde2f30e3778..9f13f58f8a9f4 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp @@ -1710,7 +1710,7 @@ bool AMDGPUInstructionSelector::selectDSAppendConsume(MachineInstr &MI, } bool AMDGPUInstructionSelector::selectSBarrier(MachineInstr &MI) const { - if (TM.getOptLevel() > CodeGenOpt::None) { + if (TM.getOptLevel() > CodeGenOptLevel::None) { unsigned WGSize = STI.getFlatWorkGroupSizes(MF->getFunction()).second; if (WGSize <= STI.getWavefrontSize()) { MachineBasicBlock *MBB = MI.getParent(); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp index 21cf4794921d3..7b18e1f805d8f 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp @@ -470,7 +470,7 @@ bool AMDGPUPostLegalizerCombiner::runOnMachineFunction(MachineFunction &MF) { auto *TPC = &getAnalysis(); const Function &F = MF.getFunction(); bool EnableOpt = - MF.getTarget().getOptLevel() != CodeGenOpt::None && !skipFunction(F); + MF.getTarget().getOptLevel() != CodeGenOptLevel::None && !skipFunction(F); const GCNSubtarget &ST = MF.getSubtarget(); const AMDGPULegalizerInfo *LI = diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPreLegalizerCombiner.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPreLegalizerCombiner.cpp index 876aa6d2a4cbf..0c7e198810da7 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUPreLegalizerCombiner.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUPreLegalizerCombiner.cpp @@ -266,7 +266,7 @@ bool AMDGPUPreLegalizerCombiner::runOnMachineFunction(MachineFunction &MF) { auto *TPC = &getAnalysis(); const Function &F = MF.getFunction(); bool EnableOpt = - MF.getTarget().getOptLevel() != CodeGenOpt::None && !skipFunction(F); + MF.getTarget().getOptLevel() != CodeGenOptLevel::None && !skipFunction(F); GISelKnownBits *KB = &getAnalysis().get(MF); // Enable CSE. diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegBankCombiner.cpp b/llvm/lib/Target/AMDGPU/AMDGPURegBankCombiner.cpp index b432d51153ad3..20e1aaa5419ad 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPURegBankCombiner.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPURegBankCombiner.cpp @@ -444,7 +444,7 @@ bool AMDGPURegBankCombiner::runOnMachineFunction(MachineFunction &MF) { auto *TPC = &getAnalysis(); const Function &F = MF.getFunction(); bool EnableOpt = - MF.getTarget().getOptLevel() != CodeGenOpt::None && !skipFunction(F); + MF.getTarget().getOptLevel() != CodeGenOptLevel::None && !skipFunction(F); const GCNSubtarget &ST = MF.getSubtarget(); GISelKnownBits *KB = &getAnalysis().get(MF); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp index 074280b59e82f..481fbaf1543a4 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -546,7 +546,7 @@ AMDGPUTargetMachine::AMDGPUTargetMachine(const Target &T, const Triple &TT, TargetOptions Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OptLevel) + CodeGenOptLevel OptLevel) : LLVMTargetMachine(T, computeDataLayout(TT), TT, getGPUOrDefault(TT, CPU), FS, Options, getEffectiveRelocModel(RM), getEffectiveCodeModel(CM, CodeModel::Small), OptLevel), @@ -827,7 +827,7 @@ GCNTargetMachine::GCNTargetMachine(const Target &T, const Triple &TT, TargetOptions Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : AMDGPUTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) {} const TargetSubtargetInfo * @@ -896,7 +896,7 @@ class GCNPassConfig final : public AMDGPUPassConfig { DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI)); DAG->addMutation(ST.createFillMFMAShadowMutation(DAG->TII)); DAG->addMutation(createIGroupLPDAGMutation()); - if (isPassEnabled(EnableVOPD, CodeGenOpt::Less)) + if (isPassEnabled(EnableVOPD, CodeGenOptLevel::Less)) DAG->addMutation(createVOPDPairingMutation()); return DAG; } @@ -943,7 +943,7 @@ AMDGPUPassConfig::AMDGPUPassConfig(LLVMTargetMachine &TM, PassManagerBase &PM) } void AMDGPUPassConfig::addEarlyCSEOrGVNPass() { - if (getOptLevel() == CodeGenOpt::Aggressive) + if (getOptLevel() == CodeGenOptLevel::Aggressive) addPass(createGVNPass()); else addPass(createEarlyCSEPass()); @@ -998,22 +998,22 @@ void AMDGPUPassConfig::addIRPasses() { // AMDGPUAttributor infers lack of llvm.amdgcn.lds.kernel.id calls, so run // after their introduction - if (TM.getOptLevel() > CodeGenOpt::None) + if (TM.getOptLevel() > CodeGenOptLevel::None) addPass(createAMDGPUAttributorPass()); - if (TM.getOptLevel() > CodeGenOpt::None) + if (TM.getOptLevel() > CodeGenOptLevel::None) addPass(createInferAddressSpacesPass()); // Run atomic optimizer before Atomic Expand if ((TM.getTargetTriple().getArch() == Triple::amdgcn) && - (TM.getOptLevel() >= CodeGenOpt::Less) && + (TM.getOptLevel() >= CodeGenOptLevel::Less) && (AMDGPUAtomicOptimizerStrategy != ScanOptions::None)) { addPass(createAMDGPUAtomicOptimizerPass(AMDGPUAtomicOptimizerStrategy)); } addPass(createAtomicExpandPass()); - if (TM.getOptLevel() > CodeGenOpt::None) { + if (TM.getOptLevel() > CodeGenOptLevel::None) { addPass(createAMDGPUPromoteAlloca()); if (isPassEnabled(EnableScalarIRPasses)) @@ -1035,7 +1035,7 @@ void AMDGPUPassConfig::addIRPasses() { // Try to hoist loop invariant parts of divisions AMDGPUCodeGenPrepare may // have expanded. - if (TM.getOptLevel() > CodeGenOpt::Less) + if (TM.getOptLevel() > CodeGenOptLevel::Less) addPass(createLICMPass()); } @@ -1081,7 +1081,7 @@ void AMDGPUPassConfig::addCodeGenPrepare() { } bool AMDGPUPassConfig::addPreISel() { - if (TM->getOptLevel() > CodeGenOpt::None) + if (TM->getOptLevel() > CodeGenOptLevel::None) addPass(createFlattenCFGPass()); return false; } @@ -1132,10 +1132,10 @@ ScheduleDAGInstrs *GCNPassConfig::createMachineScheduler( bool GCNPassConfig::addPreISel() { AMDGPUPassConfig::addPreISel(); - if (TM->getOptLevel() > CodeGenOpt::None) + if (TM->getOptLevel() > CodeGenOptLevel::None) addPass(createAMDGPULateCodeGenPreparePass()); - if (TM->getOptLevel() > CodeGenOpt::None) + if (TM->getOptLevel() > CodeGenOptLevel::None) addPass(createSinkingPass()); // Merge divergent exit nodes. StructurizeCFG won't recognize the multi-exit @@ -1158,7 +1158,7 @@ bool GCNPassConfig::addPreISel() { } addPass(createLCSSAPass()); - if (TM->getOptLevel() > CodeGenOpt::Less) + if (TM->getOptLevel() > CodeGenOptLevel::Less) addPass(&AMDGPUPerfHintAnalysisID); return false; @@ -1209,7 +1209,7 @@ bool GCNPassConfig::addIRTranslator() { } void GCNPassConfig::addPreLegalizeMachineIR() { - bool IsOptNone = getOptLevel() == CodeGenOpt::None; + bool IsOptNone = getOptLevel() == CodeGenOptLevel::None; addPass(createAMDGPUPreLegalizeCombiner(IsOptNone)); addPass(new Localizer()); } @@ -1220,7 +1220,7 @@ bool GCNPassConfig::addLegalizeMachineIR() { } void GCNPassConfig::addPreRegBankSelect() { - bool IsOptNone = getOptLevel() == CodeGenOpt::None; + bool IsOptNone = getOptLevel() == CodeGenOptLevel::None; addPass(createAMDGPUPostLegalizeCombiner(IsOptNone)); } @@ -1230,7 +1230,7 @@ bool GCNPassConfig::addRegBankSelect() { } void GCNPassConfig::addPreGlobalInstructionSelect() { - bool IsOptNone = getOptLevel() == CodeGenOpt::None; + bool IsOptNone = getOptLevel() == CodeGenOptLevel::None; addPass(createAMDGPURegBankCombiner(IsOptNone)); } @@ -1277,7 +1277,7 @@ void GCNPassConfig::addOptimizedRegAlloc() { // This is not an essential optimization and it has a noticeable impact on // compilation time, so we only enable it from O2. - if (TM->getOptLevel() > CodeGenOpt::Less) + if (TM->getOptLevel() > CodeGenOptLevel::Less) insertPass(&MachineSchedulerID, &SIFormMemoryClausesID); // FIXME: when an instruction has a Killed operand, and the instruction is @@ -1385,32 +1385,32 @@ bool GCNPassConfig::addRegAssignAndRewriteOptimized() { void GCNPassConfig::addPostRegAlloc() { addPass(&SIFixVGPRCopiesID); - if (getOptLevel() > CodeGenOpt::None) + if (getOptLevel() > CodeGenOptLevel::None) addPass(&SIOptimizeExecMaskingID); TargetPassConfig::addPostRegAlloc(); } void GCNPassConfig::addPreSched2() { - if (TM->getOptLevel() > CodeGenOpt::None) + if (TM->getOptLevel() > CodeGenOptLevel::None) addPass(createSIShrinkInstructionsPass()); addPass(&SIPostRABundlerID); } void GCNPassConfig::addPreEmitPass() { - if (isPassEnabled(EnableVOPD, CodeGenOpt::Less)) + if (isPassEnabled(EnableVOPD, CodeGenOptLevel::Less)) addPass(&GCNCreateVOPDID); addPass(createSIMemoryLegalizerPass()); addPass(createSIInsertWaitcntsPass()); addPass(createSIModeRegisterPass()); - if (getOptLevel() > CodeGenOpt::None) + if (getOptLevel() > CodeGenOptLevel::None) addPass(&SIInsertHardClausesID); addPass(&SILateBranchLoweringPassID); - if (isPassEnabled(EnableSetWavePriority, CodeGenOpt::Less)) + if (isPassEnabled(EnableSetWavePriority, CodeGenOptLevel::Less)) addPass(createAMDGPUSetWavePriorityPass()); - if (getOptLevel() > CodeGenOpt::None) + if (getOptLevel() > CodeGenOptLevel::None) addPass(&SIPreEmitPeepholeID); // The hazard recognizer that runs as part of the post-ra scheduler does not // guarantee to be able handle all hazards correctly. This is because if there @@ -1422,7 +1422,7 @@ void GCNPassConfig::addPreEmitPass() { // cases. addPass(&PostRAHazardRecognizerID); - if (isPassEnabled(EnableInsertDelayAlu, CodeGenOpt::Less)) + if (isPassEnabled(EnableInsertDelayAlu, CodeGenOptLevel::Less)) addPass(&AMDGPUInsertDelayAluID); addPass(&BranchRelaxationPassID); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h index 2426be405a659..9051a61e65570 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h @@ -41,7 +41,7 @@ class AMDGPUTargetMachine : public LLVMTargetMachine { AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL); + std::optional CM, CodeGenOptLevel OL); ~AMDGPUTargetMachine() override; const TargetSubtargetInfo *getSubtargetImpl() const; @@ -79,7 +79,7 @@ class GCNTargetMachine final : public AMDGPUTargetMachine { GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); TargetPassConfig *createPassConfig(PassManagerBase &PM) override; @@ -137,7 +137,7 @@ class AMDGPUPassConfig : public TargetPassConfig { /// be used given that a pass shall work at an optimization \p Level /// minimum. bool isPassEnabled(const cl::opt &Opt, - CodeGenOpt::Level Level = CodeGenOpt::Default) const { + CodeGenOptLevel Level = CodeGenOptLevel::Default) const { if (Opt.getNumOccurrences()) return Opt; if (TM->getOptLevel() < Level) diff --git a/llvm/lib/Target/AMDGPU/R600.h b/llvm/lib/Target/AMDGPU/R600.h index 2b0a887c61fa3..6c40c2813e204 100644 --- a/llvm/lib/Target/AMDGPU/R600.h +++ b/llvm/lib/Target/AMDGPU/R600.h @@ -27,7 +27,7 @@ FunctionPass *createR600ClauseMergePass(); FunctionPass *createR600Packetizer(); FunctionPass *createR600ControlFlowFinalizer(); FunctionPass *createR600MachineCFGStructurizerPass(); -FunctionPass *createR600ISelDag(TargetMachine &TM, CodeGenOpt::Level OptLevel); +FunctionPass *createR600ISelDag(TargetMachine &TM, CodeGenOptLevel OptLevel); ModulePass *createR600OpenCLImageTypeLoweringPass(); void initializeR600ClauseMergePassPass(PassRegistry &); diff --git a/llvm/lib/Target/AMDGPU/R600ISelDAGToDAG.cpp b/llvm/lib/Target/AMDGPU/R600ISelDAGToDAG.cpp index 20c2ff8a4fd72..293db13f34f6c 100644 --- a/llvm/lib/Target/AMDGPU/R600ISelDAGToDAG.cpp +++ b/llvm/lib/Target/AMDGPU/R600ISelDAGToDAG.cpp @@ -30,7 +30,7 @@ class R600DAGToDAGISel : public AMDGPUDAGToDAGISel { public: R600DAGToDAGISel() = delete; - explicit R600DAGToDAGISel(TargetMachine &TM, CodeGenOpt::Level OptLevel) + explicit R600DAGToDAGISel(TargetMachine &TM, CodeGenOptLevel OptLevel) : AMDGPUDAGToDAGISel(TM, OptLevel) {} void Select(SDNode *N) override; @@ -183,6 +183,6 @@ bool R600DAGToDAGISel::SelectADDRVTX_READ(SDValue Addr, SDValue &Base, /// This pass converts a legalized DAG into a R600-specific // DAG, ready for instruction scheduling. FunctionPass *llvm::createR600ISelDag(TargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new R600DAGToDAGISel(TM, OptLevel); } diff --git a/llvm/lib/Target/AMDGPU/R600TargetMachine.cpp b/llvm/lib/Target/AMDGPU/R600TargetMachine.cpp index 36840587d219d..6cd4fd42444dd 100644 --- a/llvm/lib/Target/AMDGPU/R600TargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/R600TargetMachine.cpp @@ -53,7 +53,7 @@ R600TargetMachine::R600TargetMachine(const Target &T, const Triple &TT, TargetOptions Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : AMDGPUTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) { setRequiresStructuredCFG(true); diff --git a/llvm/lib/Target/AMDGPU/R600TargetMachine.h b/llvm/lib/Target/AMDGPU/R600TargetMachine.h index f0e3cd3526425..3fe54c778fe15 100644 --- a/llvm/lib/Target/AMDGPU/R600TargetMachine.h +++ b/llvm/lib/Target/AMDGPU/R600TargetMachine.h @@ -33,7 +33,7 @@ class R600TargetMachine final : public AMDGPUTargetMachine { R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); TargetPassConfig *createPassConfig(PassManagerBase &PM) override; diff --git a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp index db323465c153f..32da233fe4d88 100644 --- a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp +++ b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp @@ -765,7 +765,7 @@ bool SIFixSGPRCopies::runOnMachineFunction(MachineFunction &MF) { for (auto MI : PHINodes) { processPHINode(*MI); } - if (MF.getTarget().getOptLevel() > CodeGenOpt::None && EnableM0Merge) + if (MF.getTarget().getOptLevel() > CodeGenOptLevel::None && EnableM0Merge) hoistAndMergeSGPRInits(AMDGPU::M0, *MRI, TRI, *MDT, TII); SiblingPenalty.clear(); diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp index 998904bf08820..3eba40d7e57d3 100644 --- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -2346,7 +2346,7 @@ static void reservePrivateMemoryRegs(const TargetMachine &TM, // Everything live out of a block is spilled with fast regalloc, so it's // almost certain that spilling will be required. - if (TM.getOptLevel() == CodeGenOpt::None) + if (TM.getOptLevel() == CodeGenOptLevel::None) HasStackObjects = true; // For now assume stack access is needed in any callee functions, so we need @@ -8498,7 +8498,7 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op, return SDValue(DAG.getMachineNode(Opc, DL, Op->getVTList(), Ops), 0); } case Intrinsic::amdgcn_s_barrier: { - if (getTargetMachine().getOptLevel() > CodeGenOpt::None) { + if (getTargetMachine().getOptLevel() > CodeGenOptLevel::None) { const GCNSubtarget &ST = MF.getSubtarget(); unsigned WGSize = ST.getFlatWorkGroupSizes(MF.getFunction()).second; if (WGSize <= ST.getWavefrontSize()) @@ -12994,7 +12994,7 @@ SDValue SITargetLowering::performClampCombine(SDNode *N, SDValue SITargetLowering::PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const { - if (getTargetMachine().getOptLevel() == CodeGenOpt::None) + if (getTargetMachine().getOptLevel() == CodeGenOptLevel::None) return SDValue(); switch (N->getOpcode()) { case ISD::ADD: diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp index 122060e10eccc..7358ad9bbc992 100644 --- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp +++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp @@ -1824,7 +1824,7 @@ bool SIInsertWaitcnts::runOnMachineFunction(MachineFunction &MF) { ForceEmitWaitcnt[T] = false; OptNone = MF.getFunction().hasOptNone() || - MF.getTarget().getOptLevel() == CodeGenOpt::None; + MF.getTarget().getOptLevel() == CodeGenOptLevel::None; HardwareLimits Limits = {}; Limits.VmcntMax = AMDGPU::getVmcntBitMask(IV); diff --git a/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp b/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp index a173adb6c58b5..f178324dbbe24 100644 --- a/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp +++ b/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp @@ -848,8 +848,8 @@ bool SILowerControlFlow::runOnMachineFunction(MachineFunction &MF) { const GCNSubtarget &ST = MF.getSubtarget(); TII = ST.getInstrInfo(); TRI = &TII->getRegisterInfo(); - EnableOptimizeEndCf = - RemoveRedundantEndcf && MF.getTarget().getOptLevel() > CodeGenOpt::None; + EnableOptimizeEndCf = RemoveRedundantEndcf && + MF.getTarget().getOptLevel() > CodeGenOptLevel::None; // This doesn't actually need LiveIntervals, but we can preserve them. LIS = getAnalysisIfAvailable(); diff --git a/llvm/lib/Target/ARC/ARC.h b/llvm/lib/Target/ARC/ARC.h index d8ccc47b89afd..b81016d0cee40 100644 --- a/llvm/lib/Target/ARC/ARC.h +++ b/llvm/lib/Target/ARC/ARC.h @@ -23,8 +23,7 @@ class ARCTargetMachine; class FunctionPass; class PassRegistry; -FunctionPass *createARCISelDag(ARCTargetMachine &TM, - CodeGenOpt::Level OptLevel); +FunctionPass *createARCISelDag(ARCTargetMachine &TM, CodeGenOptLevel OptLevel); FunctionPass *createARCExpandPseudosPass(); FunctionPass *createARCOptAddrMode(); FunctionPass *createARCBranchFinalizePass(); diff --git a/llvm/lib/Target/ARC/ARCISelDAGToDAG.cpp b/llvm/lib/Target/ARC/ARCISelDAGToDAG.cpp index 2a66cf8fcd225..28e35f8f2a548 100644 --- a/llvm/lib/Target/ARC/ARCISelDAGToDAG.cpp +++ b/llvm/lib/Target/ARC/ARCISelDAGToDAG.cpp @@ -45,7 +45,7 @@ class ARCDAGToDAGISel : public SelectionDAGISel { ARCDAGToDAGISel() = delete; - ARCDAGToDAGISel(ARCTargetMachine &TM, CodeGenOpt::Level OptLevel) + ARCDAGToDAGISel(ARCTargetMachine &TM, CodeGenOptLevel OptLevel) : SelectionDAGISel(ID, TM, OptLevel) {} void Select(SDNode *N) override; @@ -69,7 +69,7 @@ INITIALIZE_PASS(ARCDAGToDAGISel, DEBUG_TYPE, PASS_NAME, false, false) /// This pass converts a legalized DAG into a ARC-specific DAG, ready for /// instruction scheduling. FunctionPass *llvm::createARCISelDag(ARCTargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new ARCDAGToDAGISel(TM, OptLevel); } diff --git a/llvm/lib/Target/ARC/ARCTargetMachine.cpp b/llvm/lib/Target/ARC/ARCTargetMachine.cpp index 2527d6aad9cae..d4ae3255b32ab 100644 --- a/llvm/lib/Target/ARC/ARCTargetMachine.cpp +++ b/llvm/lib/Target/ARC/ARCTargetMachine.cpp @@ -32,7 +32,7 @@ ARCTargetMachine::ARCTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine(T, "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-" "f32:32:32-i64:32-f64:32-a:0:32-n32", diff --git a/llvm/lib/Target/ARC/ARCTargetMachine.h b/llvm/lib/Target/ARC/ARCTargetMachine.h index 26d9111502d4b..0fc4243ab44a7 100644 --- a/llvm/lib/Target/ARC/ARCTargetMachine.h +++ b/llvm/lib/Target/ARC/ARCTargetMachine.h @@ -29,7 +29,7 @@ class ARCTargetMachine : public LLVMTargetMachine { ARCTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); ~ARCTargetMachine() override; diff --git a/llvm/lib/Target/ARM/ARM.h b/llvm/lib/Target/ARM/ARM.h index 2013bfd5d0939..ecfca655b6e74 100644 --- a/llvm/lib/Target/ARM/ARM.h +++ b/llvm/lib/Target/ARM/ARM.h @@ -37,7 +37,7 @@ FunctionPass *createARMLowOverheadLoopsPass(); FunctionPass *createARMBlockPlacementPass(); Pass *createARMParallelDSPPass(); FunctionPass *createARMISelDag(ARMBaseTargetMachine &TM, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); FunctionPass *createA15SDOptimizerPass(); FunctionPass *createARMLoadStoreOptimizationPass(bool PreAlloc = false); FunctionPass *createARMExpandPseudoPass(); diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp index 41dee3e2c52af..15cda9b9432d5 100644 --- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp @@ -136,13 +136,13 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) { else if (F.hasOptSize()) // For small size, but speed and debugging illusion preserved OptimizationGoal = 3; - else if (TM.getOptLevel() == CodeGenOpt::Aggressive) + else if (TM.getOptLevel() == CodeGenOptLevel::Aggressive) // Aggressively for speed, small size and debug illusion sacrificed OptimizationGoal = 2; - else if (TM.getOptLevel() > CodeGenOpt::None) + else if (TM.getOptLevel() > CodeGenOptLevel::None) // For speed, but small size and good debug illusion preserved OptimizationGoal = 1; - else // TM.getOptLevel() == CodeGenOpt::None + else // TM.getOptLevel() == CodeGenOptLevel::None // For good debugging, but speed and small size preserved OptimizationGoal = 5; diff --git a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp index a6682f0ca162c..7a3ba5870bc6d 100644 --- a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp +++ b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp @@ -343,9 +343,9 @@ LLVM_DUMP_METHOD void ARMConstantIslands::dumpBBs() { // Align blocks where the previous block does not fall through. This may add // extra NOP's but they will not be executed. It uses the PrefLoopAlignment as a -// measure of how much to align, and only runs at CodeGenOpt::Aggressive. +// measure of how much to align, and only runs at CodeGenOptLevel::Aggressive. static bool AlignBlocks(MachineFunction *MF, const ARMSubtarget *STI) { - if (MF->getTarget().getOptLevel() != CodeGenOpt::Aggressive || + if (MF->getTarget().getOptLevel() != CodeGenOptLevel::Aggressive || MF->getFunction().hasOptSize()) return false; diff --git a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp index acd2e4b052b65..984d8d3e0b08c 100644 --- a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp +++ b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp @@ -63,7 +63,7 @@ class ARMDAGToDAGISel : public SelectionDAGISel { ARMDAGToDAGISel() = delete; - explicit ARMDAGToDAGISel(ARMBaseTargetMachine &tm, CodeGenOpt::Level OptLevel) + explicit ARMDAGToDAGISel(ARMBaseTargetMachine &tm, CodeGenOptLevel OptLevel) : SelectionDAGISel(ID, tm, OptLevel) {} bool runOnMachineFunction(MachineFunction &MF) override { @@ -499,7 +499,7 @@ void ARMDAGToDAGISel::PreprocessISelDAG() { /// node. VFP / NEON fp VMLA / VMLS instructions have special RAW hazards (at /// least on current ARM implementations) which should be avoidded. bool ARMDAGToDAGISel::hasNoVMLxHazardUse(SDNode *N) const { - if (OptLevel == CodeGenOpt::None) + if (OptLevel == CodeGenOptLevel::None) return true; if (!Subtarget->hasVMLxHazards()) @@ -5894,6 +5894,6 @@ bool ARMDAGToDAGISel::SelectInlineAsmMemoryOperand( /// ARM-specific DAG, ready for instruction scheduling. /// FunctionPass *llvm::createARMISelDag(ARMBaseTargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new ARMDAGToDAGISel(TM, OptLevel); } diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index 56300bdfd494b..d9ae95d0d2b59 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -1335,7 +1335,7 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM, // On v8, we have particularly efficient implementations of atomic fences // if they can be combined with nearby atomic loads and stores. if (!Subtarget->hasAcquireRelease() || - getTargetMachine().getOptLevel() == 0) { + getTargetMachine().getOptLevel() == CodeGenOptLevel::None) { // Automatically insert fences (dmb ish) around ATOMIC_SWAP etc. InsertFencesForAtomic = true; } @@ -21316,7 +21316,7 @@ ARMTargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const { // the stack and close enough to the spill slot, this can lead to a // situation where the monitor always gets cleared and the atomic operation // can never succeed. So at -O0 lower this operation to a CAS loop. - if (getTargetMachine().getOptLevel() == CodeGenOpt::None) + if (getTargetMachine().getOptLevel() == CodeGenOptLevel::None) return AtomicExpansionKind::CmpXChg; return AtomicExpansionKind::LLSC; } @@ -21340,8 +21340,8 @@ ARMTargetLowering::shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const { HasAtomicCmpXchg = Subtarget->hasV7Ops(); else HasAtomicCmpXchg = Subtarget->hasV6Ops(); - if (getTargetMachine().getOptLevel() != 0 && HasAtomicCmpXchg && - Size <= (Subtarget->isMClass() ? 32U : 64U)) + if (getTargetMachine().getOptLevel() != CodeGenOptLevel::None && + HasAtomicCmpXchg && Size <= (Subtarget->isMClass() ? 32U : 64U)) return AtomicExpansionKind::LLSC; return AtomicExpansionKind::None; } diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.cpp b/llvm/lib/Target/ARM/ARMTargetMachine.cpp index 39d8607818f74..a80d485e750be 100644 --- a/llvm/lib/Target/ARM/ARMTargetMachine.cpp +++ b/llvm/lib/Target/ARM/ARMTargetMachine.cpp @@ -220,7 +220,7 @@ ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool isLittle) + CodeGenOptLevel OL, bool isLittle) : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options, isLittle), TT, CPU, FS, Options, getEffectiveRelocModel(TT, RM), getEffectiveCodeModel(CM, CodeModel::Small), OL), @@ -328,7 +328,7 @@ ARMLETargetMachine::ARMLETargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : ARMBaseTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, true) {} ARMBETargetMachine::ARMBETargetMachine(const Target &T, const Triple &TT, @@ -336,7 +336,7 @@ ARMBETargetMachine::ARMBETargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : ARMBaseTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, false) {} namespace { @@ -422,7 +422,7 @@ void ARMPassConfig::addIRPasses() { // Cmpxchg instructions are often used with a subsequent comparison to // determine whether it succeeded. We can exploit existing control-flow in // ldrex/strex loops to simplify this, but it needs tidying up. - if (TM->getOptLevel() != CodeGenOpt::None && EnableAtomicTidy) + if (TM->getOptLevel() != CodeGenOptLevel::None && EnableAtomicTidy) addPass(createCFGSimplificationPass( SimplifyCFGOptions().hoistCommonInsts(true).sinkCommonInsts(true), [this](const Function &F) { @@ -436,15 +436,15 @@ void ARMPassConfig::addIRPasses() { TargetPassConfig::addIRPasses(); // Run the parallel DSP pass. - if (getOptLevel() == CodeGenOpt::Aggressive) + if (getOptLevel() == CodeGenOptLevel::Aggressive) addPass(createARMParallelDSPPass()); // Match complex arithmetic patterns - if (TM->getOptLevel() >= CodeGenOpt::Default) + if (TM->getOptLevel() >= CodeGenOptLevel::Default) addPass(createComplexDeinterleavingPass(TM)); // Match interleaved memory accesses to ldN/stN intrinsics. - if (TM->getOptLevel() != CodeGenOpt::None) + if (TM->getOptLevel() != CodeGenOptLevel::None) addPass(createInterleavedAccessPass()); // Add Control Flow Guard checks. @@ -456,13 +456,13 @@ void ARMPassConfig::addIRPasses() { } void ARMPassConfig::addCodeGenPrepare() { - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(createTypePromotionLegacyPass()); TargetPassConfig::addCodeGenPrepare(); } bool ARMPassConfig::addPreISel() { - if ((TM->getOptLevel() != CodeGenOpt::None && + if ((TM->getOptLevel() != CodeGenOptLevel::None && EnableGlobalMerge == cl::BOU_UNSET) || EnableGlobalMerge == cl::BOU_TRUE) { // FIXME: This is using the thumb1 only constant value for @@ -470,8 +470,9 @@ bool ARMPassConfig::addPreISel() { // to look into using the old value for non-thumb1 code of // 4095 based on the TargetMachine, but this starts to become // tricky when doing code gen per function. - bool OnlyOptimizeForSize = (TM->getOptLevel() < CodeGenOpt::Aggressive) && - (EnableGlobalMerge == cl::BOU_UNSET); + bool OnlyOptimizeForSize = + (TM->getOptLevel() < CodeGenOptLevel::Aggressive) && + (EnableGlobalMerge == cl::BOU_UNSET); // Merging of extern globals is enabled by default on non-Mach-O as we // expect it to be generally either beneficial or harmless. On Mach-O it // is disabled as we emit the .subsections_via_symbols directive which @@ -481,7 +482,7 @@ bool ARMPassConfig::addPreISel() { MergeExternalByDefault)); } - if (TM->getOptLevel() != CodeGenOpt::None) { + if (TM->getOptLevel() != CodeGenOptLevel::None) { addPass(createHardwareLoopsLegacyPass()); addPass(createMVETailPredicationPass()); // FIXME: IR passes can delete address-taken basic blocks, deleting @@ -523,8 +524,8 @@ bool ARMPassConfig::addGlobalInstructionSelect() { } void ARMPassConfig::addPreRegAlloc() { - if (getOptLevel() != CodeGenOpt::None) { - if (getOptLevel() == CodeGenOpt::Aggressive) + if (getOptLevel() != CodeGenOptLevel::None) { + if (getOptLevel() == CodeGenOptLevel::Aggressive) addPass(&MachinePipelinerID); addPass(createMVETPAndVPTOptimisationsPass()); @@ -540,7 +541,7 @@ void ARMPassConfig::addPreRegAlloc() { } void ARMPassConfig::addPreSched2() { - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { if (EnableARMLoadStoreOpt) addPass(createARMLoadStoreOptimizationPass()); @@ -552,7 +553,7 @@ void ARMPassConfig::addPreSched2() { // proper scheduling. addPass(createARMExpandPseudoPass()); - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { // When optimising for size, always run the Thumb2SizeReduction pass before // IfConversion. Otherwise, check whether IT blocks are restricted // (e.g. in v8, IfConversion depends on Thumb instruction widths) @@ -569,7 +570,7 @@ void ARMPassConfig::addPreSched2() { // Add both scheduling passes to give the subtarget an opportunity to pick // between them. - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { addPass(&PostMachineSchedulerID); addPass(&PostRASchedulerID); } @@ -588,7 +589,7 @@ void ARMPassConfig::addPreEmitPass() { })); // Don't optimize barriers or block placement at -O0. - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { addPass(createARMBlockPlacementPass()); addPass(createARMOptimizeBarriersPass()); } diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.h b/llvm/lib/Target/ARM/ARMTargetMachine.h index fb04433ec5224..1754382692baa 100644 --- a/llvm/lib/Target/ARM/ARMTargetMachine.h +++ b/llvm/lib/Target/ARM/ARMTargetMachine.h @@ -42,7 +42,7 @@ class ARMBaseTargetMachine : public LLVMTargetMachine { ARMBaseTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool isLittle); ~ARMBaseTargetMachine() override; @@ -92,7 +92,7 @@ class ARMLETargetMachine : public ARMBaseTargetMachine { ARMLETargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); }; @@ -103,7 +103,7 @@ class ARMBETargetMachine : public ARMBaseTargetMachine { ARMBETargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); }; diff --git a/llvm/lib/Target/AVR/AVR.h b/llvm/lib/Target/AVR/AVR.h index 020c3d4ec6c74..4b1336ecd6618 100644 --- a/llvm/lib/Target/AVR/AVR.h +++ b/llvm/lib/Target/AVR/AVR.h @@ -26,8 +26,7 @@ class FunctionPass; class PassRegistry; Pass *createAVRShiftExpandPass(); -FunctionPass *createAVRISelDag(AVRTargetMachine &TM, - CodeGenOpt::Level OptLevel); +FunctionPass *createAVRISelDag(AVRTargetMachine &TM, CodeGenOptLevel OptLevel); FunctionPass *createAVRExpandPseudoPass(); FunctionPass *createAVRFrameAnalyzerPass(); FunctionPass *createAVRBranchSelectionPass(); diff --git a/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp b/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp index 214799aa31a9c..196122e45ab8d 100644 --- a/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp +++ b/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp @@ -33,7 +33,7 @@ class AVRDAGToDAGISel : public SelectionDAGISel { AVRDAGToDAGISel() = delete; - AVRDAGToDAGISel(AVRTargetMachine &TM, CodeGenOpt::Level OptLevel) + AVRDAGToDAGISel(AVRTargetMachine &TM, CodeGenOptLevel OptLevel) : SelectionDAGISel(ID, TM, OptLevel), Subtarget(nullptr) {} bool runOnMachineFunction(MachineFunction &MF) override; @@ -585,6 +585,6 @@ bool AVRDAGToDAGISel::trySelect(SDNode *N) { } FunctionPass *llvm::createAVRISelDag(AVRTargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new AVRDAGToDAGISel(TM, OptLevel); } diff --git a/llvm/lib/Target/AVR/AVRTargetMachine.cpp b/llvm/lib/Target/AVR/AVRTargetMachine.cpp index e0c0514f62c4c..e0776a6cab432 100644 --- a/llvm/lib/Target/AVR/AVRTargetMachine.cpp +++ b/llvm/lib/Target/AVR/AVRTargetMachine.cpp @@ -48,7 +48,7 @@ AVRTargetMachine::AVRTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine(T, AVRDataLayout, TT, getCPU(CPU), FS, Options, getEffectiveRelocModel(RM), getEffectiveCodeModel(CM, CodeModel::Small), OL), diff --git a/llvm/lib/Target/AVR/AVRTargetMachine.h b/llvm/lib/Target/AVR/AVRTargetMachine.h index 0fee27dc52f3f..c19df2bc301ea 100644 --- a/llvm/lib/Target/AVR/AVRTargetMachine.h +++ b/llvm/lib/Target/AVR/AVRTargetMachine.h @@ -32,7 +32,7 @@ class AVRTargetMachine : public LLVMTargetMachine { AVRTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); const AVRSubtarget *getSubtargetImpl() const; diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.cpp b/llvm/lib/Target/BPF/BPFTargetMachine.cpp index 3926885c05a39..983a4ff6aa5c7 100644 --- a/llvm/lib/Target/BPF/BPFTargetMachine.cpp +++ b/llvm/lib/Target/BPF/BPFTargetMachine.cpp @@ -62,7 +62,7 @@ BPFTargetMachine::BPFTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, getEffectiveRelocModel(RM), getEffectiveCodeModel(CM, CodeModel::Small), OL), @@ -159,7 +159,7 @@ void BPFPassConfig::addMachineSSAOptimization() { void BPFPassConfig::addPreEmitPass() { addPass(createBPFMIPreEmitCheckingPass()); - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) if (!DisableMIPeephole) addPass(createBPFMIPreEmitPeepholePass()); } diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.h b/llvm/lib/Target/BPF/BPFTargetMachine.h index 1f22fccbfe2d5..4e6adc722e76a 100644 --- a/llvm/lib/Target/BPF/BPFTargetMachine.h +++ b/llvm/lib/Target/BPF/BPFTargetMachine.h @@ -26,7 +26,7 @@ class BPFTargetMachine : public LLVMTargetMachine { BPFTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); const BPFSubtarget *getSubtargetImpl() const { return &Subtarget; } diff --git a/llvm/lib/Target/CSKY/CSKY.h b/llvm/lib/Target/CSKY/CSKY.h index 871a7d7a2a07e..7ca630c9abaaf 100644 --- a/llvm/lib/Target/CSKY/CSKY.h +++ b/llvm/lib/Target/CSKY/CSKY.h @@ -23,7 +23,7 @@ class FunctionPass; class PassRegistry; FunctionPass *createCSKYISelDag(CSKYTargetMachine &TM, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); FunctionPass *createCSKYConstantIslandPass(); void initializeCSKYConstantIslandsPass(PassRegistry &); diff --git a/llvm/lib/Target/CSKY/CSKYISelDAGToDAG.cpp b/llvm/lib/Target/CSKY/CSKYISelDAGToDAG.cpp index 1a3c9f14c1d5a..c0c23a45d1551 100644 --- a/llvm/lib/Target/CSKY/CSKYISelDAGToDAG.cpp +++ b/llvm/lib/Target/CSKY/CSKYISelDAGToDAG.cpp @@ -30,7 +30,7 @@ class CSKYDAGToDAGISel : public SelectionDAGISel { public: static char ID; - explicit CSKYDAGToDAGISel(CSKYTargetMachine &TM, CodeGenOpt::Level OptLevel) + explicit CSKYDAGToDAGISel(CSKYTargetMachine &TM, CodeGenOptLevel OptLevel) : SelectionDAGISel(ID, TM, OptLevel) {} bool runOnMachineFunction(MachineFunction &MF) override { @@ -400,6 +400,6 @@ bool CSKYDAGToDAGISel::SelectInlineAsmMemoryOperand( } FunctionPass *llvm::createCSKYISelDag(CSKYTargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new CSKYDAGToDAGISel(TM, OptLevel); } diff --git a/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp b/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp index c5a57f32e29a0..8c268dc316141 100644 --- a/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp +++ b/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp @@ -53,7 +53,7 @@ CSKYTargetMachine::CSKYTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, RM.value_or(Reloc::Static), getEffectiveCodeModel(CM, CodeModel::Small), OL), diff --git a/llvm/lib/Target/CSKY/CSKYTargetMachine.h b/llvm/lib/Target/CSKY/CSKYTargetMachine.h index 13d4212c79aa6..e47b514ae9ddc 100644 --- a/llvm/lib/Target/CSKY/CSKYTargetMachine.h +++ b/llvm/lib/Target/CSKY/CSKYTargetMachine.h @@ -28,7 +28,7 @@ class CSKYTargetMachine : public LLVMTargetMachine { CSKYTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); TargetPassConfig *createPassConfig(PassManagerBase &PM) override; diff --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp index 1111bb86e1c14..d5cb488f2fdef 100644 --- a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp +++ b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp @@ -87,7 +87,7 @@ DirectXTargetMachine::DirectXTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine(T, "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-" "f32:32-f64:64-n8:16:32:64", @@ -129,11 +129,11 @@ bool DirectXTargetMachine::addPassesToEmitFile( PassConfig->addCodeGenPrepare(); switch (FileType) { - case CGFT_AssemblyFile: + case CodeGenFileType::AssemblyFile: PM.add(createDXILPrettyPrinterPass(Out)); PM.add(createPrintModulePass(Out, "", true)); break; - case CGFT_ObjectFile: + case CodeGenFileType::ObjectFile: if (TargetPassConfig::willCompleteCodeGenPipeline()) { PM.add(createDXILEmbedderPass()); // We embed the other DXContainer globals after embedding DXIL so that the @@ -149,7 +149,7 @@ bool DirectXTargetMachine::addPassesToEmitFile( } else PM.add(createDXILWriterPass(Out)); break; - case CGFT_Null: + case CodeGenFileType::Null: break; } return false; diff --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.h b/llvm/lib/Target/DirectX/DirectXTargetMachine.h index a6a1b3ef045b1..d04c375b2736d 100644 --- a/llvm/lib/Target/DirectX/DirectXTargetMachine.h +++ b/llvm/lib/Target/DirectX/DirectXTargetMachine.h @@ -25,7 +25,7 @@ class DirectXTargetMachine : public LLVMTargetMachine { DirectXTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); ~DirectXTargetMachine() override; diff --git a/llvm/lib/Target/Hexagon/HexagonCopyToCombine.cpp b/llvm/lib/Target/Hexagon/HexagonCopyToCombine.cpp index 033e6737f8bb8..310993662b672 100644 --- a/llvm/lib/Target/Hexagon/HexagonCopyToCombine.cpp +++ b/llvm/lib/Target/Hexagon/HexagonCopyToCombine.cpp @@ -467,7 +467,7 @@ bool HexagonCopyToCombine::runOnMachineFunction(MachineFunction &MF) { // Combine aggressively (for code size) ShouldCombineAggressively = - MF.getTarget().getOptLevel() <= CodeGenOpt::Default; + MF.getTarget().getOptLevel() <= CodeGenOptLevel::Default; // Disable CONST64 for tiny core since it takes a LD resource. if (!OptForSize && ST->isTinyCore()) diff --git a/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp b/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp index 231ac0825ee1d..812e5f7ad9303 100644 --- a/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp +++ b/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp @@ -381,7 +381,7 @@ static bool isRestoreCall(unsigned Opc) { static inline bool isOptNone(const MachineFunction &MF) { return MF.getFunction().hasOptNone() || - MF.getTarget().getOptLevel() == CodeGenOpt::None; + MF.getTarget().getOptLevel() == CodeGenOptLevel::None; } static inline bool isOptSize(const MachineFunction &MF) { @@ -1156,7 +1156,7 @@ bool HexagonFrameLowering::hasFP(const MachineFunction &MF) const { // gdb can't break at the start of the function without it. Will remove if // this turns out to be a gdb bug. // - if (MF.getTarget().getOptLevel() == CodeGenOpt::None) + if (MF.getTarget().getOptLevel() == CodeGenOptLevel::None) return true; // By default we want to use SP (since it's always there). FP requires @@ -1269,7 +1269,7 @@ HexagonFrameLowering::getFrameIndexReference(const MachineFunction &MF, int FI, int Offset = MFI.getObjectOffset(FI); bool HasAlloca = MFI.hasVarSizedObjects(); bool HasExtraAlign = HRI.hasStackRealignment(MF); - bool NoOpt = MF.getTarget().getOptLevel() == CodeGenOpt::None; + bool NoOpt = MF.getTarget().getOptLevel() == CodeGenOptLevel::None; auto &HMFI = *MF.getInfo(); unsigned FrameSize = MFI.getStackSize(); @@ -2584,7 +2584,7 @@ bool HexagonFrameLowering::shouldInlineCSR(const MachineFunction &MF, if (!hasFP(MF)) return true; if (!isOptSize(MF) && !isMinSize(MF)) - if (MF.getTarget().getOptLevel() > CodeGenOpt::Default) + if (MF.getTarget().getOptLevel() > CodeGenOptLevel::Default) return true; // Check if CSI only has double registers, and if the registers form diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp index 4c340a42748e1..f930015026a5c 100644 --- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp +++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp @@ -59,7 +59,7 @@ namespace llvm { /// createHexagonISelDag - This pass converts a legalized DAG into a /// Hexagon-specific DAG, ready for instruction scheduling. FunctionPass *createHexagonISelDag(HexagonTargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new HexagonDAGToDAGISel(TM, OptLevel); } } diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.h b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.h index bc650571d2a51..4ccbbf9fb9c10 100644 --- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.h +++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.h @@ -36,7 +36,7 @@ class HexagonDAGToDAGISel : public SelectionDAGISel { HexagonDAGToDAGISel() = delete; explicit HexagonDAGToDAGISel(HexagonTargetMachine &tm, - CodeGenOpt::Level OptLevel) + CodeGenOptLevel OptLevel) : SelectionDAGISel(ID, tm, OptLevel), HST(nullptr), HII(nullptr), HRI(nullptr) {} diff --git a/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp b/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp index 8917be1b56261..1c9c258df9475 100644 --- a/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp +++ b/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp @@ -429,7 +429,7 @@ void HexagonSubtarget::BankConflictMutation::apply(ScheduleDAGInstrs *DAG) { /// Enable use of alias analysis during code generation (during MI /// scheduling, DAGCombine, etc.). bool HexagonSubtarget::useAA() const { - if (OptLevel != CodeGenOpt::None) + if (OptLevel != CodeGenOptLevel::None) return true; return false; } diff --git a/llvm/lib/Target/Hexagon/HexagonSubtarget.h b/llvm/lib/Target/Hexagon/HexagonSubtarget.h index f5b4461a5d247..e56007ee21e75 100644 --- a/llvm/lib/Target/Hexagon/HexagonSubtarget.h +++ b/llvm/lib/Target/Hexagon/HexagonSubtarget.h @@ -70,7 +70,7 @@ class HexagonSubtarget : public HexagonGenSubtargetInfo { public: Hexagon::ArchEnum HexagonArchVersion; Hexagon::ArchEnum HexagonHVXVersion = Hexagon::ArchEnum::NoArch; - CodeGenOpt::Level OptLevel; + CodeGenOptLevel OptLevel; /// True if the target should use Back-Skip-Back scheduling. This is the /// default for V60. bool UseBSBScheduling; diff --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp index 9654c9be303fe..590e464e1653a 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp +++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp @@ -177,7 +177,7 @@ namespace llvm { FunctionPass *createHexagonGenPredicate(); FunctionPass *createHexagonHardwareLoops(); FunctionPass *createHexagonISelDag(HexagonTargetMachine &TM, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); FunctionPass *createHexagonLoopRescheduling(); FunctionPass *createHexagonNewValueJump(); FunctionPass *createHexagonOptAddrMode(); @@ -226,7 +226,7 @@ HexagonTargetMachine::HexagonTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) // Specify the vector alignment explicitly. For v512x1, the calculated // alignment would be 512*alignment(i1), which is 512 bytes, instead of // the required minimum of 64 bytes. @@ -237,7 +237,7 @@ HexagonTargetMachine::HexagonTargetMachine(const Target &T, const Triple &TT, "v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048", TT, CPU, FS, Options, getEffectiveRelocModel(RM), getEffectiveCodeModel(CM, CodeModel::Small), - (HexagonNoOpt ? CodeGenOpt::None : OL)), + (HexagonNoOpt ? CodeGenOptLevel::None : OL)), TLOF(std::make_unique()) { initializeHexagonExpandCondsetsPass(*PassRegistry::getPassRegistry()); initAsmInfo(); @@ -330,7 +330,7 @@ TargetPassConfig *HexagonTargetMachine::createPassConfig(PassManagerBase &PM) { void HexagonPassConfig::addIRPasses() { TargetPassConfig::addIRPasses(); - bool NoOpt = (getOptLevel() == CodeGenOpt::None); + bool NoOpt = (getOptLevel() == CodeGenOptLevel::None); if (!NoOpt) { if (EnableInstSimplify) @@ -363,7 +363,7 @@ void HexagonPassConfig::addIRPasses() { bool HexagonPassConfig::addInstSelector() { HexagonTargetMachine &TM = getHexagonTargetMachine(); - bool NoOpt = (getOptLevel() == CodeGenOpt::None); + bool NoOpt = (getOptLevel() == CodeGenOptLevel::None); if (!NoOpt) addPass(createHexagonOptimizeSZextends()); @@ -401,7 +401,7 @@ bool HexagonPassConfig::addInstSelector() { } void HexagonPassConfig::addPreRegAlloc() { - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { if (EnableCExtOpt) addPass(createHexagonConstExtenders()); if (EnableExpandCondsets) @@ -411,12 +411,12 @@ void HexagonPassConfig::addPreRegAlloc() { if (!DisableHardwareLoops) addPass(createHexagonHardwareLoops()); } - if (TM->getOptLevel() >= CodeGenOpt::Default) + if (TM->getOptLevel() >= CodeGenOptLevel::Default) addPass(&MachinePipelinerID); } void HexagonPassConfig::addPostRegAlloc() { - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { if (EnableRDFOpt) addPass(createHexagonRDFOpt()); if (!DisableHexagonCFGOpt) @@ -428,13 +428,13 @@ void HexagonPassConfig::addPostRegAlloc() { void HexagonPassConfig::addPreSched2() { addPass(createHexagonCopyToCombine()); - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(&IfConverterID); addPass(createHexagonSplitConst32AndConst64()); } void HexagonPassConfig::addPreEmitPass() { - bool NoOpt = (getOptLevel() == CodeGenOpt::None); + bool NoOpt = (getOptLevel() == CodeGenOptLevel::None); if (!NoOpt) addPass(createHexagonNewValueJump()); diff --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.h b/llvm/lib/Target/Hexagon/HexagonTargetMachine.h index 208b47d765c73..4ffd0fd89de60 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.h +++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.h @@ -31,7 +31,7 @@ class HexagonTargetMachine : public LLVMTargetMachine { HexagonTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); ~HexagonTargetMachine() override; const HexagonSubtarget *getSubtargetImpl(const Function &F) const override; diff --git a/llvm/lib/Target/Lanai/LanaiSubtarget.cpp b/llvm/lib/Target/Lanai/LanaiSubtarget.cpp index 37a4843e1bc40..11cd7f53505e3 100644 --- a/llvm/lib/Target/Lanai/LanaiSubtarget.cpp +++ b/llvm/lib/Target/Lanai/LanaiSubtarget.cpp @@ -40,7 +40,7 @@ LanaiSubtarget::LanaiSubtarget(const Triple &TargetTriple, StringRef Cpu, StringRef FeatureString, const TargetMachine &TM, const TargetOptions & /*Options*/, CodeModel::Model /*CodeModel*/, - CodeGenOpt::Level /*OptLevel*/) + CodeGenOptLevel /*OptLevel*/) : LanaiGenSubtargetInfo(TargetTriple, Cpu, /*TuneCPU*/ Cpu, FeatureString), FrameLowering(initializeSubtargetDependencies(Cpu, FeatureString)), TLInfo(TM, *this) {} diff --git a/llvm/lib/Target/Lanai/LanaiSubtarget.h b/llvm/lib/Target/Lanai/LanaiSubtarget.h index 7955bfe0d8b9e..0a229063ab7b2 100644 --- a/llvm/lib/Target/Lanai/LanaiSubtarget.h +++ b/llvm/lib/Target/Lanai/LanaiSubtarget.h @@ -33,7 +33,7 @@ class LanaiSubtarget : public LanaiGenSubtargetInfo { LanaiSubtarget(const Triple &TargetTriple, StringRef Cpu, StringRef FeatureString, const TargetMachine &TM, const TargetOptions &Options, CodeModel::Model CodeModel, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); // ParseSubtargetFeatures - Parses features string setting specified // subtarget options. Definition of function is auto generated by tblgen. diff --git a/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp b/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp index 80a60955c48b3..039182b3ffe60 100644 --- a/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp +++ b/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp @@ -58,7 +58,7 @@ static Reloc::Model getEffectiveRelocModel(std::optional RM) { LanaiTargetMachine::LanaiTargetMachine( const Target &T, const Triple &TT, StringRef Cpu, StringRef FeatureString, const TargetOptions &Options, std::optional RM, - std::optional CodeModel, CodeGenOpt::Level OptLevel, + std::optional CodeModel, CodeGenOptLevel OptLevel, bool JIT) : LLVMTargetMachine(T, computeDataLayout(), TT, Cpu, FeatureString, Options, getEffectiveRelocModel(RM), diff --git a/llvm/lib/Target/Lanai/LanaiTargetMachine.h b/llvm/lib/Target/Lanai/LanaiTargetMachine.h index 85e3b3f261fe4..c5c351b36b316 100644 --- a/llvm/lib/Target/Lanai/LanaiTargetMachine.h +++ b/llvm/lib/Target/Lanai/LanaiTargetMachine.h @@ -32,7 +32,7 @@ class LanaiTargetMachine : public LLVMTargetMachine { const TargetOptions &Options, std::optional RM, std::optional CodeModel, - CodeGenOpt::Level OptLevel, bool JIT); + CodeGenOptLevel OptLevel, bool JIT); const LanaiSubtarget * getSubtargetImpl(const llvm::Function & /*Fn*/) const override { diff --git a/llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp b/llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp index 46e4a06f6bc01..c54a9b9c76c45 100644 --- a/llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp +++ b/llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp @@ -78,7 +78,7 @@ getEffectiveLoongArchCodeModel(const Triple &TT, LoongArchTargetMachine::LoongArchTargetMachine( const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, bool JIT) + std::optional CM, CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, getEffectiveRelocModel(TT, RM), getEffectiveLoongArchCodeModel(TT, CM), OL), @@ -159,7 +159,7 @@ void LoongArchPassConfig::addIRPasses() { // // Run this before LSR to remove the multiplies involved in computing the // pointer values N iterations ahead. - if (TM->getOptLevel() != CodeGenOpt::None && EnableLoopDataPrefetch) + if (TM->getOptLevel() != CodeGenOptLevel::None && EnableLoopDataPrefetch) addPass(createLoopDataPrefetchPass()); addPass(createAtomicExpandPass()); diff --git a/llvm/lib/Target/LoongArch/LoongArchTargetMachine.h b/llvm/lib/Target/LoongArch/LoongArchTargetMachine.h index 06fcec838ea45..7d39d47e86b36 100644 --- a/llvm/lib/Target/LoongArch/LoongArchTargetMachine.h +++ b/llvm/lib/Target/LoongArch/LoongArchTargetMachine.h @@ -27,8 +27,8 @@ class LoongArchTargetMachine : public LLVMTargetMachine { LoongArchTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, - CodeGenOpt::Level OL, bool JIT); + std::optional CM, CodeGenOptLevel OL, + bool JIT); ~LoongArchTargetMachine() override; TargetTransformInfo getTargetTransformInfo(const Function &F) const override; diff --git a/llvm/lib/Target/M68k/M68kISelDAGToDAG.cpp b/llvm/lib/Target/M68k/M68kISelDAGToDAG.cpp index c400c9a3fc992..e3aa9cb508479 100644 --- a/llvm/lib/Target/M68k/M68kISelDAGToDAG.cpp +++ b/llvm/lib/Target/M68k/M68kISelDAGToDAG.cpp @@ -324,7 +324,7 @@ INITIALIZE_PASS(M68kDAGToDAGISel, DEBUG_TYPE, PASS_NAME, false, false) bool M68kDAGToDAGISel::IsProfitableToFold(SDValue N, SDNode *U, SDNode *Root) const { - if (OptLevel == CodeGenOpt::None) + if (OptLevel == CodeGenOptLevel::None) return false; if (U == Root) { diff --git a/llvm/lib/Target/M68k/M68kTargetMachine.cpp b/llvm/lib/Target/M68k/M68kTargetMachine.cpp index 4e59e27bef8cf..af8cb9a83a050 100644 --- a/llvm/lib/Target/M68k/M68kTargetMachine.cpp +++ b/llvm/lib/Target/M68k/M68kTargetMachine.cpp @@ -101,7 +101,7 @@ M68kTargetMachine::M68kTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options), TT, CPU, FS, Options, getEffectiveRelocModel(TT, RM), ::getEffectiveCodeModel(CM, JIT), OL), diff --git a/llvm/lib/Target/M68k/M68kTargetMachine.h b/llvm/lib/Target/M68k/M68kTargetMachine.h index e204f639c4f1e..4ff4c4cb46b80 100644 --- a/llvm/lib/Target/M68k/M68kTargetMachine.h +++ b/llvm/lib/Target/M68k/M68kTargetMachine.h @@ -38,7 +38,7 @@ class M68kTargetMachine : public LLVMTargetMachine { M68kTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); ~M68kTargetMachine() override; diff --git a/llvm/lib/Target/MSP430/MSP430.h b/llvm/lib/Target/MSP430/MSP430.h index 75fa398adc026..60685b6704ba2 100644 --- a/llvm/lib/Target/MSP430/MSP430.h +++ b/llvm/lib/Target/MSP430/MSP430.h @@ -39,7 +39,7 @@ class MSP430TargetMachine; class PassRegistry; FunctionPass *createMSP430ISelDag(MSP430TargetMachine &TM, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); FunctionPass *createMSP430BranchSelectionPass(); diff --git a/llvm/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp b/llvm/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp index cb5d979147256..660861a5d5218 100644 --- a/llvm/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp +++ b/llvm/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp @@ -95,7 +95,7 @@ namespace { MSP430DAGToDAGISel() = delete; - MSP430DAGToDAGISel(MSP430TargetMachine &TM, CodeGenOpt::Level OptLevel) + MSP430DAGToDAGISel(MSP430TargetMachine &TM, CodeGenOptLevel OptLevel) : SelectionDAGISel(ID, TM, OptLevel) {} private: @@ -129,11 +129,10 @@ INITIALIZE_PASS(MSP430DAGToDAGISel, DEBUG_TYPE, PASS_NAME, false, false) /// MSP430-specific DAG, ready for instruction scheduling. /// FunctionPass *llvm::createMSP430ISelDag(MSP430TargetMachine &TM, - CodeGenOpt::Level OptLevel) { - return new MSP430DAGToDAGISel(TM, OptLevel); + CodeGenOptLevel OptLevel) { + return new MSP430DAGToDAGISel(TM, OptLevel); } - /// MatchWrapper - Try to match MSP430ISD::Wrapper node into an addressing mode. /// These wrap things that will resolve down into a symbol reference. If no /// match is possible, this returns true, otherwise it returns false. diff --git a/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp b/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp index 2efeeb5ee63dc..39e0658eb70dd 100644 --- a/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp +++ b/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp @@ -43,7 +43,7 @@ MSP430TargetMachine::MSP430TargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options), TT, CPU, FS, Options, getEffectiveRelocModel(RM), getEffectiveCodeModel(CM, CodeModel::Small), OL), diff --git a/llvm/lib/Target/MSP430/MSP430TargetMachine.h b/llvm/lib/Target/MSP430/MSP430TargetMachine.h index 30e1f7f4a80dd..f9af9a7e26f69 100644 --- a/llvm/lib/Target/MSP430/MSP430TargetMachine.h +++ b/llvm/lib/Target/MSP430/MSP430TargetMachine.h @@ -31,7 +31,7 @@ class MSP430TargetMachine : public LLVMTargetMachine { MSP430TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); ~MSP430TargetMachine() override; diff --git a/llvm/lib/Target/Mips/Mips16ISelDAGToDAG.cpp b/llvm/lib/Target/Mips/Mips16ISelDAGToDAG.cpp index c8c9612b75e79..0be9b94187a2e 100644 --- a/llvm/lib/Target/Mips/Mips16ISelDAGToDAG.cpp +++ b/llvm/lib/Target/Mips/Mips16ISelDAGToDAG.cpp @@ -220,6 +220,6 @@ bool Mips16DAGToDAGISel::trySelect(SDNode *Node) { } FunctionPass *llvm::createMips16ISelDag(MipsTargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new Mips16DAGToDAGISel(TM, OptLevel); } diff --git a/llvm/lib/Target/Mips/Mips16ISelDAGToDAG.h b/llvm/lib/Target/Mips/Mips16ISelDAGToDAG.h index 1ef194029f509..c6d3bde68806e 100644 --- a/llvm/lib/Target/Mips/Mips16ISelDAGToDAG.h +++ b/llvm/lib/Target/Mips/Mips16ISelDAGToDAG.h @@ -19,7 +19,7 @@ namespace llvm { class Mips16DAGToDAGISel : public MipsDAGToDAGISel { public: - explicit Mips16DAGToDAGISel(MipsTargetMachine &TM, CodeGenOpt::Level OL) + explicit Mips16DAGToDAGISel(MipsTargetMachine &TM, CodeGenOptLevel OL) : MipsDAGToDAGISel(TM, OL) {} private: @@ -48,7 +48,7 @@ class Mips16DAGToDAGISel : public MipsDAGToDAGISel { }; FunctionPass *createMips16ISelDag(MipsTargetMachine &TM, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); } #endif diff --git a/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp b/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp index 8aa5f769c903d..cb98c04ff4e50 100644 --- a/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp +++ b/llvm/lib/Target/Mips/MipsDelaySlotFiller.cpp @@ -610,7 +610,8 @@ bool MipsDelaySlotFiller::runOnMachineBasicBlock(MachineBasicBlock &MBB) { continue; // Delay slot filling is disabled at -O0, or in microMIPS32R6. - if (!DisableDelaySlotFiller && (TM->getOptLevel() != CodeGenOpt::None) && + if (!DisableDelaySlotFiller && + (TM->getOptLevel() != CodeGenOptLevel::None) && !(InMicroMipsMode && STI.hasMips32r6())) { bool Filled = false; diff --git a/llvm/lib/Target/Mips/MipsISelDAGToDAG.h b/llvm/lib/Target/Mips/MipsISelDAGToDAG.h index 9c861017ec72a..e41cb08712ca2 100644 --- a/llvm/lib/Target/Mips/MipsISelDAGToDAG.h +++ b/llvm/lib/Target/Mips/MipsISelDAGToDAG.h @@ -34,7 +34,7 @@ class MipsDAGToDAGISel : public SelectionDAGISel { MipsDAGToDAGISel() = delete; - explicit MipsDAGToDAGISel(MipsTargetMachine &TM, CodeGenOpt::Level OL) + explicit MipsDAGToDAGISel(MipsTargetMachine &TM, CodeGenOptLevel OL) : SelectionDAGISel(ID, TM, OL), Subtarget(nullptr) {} bool runOnMachineFunction(MachineFunction &MF) override; diff --git a/llvm/lib/Target/Mips/MipsPostLegalizerCombiner.cpp b/llvm/lib/Target/Mips/MipsPostLegalizerCombiner.cpp index 3d970d6ef9a47..0578655f0443a 100644 --- a/llvm/lib/Target/Mips/MipsPostLegalizerCombiner.cpp +++ b/llvm/lib/Target/Mips/MipsPostLegalizerCombiner.cpp @@ -131,7 +131,7 @@ bool MipsPostLegalizerCombiner::runOnMachineFunction(MachineFunction &MF) { auto *TPC = &getAnalysis(); const Function &F = MF.getFunction(); bool EnableOpt = - MF.getTarget().getOptLevel() != CodeGenOpt::None && !skipFunction(F); + MF.getTarget().getOptLevel() != CodeGenOptLevel::None && !skipFunction(F); const MipsSubtarget &ST = MF.getSubtarget(); const MipsLegalizerInfo *LI = diff --git a/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp b/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp index 0bb16f3111efb..8c865afd42079 100644 --- a/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp +++ b/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp @@ -1442,6 +1442,6 @@ bool MipsSEDAGToDAGISel::SelectInlineAsmMemoryOperand( } FunctionPass *llvm::createMipsSEISelDag(MipsTargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new MipsSEDAGToDAGISel(TM, OptLevel); } diff --git a/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.h b/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.h index f3b887286db82..96dc876cb753e 100644 --- a/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.h +++ b/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.h @@ -20,7 +20,7 @@ namespace llvm { class MipsSEDAGToDAGISel : public MipsDAGToDAGISel { public: - explicit MipsSEDAGToDAGISel(MipsTargetMachine &TM, CodeGenOpt::Level OL) + explicit MipsSEDAGToDAGISel(MipsTargetMachine &TM, CodeGenOptLevel OL) : MipsDAGToDAGISel(TM, OL) {} private: @@ -140,7 +140,7 @@ class MipsSEDAGToDAGISel : public MipsDAGToDAGISel { }; FunctionPass *createMipsSEISelDag(MipsTargetMachine &TM, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); } #endif diff --git a/llvm/lib/Target/Mips/MipsSubtarget.cpp b/llvm/lib/Target/Mips/MipsSubtarget.cpp index 323e611207a2a..0134fcb341f18 100644 --- a/llvm/lib/Target/Mips/MipsSubtarget.cpp +++ b/llvm/lib/Target/Mips/MipsSubtarget.cpp @@ -234,8 +234,8 @@ void MipsSubtarget::getCriticalPathRCs(RegClassVector &CriticalPathRCs) const { : &Mips::GPR32RegClass); } -CodeGenOpt::Level MipsSubtarget::getOptLevelToEnablePostRAScheduler() const { - return CodeGenOpt::Aggressive; +CodeGenOptLevel MipsSubtarget::getOptLevelToEnablePostRAScheduler() const { + return CodeGenOptLevel::Aggressive; } MipsSubtarget & diff --git a/llvm/lib/Target/Mips/MipsSubtarget.h b/llvm/lib/Target/Mips/MipsSubtarget.h index ec8ca64c8ce8d..014c950425c30 100644 --- a/llvm/lib/Target/Mips/MipsSubtarget.h +++ b/llvm/lib/Target/Mips/MipsSubtarget.h @@ -228,7 +228,7 @@ class MipsSubtarget : public MipsGenSubtargetInfo { /// This overrides the PostRAScheduler bit in the SchedModel for each CPU. bool enablePostRAScheduler() const override; void getCriticalPathRCs(RegClassVector &CriticalPathRCs) const override; - CodeGenOpt::Level getOptLevelToEnablePostRAScheduler() const override; + CodeGenOptLevel getOptLevelToEnablePostRAScheduler() const override; bool isABI_N64() const; bool isABI_N32() const; diff --git a/llvm/lib/Target/Mips/MipsTargetMachine.cpp b/llvm/lib/Target/Mips/MipsTargetMachine.cpp index fe31ab91d0ea3..0742228369292 100644 --- a/llvm/lib/Target/Mips/MipsTargetMachine.cpp +++ b/llvm/lib/Target/Mips/MipsTargetMachine.cpp @@ -123,7 +123,7 @@ MipsTargetMachine::MipsTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT, + CodeGenOptLevel OL, bool JIT, bool isLittle) : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options, isLittle), TT, CPU, FS, Options, getEffectiveRelocModel(JIT, RM), @@ -152,7 +152,7 @@ MipsebTargetMachine::MipsebTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : MipsTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, false) {} void MipselTargetMachine::anchor() {} @@ -162,7 +162,7 @@ MipselTargetMachine::MipselTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : MipsTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, true) {} const MipsSubtarget * @@ -347,7 +347,7 @@ bool MipsPassConfig::addLegalizeMachineIR() { } void MipsPassConfig::addPreRegBankSelect() { - bool IsOptNone = getOptLevel() == CodeGenOpt::None; + bool IsOptNone = getOptLevel() == CodeGenOptLevel::None; addPass(createMipsPostLegalizeCombiner(IsOptNone)); } diff --git a/llvm/lib/Target/Mips/MipsTargetMachine.h b/llvm/lib/Target/Mips/MipsTargetMachine.h index d07e5bb2dfbcf..0ad239e3bed12 100644 --- a/llvm/lib/Target/Mips/MipsTargetMachine.h +++ b/llvm/lib/Target/Mips/MipsTargetMachine.h @@ -40,7 +40,7 @@ class MipsTargetMachine : public LLVMTargetMachine { MipsTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT, bool isLittle); ~MipsTargetMachine() override; @@ -89,7 +89,7 @@ class MipsebTargetMachine : public MipsTargetMachine { MipsebTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); }; @@ -102,7 +102,7 @@ class MipselTargetMachine : public MipsTargetMachine { MipselTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); }; diff --git a/llvm/lib/Target/NVPTX/NVPTX.h b/llvm/lib/Target/NVPTX/NVPTX.h index ec32a95dea908..c5816b9266dfd 100644 --- a/llvm/lib/Target/NVPTX/NVPTX.h +++ b/llvm/lib/Target/NVPTX/NVPTX.h @@ -36,7 +36,7 @@ enum CondCodes { } FunctionPass *createNVPTXISelDag(NVPTXTargetMachine &TM, - llvm::CodeGenOpt::Level OptLevel); + llvm::CodeGenOptLevel OptLevel); ModulePass *createNVPTXAssignValidGlobalNamesPass(); ModulePass *createGenericToNVVMLegacyPass(); ModulePass *createNVPTXCtorDtorLoweringLegacyPass(); diff --git a/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp b/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp index 62991df958daa..0aef2591c6e23 100644 --- a/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp @@ -32,7 +32,7 @@ using namespace llvm; /// createNVPTXISelDag - This pass converts a legalized DAG into a /// NVPTX-specific DAG, ready for instruction scheduling. FunctionPass *llvm::createNVPTXISelDag(NVPTXTargetMachine &TM, - llvm::CodeGenOpt::Level OptLevel) { + llvm::CodeGenOptLevel OptLevel) { return new NVPTXDAGToDAGISel(TM, OptLevel); } @@ -41,9 +41,9 @@ char NVPTXDAGToDAGISel::ID = 0; INITIALIZE_PASS(NVPTXDAGToDAGISel, DEBUG_TYPE, PASS_NAME, false, false) NVPTXDAGToDAGISel::NVPTXDAGToDAGISel(NVPTXTargetMachine &tm, - CodeGenOpt::Level OptLevel) + CodeGenOptLevel OptLevel) : SelectionDAGISel(ID, tm, OptLevel), TM(tm) { - doMulWide = (OptLevel > 0); + doMulWide = (OptLevel > CodeGenOptLevel::None); } bool NVPTXDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) { diff --git a/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h b/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h index b283dc9be068e..06922331f5e20 100644 --- a/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h +++ b/llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h @@ -43,8 +43,7 @@ class LLVM_LIBRARY_VISIBILITY NVPTXDAGToDAGISel : public SelectionDAGISel { NVPTXDAGToDAGISel() = delete; - explicit NVPTXDAGToDAGISel(NVPTXTargetMachine &tm, - CodeGenOpt::Level OptLevel); + explicit NVPTXDAGToDAGISel(NVPTXTargetMachine &tm, CodeGenOptLevel OptLevel); bool runOnMachineFunction(MachineFunction &MF) override; const NVPTXSubtarget *Subtarget = nullptr; diff --git a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp index 8b2d91974e23e..e4d5e5c71b7e1 100644 --- a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp @@ -4804,13 +4804,13 @@ NVPTXTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, //===----------------------------------------------------------------------===// bool NVPTXTargetLowering::allowFMA(MachineFunction &MF, - CodeGenOpt::Level OptLevel) const { + CodeGenOptLevel OptLevel) const { // Always honor command-line argument if (FMAContractLevelOpt.getNumOccurrences() > 0) return FMAContractLevelOpt > 0; // Do not contract if we're not optimizing the code. - if (OptLevel == 0) + if (OptLevel == CodeGenOptLevel::None) return false; // Honor TargetOptions flags that explicitly say fusion is okay. @@ -4834,10 +4834,9 @@ bool NVPTXTargetLowering::allowUnsafeFPMath(MachineFunction &MF) const { /// operands N0 and N1. This is a helper for PerformADDCombine that is /// called with the default operands, and if that fails, with commuted /// operands. -static SDValue PerformADDCombineWithOperands(SDNode *N, SDValue N0, SDValue N1, - TargetLowering::DAGCombinerInfo &DCI, - const NVPTXSubtarget &Subtarget, - CodeGenOpt::Level OptLevel) { +static SDValue PerformADDCombineWithOperands( + SDNode *N, SDValue N0, SDValue N1, TargetLowering::DAGCombinerInfo &DCI, + const NVPTXSubtarget &Subtarget, CodeGenOptLevel OptLevel) { SelectionDAG &DAG = DCI.DAG; // Skip non-integer, non-scalar case EVT VT=N0.getValueType(); @@ -4852,7 +4851,7 @@ static SDValue PerformADDCombineWithOperands(SDNode *N, SDValue N0, SDValue N1, // Since integer multiply-add costs the same as integer multiply // but is more costly than integer add, do the fusion only when // the mul is only used in the add. - if (OptLevel==CodeGenOpt::None || VT != MVT::i32 || + if (OptLevel == CodeGenOptLevel::None || VT != MVT::i32 || !N0.getNode()->hasOneUse()) return SDValue(); @@ -4949,7 +4948,7 @@ static SDValue PerformStoreRetvalCombine(SDNode *N) { static SDValue PerformADDCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI, const NVPTXSubtarget &Subtarget, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { SDValue N0 = N->getOperand(0); SDValue N1 = N->getOperand(1); @@ -5039,11 +5038,11 @@ static SDValue PerformANDCombine(SDNode *N, static SDValue PerformREMCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { assert(N->getOpcode() == ISD::SREM || N->getOpcode() == ISD::UREM); // Don't do anything at less than -O2. - if (OptLevel < CodeGenOpt::Default) + if (OptLevel < CodeGenOptLevel::Default) return SDValue(); SelectionDAG &DAG = DCI.DAG; @@ -5209,8 +5208,8 @@ static SDValue TryMULWIDECombine(SDNode *N, /// PerformMULCombine - Runs PTX-specific DAG combine patterns on MUL nodes. static SDValue PerformMULCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI, - CodeGenOpt::Level OptLevel) { - if (OptLevel > 0) { + CodeGenOptLevel OptLevel) { + if (OptLevel > CodeGenOptLevel::None) { // Try mul.wide combining at OptLevel > 0 if (SDValue Ret = TryMULWIDECombine(N, DCI)) return Ret; @@ -5222,8 +5221,8 @@ static SDValue PerformMULCombine(SDNode *N, /// PerformSHLCombine - Runs PTX-specific DAG combine patterns on SHL nodes. static SDValue PerformSHLCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI, - CodeGenOpt::Level OptLevel) { - if (OptLevel > 0) { + CodeGenOptLevel OptLevel) { + if (OptLevel > CodeGenOptLevel::None) { // Try mul.wide combining at OptLevel > 0 if (SDValue Ret = TryMULWIDECombine(N, DCI)) return Ret; @@ -5255,7 +5254,7 @@ static SDValue PerformSETCCCombine(SDNode *N, SDValue NVPTXTargetLowering::PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const { - CodeGenOpt::Level OptLevel = getTargetMachine().getOptLevel(); + CodeGenOptLevel OptLevel = getTargetMachine().getOptLevel(); switch (N->getOpcode()) { default: break; case ISD::ADD: diff --git a/llvm/lib/Target/NVPTX/NVPTXISelLowering.h b/llvm/lib/Target/NVPTX/NVPTXISelLowering.h index 87cd52c954a7b..0b760d06743ee 100644 --- a/llvm/lib/Target/NVPTX/NVPTXISelLowering.h +++ b/llvm/lib/Target/NVPTX/NVPTXISelLowering.h @@ -556,7 +556,7 @@ class NVPTXTargetLowering : public TargetLowering { unsigned combineRepeatedFPDivisors() const override { return 2; } - bool allowFMA(MachineFunction &MF, CodeGenOpt::Level OptLevel) const; + bool allowFMA(MachineFunction &MF, CodeGenOptLevel OptLevel) const; bool allowUnsafeFPMath(MachineFunction &MF) const; bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF, diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp index 1892f951ee835..cad97b1f14eb2 100644 --- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp @@ -133,7 +133,7 @@ NVPTXTargetMachine::NVPTXTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool is64bit) + CodeGenOptLevel OL, bool is64bit) // The pic relocation model is used regardless of what the client has // specified, as it is the only relocation model currently supported. : LLVMTargetMachine(T, computeDataLayout(is64bit, UseShortPointersOpt), TT, @@ -161,7 +161,7 @@ NVPTXTargetMachine32::NVPTXTargetMachine32(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : NVPTXTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, false) {} void NVPTXTargetMachine64::anchor() {} @@ -171,7 +171,7 @@ NVPTXTargetMachine64::NVPTXTargetMachine64(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : NVPTXTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, true) {} namespace { @@ -310,7 +310,7 @@ NVPTXTargetMachine::getPredicatedAddrSpace(const Value *V) const { } void NVPTXPassConfig::addEarlyCSEOrGVNPass() { - if (getOptLevel() == CodeGenOpt::Aggressive) + if (getOptLevel() == CodeGenOptLevel::Aggressive) addPass(createGVNPass()); else addPass(createEarlyCSEPass()); @@ -373,7 +373,7 @@ void NVPTXPassConfig::addIRPasses() { const NVPTXSubtarget &ST = *getTM().getSubtargetImpl(); addPass(createNVVMReflectPass(ST.getSmVersion())); - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(createNVPTXImageOptimizerPass()); addPass(createNVPTXAssignValidGlobalNamesPass()); addPass(createGenericToNVVMLegacyPass()); @@ -381,7 +381,7 @@ void NVPTXPassConfig::addIRPasses() { // NVPTXLowerArgs is required for correctness and should be run right // before the address space inference passes. addPass(createNVPTXLowerArgsPass()); - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { addAddressSpaceInferencePasses(); addStraightLineScalarOptimizationPasses(); } @@ -403,7 +403,7 @@ void NVPTXPassConfig::addIRPasses() { // %1 = shl %a, 2 // // but EarlyCSE can do neither of them. - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { addEarlyCSEOrGVNPass(); if (!DisableLoadStoreVectorizer) addPass(createLoadStoreVectorizerPass()); @@ -434,7 +434,7 @@ void NVPTXPassConfig::addPreRegAlloc() { void NVPTXPassConfig::addPostRegAlloc() { addPass(createNVPTXPrologEpilogPass()); - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { // NVPTXPrologEpilogPass calculates frame object offset and replace frame // index with VRFrame register. NVPTXPeephole need to be run after that and // will replace VRFrame with VRFrameLocal when possible. diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h index 25dfea11aabc8..cfdd8da9b7652 100644 --- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h +++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h @@ -38,7 +38,7 @@ class NVPTXTargetMachine : public LLVMTargetMachine { NVPTXTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OP, + std::optional CM, CodeGenOptLevel OP, bool is64bit); ~NVPTXTargetMachine() override; const NVPTXSubtarget *getSubtargetImpl(const Function &) const override { @@ -88,7 +88,7 @@ class NVPTXTargetMachine32 : public NVPTXTargetMachine { NVPTXTargetMachine32(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); }; @@ -99,7 +99,7 @@ class NVPTXTargetMachine64 : public NVPTXTargetMachine { NVPTXTargetMachine64(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); }; diff --git a/llvm/lib/Target/PowerPC/PPC.h b/llvm/lib/Target/PowerPC/PPC.h index ad62a47bbbaf6..086b61a93a43d 100644 --- a/llvm/lib/Target/PowerPC/PPC.h +++ b/llvm/lib/Target/PowerPC/PPC.h @@ -46,7 +46,7 @@ class ModulePass; FunctionPass *createPPCMIPeepholePass(); FunctionPass *createPPCBranchSelectionPass(); FunctionPass *createPPCBranchCoalescingPass(); - FunctionPass *createPPCISelDag(PPCTargetMachine &TM, CodeGenOpt::Level OL); + FunctionPass *createPPCISelDag(PPCTargetMachine &TM, CodeGenOptLevel OL); FunctionPass *createPPCTLSDynamicCallPass(); FunctionPass *createPPCBoolRetToIntPass(); FunctionPass *createPPCExpandISELPass(); diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp index 1c2f562a0b3b6..b57d185bb638b 100644 --- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -151,7 +151,7 @@ namespace { PPCDAGToDAGISel() = delete; - explicit PPCDAGToDAGISel(PPCTargetMachine &tm, CodeGenOpt::Level OptLevel) + explicit PPCDAGToDAGISel(PPCTargetMachine &tm, CodeGenOptLevel OptLevel) : SelectionDAGISel(ID, tm, OptLevel), TM(tm) {} bool runOnMachineFunction(MachineFunction &MF) override { @@ -756,8 +756,8 @@ static bool isThreadPointerAcquisitionNode(SDValue Base, SelectionDAG *CurDAG) { static bool canOptimizeTLSDFormToXForm(SelectionDAG *CurDAG, SDValue Base) { // Do not do this transformation at -O0. - if (CurDAG->getTarget().getOptLevel() == CodeGenOpt::None) - return false; + if (CurDAG->getTarget().getOptLevel() == CodeGenOptLevel::None) + return false; // In order to perform this optimization inside tryTLSXForm[Load|Store], // Base is expected to be an ADD_TLS node. @@ -4055,7 +4055,7 @@ bool PPCDAGToDAGISel::tryIntCompareInGPR(SDNode *N) { // This optimization will emit code that assumes 64-bit registers // so we don't want to run it in 32-bit mode. Also don't run it // on functions that are not to be optimized. - if (TM.getOptLevel() == CodeGenOpt::None || !TM.isPPC64()) + if (TM.getOptLevel() == CodeGenOptLevel::None || !TM.isPPC64()) return false; // For POWER10, it is more profitable to use the set boolean extension @@ -6667,7 +6667,7 @@ void PPCDAGToDAGISel::PreprocessISelDAG() { /// on the DAG representation. void PPCDAGToDAGISel::PostprocessISelDAG() { // Skip peepholes at -O0. - if (TM.getOptLevel() == CodeGenOpt::None) + if (TM.getOptLevel() == CodeGenOptLevel::None) return; PeepholePPC64(); @@ -7792,6 +7792,6 @@ void PPCDAGToDAGISel::PeepholePPC64() { /// PowerPC-specific DAG, ready for instruction scheduling. /// FunctionPass *llvm::createPPCISelDag(PPCTargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new PPCDAGToDAGISel(TM, OptLevel); } diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index 95f2243178c8a..f4e3531980d16 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -399,7 +399,7 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM, // MASS transformation for LLVM intrinsics with replicating fast-math flag // to be consistent to PPCGenScalarMASSEntries pass - if (TM.getOptLevel() == CodeGenOpt::Aggressive) { + if (TM.getOptLevel() == CodeGenOptLevel::Aggressive) { setOperationAction(ISD::FSIN , MVT::f64, Custom); setOperationAction(ISD::FCOS , MVT::f64, Custom); setOperationAction(ISD::FPOW , MVT::f64, Custom); @@ -17134,7 +17134,7 @@ bool PPCTargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info, /// target-independent logic. EVT PPCTargetLowering::getOptimalMemOpType( const MemOp &Op, const AttributeList &FuncAttributes) const { - if (getTargetMachine().getOptLevel() != CodeGenOpt::None) { + if (getTargetMachine().getOptLevel() != CodeGenOptLevel::None) { // We should use Altivec/VSX loads and stores when available. For unaligned // addresses, unaligned VSX loads are only fast starting with the P8. if (Subtarget.hasAltivec() && Op.size() >= 16) { diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp index 6ca68ecdcc773..854034b38637a 100644 --- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp @@ -763,7 +763,7 @@ bool PPCInstrInfo::getMachineCombinerPatterns( bool DoRegPressureReduce) const { // Using the machine combiner in this way is potentially expensive, so // restrict to when aggressive optimizations are desired. - if (Subtarget.getTargetMachine().getOptLevel() != CodeGenOpt::Aggressive) + if (Subtarget.getTargetMachine().getOptLevel() != CodeGenOptLevel::Aggressive) return false; if (getFMAPatterns(Root, Patterns, DoRegPressureReduce)) diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp index eaef4bf467c05..42f052cb15d5c 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -197,7 +197,7 @@ static std::string getDataLayoutString(const Triple &T) { return Ret; } -static std::string computeFSAdditions(StringRef FS, CodeGenOpt::Level OL, +static std::string computeFSAdditions(StringRef FS, CodeGenOptLevel OL, const Triple &TT) { std::string FullFS = std::string(FS); @@ -209,14 +209,14 @@ static std::string computeFSAdditions(StringRef FS, CodeGenOpt::Level OL, FullFS = "+64bit"; } - if (OL >= CodeGenOpt::Default) { + if (OL >= CodeGenOptLevel::Default) { if (!FullFS.empty()) FullFS = "+crbits," + FullFS; else FullFS = "+crbits"; } - if (OL != CodeGenOpt::None) { + if (OL != CodeGenOptLevel::None) { if (!FullFS.empty()) FullFS = "+invariant-function-descriptors," + FullFS; else @@ -345,7 +345,7 @@ PPCTargetMachine::PPCTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine(T, getDataLayoutString(TT), TT, CPU, computeFSAdditions(FS, OL, TT), Options, getEffectiveRelocModel(TT, RM), @@ -414,7 +414,7 @@ class PPCPassConfig : public TargetPassConfig { : TargetPassConfig(TM, PM) { // At any optimization level above -O0 we use the Machine Scheduler and not // the default Post RA List Scheduler. - if (TM.getOptLevel() != CodeGenOpt::None) + if (TM.getOptLevel() != CodeGenOptLevel::None) substitutePass(&PostRASchedulerID, &PostMachineSchedulerID); } @@ -454,7 +454,7 @@ TargetPassConfig *PPCTargetMachine::createPassConfig(PassManagerBase &PM) { } void PPCPassConfig::addIRPasses() { - if (TM->getOptLevel() != CodeGenOpt::None) + if (TM->getOptLevel() != CodeGenOptLevel::None) addPass(createPPCBoolRetToIntPass()); addPass(createAtomicExpandPass()); @@ -463,7 +463,7 @@ void PPCPassConfig::addIRPasses() { // Generate PowerPC target-specific entries for scalar math functions // that are available in IBM MASS (scalar) library. - if (TM->getOptLevel() == CodeGenOpt::Aggressive && + if (TM->getOptLevel() == CodeGenOptLevel::Aggressive && EnablePPCGenScalarMASSEntries) { TM->Options.PPCGenScalarMASSEntries = EnablePPCGenScalarMASSEntries; addPass(createPPCGenScalarMASSEntriesPass()); @@ -473,7 +473,7 @@ void PPCPassConfig::addIRPasses() { if (EnablePrefetch.getNumOccurrences() > 0) addPass(createLoopDataPrefetchPass()); - if (TM->getOptLevel() >= CodeGenOpt::Default && EnableGEPOpt) { + if (TM->getOptLevel() >= CodeGenOptLevel::Default && EnableGEPOpt) { // Call SeparateConstOffsetFromGEP pass to extract constants within indices // and lower a GEP with multiple indices to either arithmetic operations or // multiple GEPs with single index. @@ -490,13 +490,13 @@ void PPCPassConfig::addIRPasses() { } bool PPCPassConfig::addPreISel() { - if (MergeStringPool && getOptLevel() != CodeGenOpt::None) + if (MergeStringPool && getOptLevel() != CodeGenOptLevel::None) addPass(createPPCMergeStringPoolPass()); - if (!DisableInstrFormPrep && getOptLevel() != CodeGenOpt::None) + if (!DisableInstrFormPrep && getOptLevel() != CodeGenOptLevel::None) addPass(createPPCLoopInstrFormPrepPass(getPPCTargetMachine())); - if (!DisableCTRLoops && getOptLevel() != CodeGenOpt::None) + if (!DisableCTRLoops && getOptLevel() != CodeGenOptLevel::None) addPass(createHardwareLoopsLegacyPass()); return false; @@ -516,7 +516,7 @@ bool PPCPassConfig::addInstSelector() { addPass(createPPCISelDag(getPPCTargetMachine(), getOptLevel())); #ifndef NDEBUG - if (!DisableCTRLoops && getOptLevel() != CodeGenOpt::None) + if (!DisableCTRLoops && getOptLevel() != CodeGenOptLevel::None) addPass(createPPCCTRLoopsVerify()); #endif @@ -527,12 +527,12 @@ bool PPCPassConfig::addInstSelector() { void PPCPassConfig::addMachineSSAOptimization() { // Run CTR loops pass before any cfg modification pass to prevent the // canonical form of hardware loop from being destroied. - if (!DisableCTRLoops && getOptLevel() != CodeGenOpt::None) + if (!DisableCTRLoops && getOptLevel() != CodeGenOptLevel::None) addPass(createPPCCTRLoopsPass()); // PPCBranchCoalescingPass need to be done before machine sinking // since it merges empty blocks. - if (EnableBranchCoalescing && getOptLevel() != CodeGenOpt::None) + if (EnableBranchCoalescing && getOptLevel() != CodeGenOptLevel::None) addPass(createPPCBranchCoalescingPass()); TargetPassConfig::addMachineSSAOptimization(); // For little endian, remove where possible the vector swap instructions @@ -541,7 +541,7 @@ void PPCPassConfig::addMachineSSAOptimization() { !DisableVSXSwapRemoval) addPass(createPPCVSXSwapRemovalPass()); // Reduce the number of cr-logical ops. - if (ReduceCRLogical && getOptLevel() != CodeGenOpt::None) + if (ReduceCRLogical && getOptLevel() != CodeGenOptLevel::None) addPass(createPPCReduceCRLogicalsPass()); // Target-specific peephole cleanups performed after instruction // selection. @@ -552,7 +552,7 @@ void PPCPassConfig::addMachineSSAOptimization() { } void PPCPassConfig::addPreRegAlloc() { - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { initializePPCVSXFMAMutatePass(*PassRegistry::getPassRegistry()); insertPass(VSXFMAMutateEarly ? &RegisterCoalescerID : &MachineSchedulerID, &PPCVSXFMAMutateID); @@ -570,12 +570,12 @@ void PPCPassConfig::addPreRegAlloc() { if (EnableExtraTOCRegDeps) addPass(createPPCTOCRegDepsPass()); - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(&MachinePipelinerID); } void PPCPassConfig::addPreSched2() { - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(&IfConverterID); } @@ -583,7 +583,7 @@ void PPCPassConfig::addPreEmitPass() { addPass(createPPCPreEmitPeepholePass()); addPass(createPPCExpandISELPass()); - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(createPPCEarlyReturnPass()); } diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.h b/llvm/lib/Target/PowerPC/PPCTargetMachine.h index 5d4571b7323a9..56145a2eb39ce 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetMachine.h +++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.h @@ -39,7 +39,7 @@ class PPCTargetMachine final : public LLVMTargetMachine { PPCTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); ~PPCTargetMachine() override; diff --git a/llvm/lib/Target/RISCV/RISCV.h b/llvm/lib/Target/RISCV/RISCV.h index 107ca51520b77..e66d967fce218 100644 --- a/llvm/lib/Target/RISCV/RISCV.h +++ b/llvm/lib/Target/RISCV/RISCV.h @@ -34,7 +34,7 @@ FunctionPass *createRISCVCodeGenPreparePass(); void initializeRISCVCodeGenPreparePass(PassRegistry &); FunctionPass *createRISCVISelDag(RISCVTargetMachine &TM, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); FunctionPass *createRISCVMakeCompressibleOptPass(); void initializeRISCVMakeCompressibleOptPass(PassRegistry &); diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp index d5c1ab4718dbd..e6d0346c45e8d 100644 --- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp @@ -3653,7 +3653,7 @@ bool RISCVDAGToDAGISel::doPeepholeNoRegPassThru() { // This pass converts a legalized DAG into a RISCV-specific DAG, ready // for instruction scheduling. FunctionPass *llvm::createRISCVISelDag(RISCVTargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new RISCVDAGToDAGISel(TM, OptLevel); } diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h index b9117a4c5efea..c220b2d57c2e5 100644 --- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h +++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h @@ -30,7 +30,7 @@ class RISCVDAGToDAGISel : public SelectionDAGISel { RISCVDAGToDAGISel() = delete; explicit RISCVDAGToDAGISel(RISCVTargetMachine &TargetMachine, - CodeGenOpt::Level OptLevel) + CodeGenOptLevel OptLevel) : SelectionDAGISel(ID, TargetMachine, OptLevel) {} bool runOnMachineFunction(MachineFunction &MF) override { diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp index d4fd66c9b360c..8c15d17c14531 100644 --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -109,7 +109,7 @@ RISCVTargetMachine::RISCVTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, getEffectiveRelocModel(TT, RM), getEffectiveCodeModel(CM, CodeModel::Small), OL), @@ -284,7 +284,7 @@ TargetPassConfig *RISCVTargetMachine::createPassConfig(PassManagerBase &PM) { void RISCVPassConfig::addIRPasses() { addPass(createAtomicExpandPass()); - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { addPass(createRISCVGatherScatterLoweringPass()); addPass(createInterleavedAccessPass()); addPass(createRISCVCodeGenPreparePass()); @@ -294,7 +294,7 @@ void RISCVPassConfig::addIRPasses() { } bool RISCVPassConfig::addPreISel() { - if (TM->getOptLevel() != CodeGenOpt::None) { + if (TM->getOptLevel() != CodeGenOptLevel::None) { // Add a barrier before instruction selection so that we will not get // deleted block address after enabling default outlining. See D99707 for // more details. @@ -350,12 +350,13 @@ void RISCVPassConfig::addPreEmitPass() { // propagation after the machine outliner (which runs after addPreEmitPass) // currently leads to incorrect code-gen, where copies to registers within // outlined functions are removed erroneously. - if (TM->getOptLevel() >= CodeGenOpt::Default && EnableRISCVCopyPropagation) + if (TM->getOptLevel() >= CodeGenOptLevel::Default && + EnableRISCVCopyPropagation) addPass(createMachineCopyPropagationPass(true)); } void RISCVPassConfig::addPreEmitPass2() { - if (TM->getOptLevel() != CodeGenOpt::None) { + if (TM->getOptLevel() != CodeGenOptLevel::None) { addPass(createRISCVMoveMergePass()); // Schedule PushPop Optimization before expansion of Pseudo instruction, // ensuring return instruction is detected correctly. @@ -386,7 +387,7 @@ void RISCVPassConfig::addMachineSSAOptimization() { void RISCVPassConfig::addPreRegAlloc() { addPass(createRISCVPreRAExpandPseudoPass()); - if (TM->getOptLevel() != CodeGenOpt::None) + if (TM->getOptLevel() != CodeGenOptLevel::None) addPass(createRISCVMergeBaseOffsetOptPass()); addPass(createRISCVInsertVSETVLIPass()); addPass(createRISCVInsertReadWriteCSRPass()); @@ -405,7 +406,8 @@ void RISCVPassConfig::addFastRegAlloc() { void RISCVPassConfig::addPostRegAlloc() { - if (TM->getOptLevel() != CodeGenOpt::None && EnableRedundantCopyElimination) + if (TM->getOptLevel() != CodeGenOptLevel::None && + EnableRedundantCopyElimination) addPass(createRISCVRedundantCopyEliminationPass()); } diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.h b/llvm/lib/Target/RISCV/RISCVTargetMachine.h index 775422075314e..68dfb3c81f2fe 100644 --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.h +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.h @@ -29,7 +29,7 @@ class RISCVTargetMachine : public LLVMTargetMachine { RISCVTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); const RISCVSubtarget *getSubtargetImpl(const Function &F) const override; diff --git a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp index 9ca291bdd5f35..14dd429b45191 100644 --- a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp +++ b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp @@ -72,7 +72,7 @@ SPIRVTargetMachine::SPIRVTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, getEffectiveRelocModel(RM), getEffectiveCodeModel(CM, CodeModel::Small), OL), diff --git a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.h b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.h index cb16d7a01f70d..a1a9f26846153 100644 --- a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.h +++ b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.h @@ -26,7 +26,7 @@ class SPIRVTargetMachine : public LLVMTargetMachine { SPIRVTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); const SPIRVSubtarget *getSubtargetImpl() const { return &Subtarget; } diff --git a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp index 577dc1351de9b..6e146fa30a582 100644 --- a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp +++ b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp @@ -100,7 +100,7 @@ SparcTargetMachine::SparcTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT, + CodeGenOptLevel OL, bool JIT, bool is64bit) : LLVMTargetMachine(T, computeDataLayout(TT, is64bit), TT, CPU, FS, Options, getEffectiveRelocModel(RM), @@ -210,7 +210,7 @@ SparcV8TargetMachine::SparcV8TargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : SparcTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, false) {} void SparcV9TargetMachine::anchor() { } @@ -220,7 +220,7 @@ SparcV9TargetMachine::SparcV9TargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : SparcTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, true) {} void SparcelTargetMachine::anchor() {} @@ -230,5 +230,5 @@ SparcelTargetMachine::SparcelTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : SparcTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, false) {} diff --git a/llvm/lib/Target/Sparc/SparcTargetMachine.h b/llvm/lib/Target/Sparc/SparcTargetMachine.h index 6e3c8e7df43fa..0493829cb1bac 100644 --- a/llvm/lib/Target/Sparc/SparcTargetMachine.h +++ b/llvm/lib/Target/Sparc/SparcTargetMachine.h @@ -30,7 +30,7 @@ class SparcTargetMachine : public LLVMTargetMachine { SparcTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT, bool is64bit); ~SparcTargetMachine() override; @@ -57,7 +57,7 @@ class SparcV8TargetMachine : public SparcTargetMachine { SparcV8TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); }; @@ -70,7 +70,7 @@ class SparcV9TargetMachine : public SparcTargetMachine { SparcV9TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); }; @@ -81,7 +81,7 @@ class SparcelTargetMachine : public SparcTargetMachine { SparcelTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); }; diff --git a/llvm/lib/Target/SystemZ/SystemZ.h b/llvm/lib/Target/SystemZ/SystemZ.h index cdd2850ad8e17..d7aa9e4e18cbb 100644 --- a/llvm/lib/Target/SystemZ/SystemZ.h +++ b/llvm/lib/Target/SystemZ/SystemZ.h @@ -189,7 +189,7 @@ static inline bool isImmHF(uint64_t Val) { } // end namespace SystemZ FunctionPass *createSystemZISelDag(SystemZTargetMachine &TM, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); FunctionPass *createSystemZElimComparePass(SystemZTargetMachine &TM); FunctionPass *createSystemZShortenInstPass(SystemZTargetMachine &TM); FunctionPass *createSystemZLongBranchPass(SystemZTargetMachine &TM); diff --git a/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp b/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp index f88e365d3f528..4cc69530db011 100644 --- a/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp +++ b/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp @@ -350,7 +350,7 @@ class SystemZDAGToDAGISel : public SelectionDAGISel { SystemZDAGToDAGISel() = delete; - SystemZDAGToDAGISel(SystemZTargetMachine &TM, CodeGenOpt::Level OptLevel) + SystemZDAGToDAGISel(SystemZTargetMachine &TM, CodeGenOptLevel OptLevel) : SelectionDAGISel(ID, TM, OptLevel) {} bool runOnMachineFunction(MachineFunction &MF) override { @@ -384,7 +384,7 @@ char SystemZDAGToDAGISel::ID = 0; INITIALIZE_PASS(SystemZDAGToDAGISel, DEBUG_TYPE, PASS_NAME, false, false) FunctionPass *llvm::createSystemZISelDag(SystemZTargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new SystemZDAGToDAGISel(TM, OptLevel); } diff --git a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp index 787c51645de16..7a3a2a7e9013d 100644 --- a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp +++ b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp @@ -143,7 +143,7 @@ SystemZTargetMachine::SystemZTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine( T, computeDataLayout(TT), TT, CPU, FS, Options, getEffectiveRelocModel(RM), @@ -221,7 +221,7 @@ class SystemZPassConfig : public TargetPassConfig { } // end anonymous namespace void SystemZPassConfig::addIRPasses() { - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { addPass(createSystemZTDCPass()); addPass(createLoopDataPrefetchPass()); } @@ -232,7 +232,7 @@ void SystemZPassConfig::addIRPasses() { bool SystemZPassConfig::addInstSelector() { addPass(createSystemZISelDag(getSystemZTargetMachine(), getOptLevel())); - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(createSystemZLDCleanupPass(getSystemZTargetMachine())); return false; @@ -254,12 +254,12 @@ void SystemZPassConfig::addPostRewrite() { void SystemZPassConfig::addPostRegAlloc() { // PostRewrite needs to be run at -O0 also (in which case addPostRewrite() // is not called). - if (getOptLevel() == CodeGenOpt::None) + if (getOptLevel() == CodeGenOptLevel::None) addPass(createSystemZPostRewritePass(getSystemZTargetMachine())); } void SystemZPassConfig::addPreSched2() { - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(&IfConverterID); } @@ -267,7 +267,7 @@ void SystemZPassConfig::addPreEmitPass() { // Do instruction shortening before compare elimination because some // vector instructions will be shortened into opcodes that compare // elimination recognizes. - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(createSystemZShortenInstPass(getSystemZTargetMachine())); // We eliminate comparisons here rather than earlier because some @@ -293,14 +293,14 @@ void SystemZPassConfig::addPreEmitPass() { // Doing it so late makes it more likely that a register will be reused // between the comparison and the branch, but it isn't clear whether // preventing that would be a win or not. - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(createSystemZElimComparePass(getSystemZTargetMachine())); addPass(createSystemZLongBranchPass(getSystemZTargetMachine())); // Do final scheduling after all other optimizations, to get an // optimal input for the decoder (branch relaxation must happen // after block placement). - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(&PostMachineSchedulerID); } diff --git a/llvm/lib/Target/SystemZ/SystemZTargetMachine.h b/llvm/lib/Target/SystemZ/SystemZTargetMachine.h index 20d68fff170ac..75e5d68e74eef 100644 --- a/llvm/lib/Target/SystemZ/SystemZTargetMachine.h +++ b/llvm/lib/Target/SystemZ/SystemZTargetMachine.h @@ -33,7 +33,7 @@ class SystemZTargetMachine : public LLVMTargetMachine { SystemZTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); ~SystemZTargetMachine() override; diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp index 323b7c0c0bf1f..0b4a251e5414e 100644 --- a/llvm/lib/Target/TargetMachine.cpp +++ b/llvm/lib/Target/TargetMachine.cpp @@ -198,9 +198,9 @@ TLSModel::Model TargetMachine::getTLSModel(const GlobalValue *GV) const { } /// Returns the optimization level: None, Less, Default, or Aggressive. -CodeGenOpt::Level TargetMachine::getOptLevel() const { return OptLevel; } +CodeGenOptLevel TargetMachine::getOptLevel() const { return OptLevel; } -void TargetMachine::setOptLevel(CodeGenOpt::Level Level) { OptLevel = Level; } +void TargetMachine::setOptLevel(CodeGenOptLevel Level) { OptLevel = Level; } TargetTransformInfo TargetMachine::getTargetTransformInfo(const Function &F) const { diff --git a/llvm/lib/Target/TargetMachineC.cpp b/llvm/lib/Target/TargetMachineC.cpp index 7cd29b40da12c..d418377325b21 100644 --- a/llvm/lib/Target/TargetMachineC.cpp +++ b/llvm/lib/Target/TargetMachineC.cpp @@ -127,19 +127,19 @@ LLVMTargetMachineRef LLVMCreateTargetMachine(LLVMTargetRef T, bool JIT; std::optional CM = unwrap(CodeModel, JIT); - CodeGenOpt::Level OL; + CodeGenOptLevel OL; switch (Level) { case LLVMCodeGenLevelNone: - OL = CodeGenOpt::None; + OL = CodeGenOptLevel::None; break; case LLVMCodeGenLevelLess: - OL = CodeGenOpt::Less; + OL = CodeGenOptLevel::Less; break; case LLVMCodeGenLevelAggressive: - OL = CodeGenOpt::Aggressive; + OL = CodeGenOptLevel::Aggressive; break; default: - OL = CodeGenOpt::Default; + OL = CodeGenOptLevel::Default; break; } @@ -195,10 +195,10 @@ static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M, CodeGenFileType ft; switch (codegen) { case LLVMAssemblyFile: - ft = CGFT_AssemblyFile; + ft = CodeGenFileType::AssemblyFile; break; default: - ft = CGFT_ObjectFile; + ft = CodeGenFileType::ObjectFile; break; } if (TM->addPassesToEmitFile(pass, OS, nullptr, ft)) { diff --git a/llvm/lib/Target/VE/VETargetMachine.cpp b/llvm/lib/Target/VE/VETargetMachine.cpp index 93fb3d8ef8d59..6d102bfd3926a 100644 --- a/llvm/lib/Target/VE/VETargetMachine.cpp +++ b/llvm/lib/Target/VE/VETargetMachine.cpp @@ -88,7 +88,7 @@ VETargetMachine::VETargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, getEffectiveRelocModel(RM), getEffectiveCodeModel(CM, CodeModel::Small), OL), diff --git a/llvm/lib/Target/VE/VETargetMachine.h b/llvm/lib/Target/VE/VETargetMachine.h index 057ff16b75926..fd838296b9dd0 100644 --- a/llvm/lib/Target/VE/VETargetMachine.h +++ b/llvm/lib/Target/VE/VETargetMachine.h @@ -31,7 +31,7 @@ class VETargetMachine : public LLVMTargetMachine { VETargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); ~VETargetMachine() override; diff --git a/llvm/lib/Target/WebAssembly/WebAssembly.h b/llvm/lib/Target/WebAssembly/WebAssembly.h index 53be8f5b67b4f..91765ad117bdb 100644 --- a/llvm/lib/Target/WebAssembly/WebAssembly.h +++ b/llvm/lib/Target/WebAssembly/WebAssembly.h @@ -33,7 +33,7 @@ FunctionPass *createWebAssemblyLowerRefTypesIntPtrConv(); // ISel and immediate followup passes. FunctionPass *createWebAssemblyISelDag(WebAssemblyTargetMachine &TM, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); FunctionPass *createWebAssemblyArgumentMove(); FunctionPass *createWebAssemblySetP2AlignOperands(); diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp index 3d1022de85b53..8833aee02a6a9 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp @@ -47,7 +47,7 @@ class WebAssemblyDAGToDAGISel final : public SelectionDAGISel { WebAssemblyDAGToDAGISel() = delete; WebAssemblyDAGToDAGISel(WebAssemblyTargetMachine &TM, - CodeGenOpt::Level OptLevel) + CodeGenOptLevel OptLevel) : SelectionDAGISel(ID, TM, OptLevel), Subtarget(nullptr) {} bool runOnMachineFunction(MachineFunction &MF) override { @@ -408,6 +408,6 @@ bool WebAssemblyDAGToDAGISel::SelectAddrOperands64(SDValue Op, SDValue &Offset, /// This pass converts a legalized DAG into a WebAssembly-specific DAG, ready /// for instruction scheduling. FunctionPass *llvm::createWebAssemblyISelDag(WebAssemblyTargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new WebAssemblyDAGToDAGISel(TM, OptLevel); } diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index f8a4b95a95515..10464e8f52e56 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -107,7 +107,7 @@ static Reloc::Model getEffectiveRelocModel(std::optional RM, WebAssemblyTargetMachine::WebAssemblyTargetMachine( const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, bool JIT) + std::optional CM, CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine( T, TT.isArch64Bit() @@ -426,7 +426,7 @@ void WebAssemblyPassConfig::addIRPasses() { addPass(createWebAssemblyFixFunctionBitcasts()); // Optimize "returned" function attributes. - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(createWebAssemblyOptimizeReturned()); basicCheckForEHAndSjLj(TM); @@ -503,7 +503,7 @@ void WebAssemblyPassConfig::addOptimizedRegAlloc() { // usually not used for production builds. // TODO Investigate why RegisterCoalesce degrades debug info quality and fix // it properly - if (getOptLevel() == CodeGenOpt::Less) + if (getOptLevel() == CodeGenOptLevel::Less) disablePass(&RegisterCoalescerID); TargetPassConfig::addOptimizedRegAlloc(); } @@ -550,7 +550,7 @@ void WebAssemblyPassConfig::addPreEmitPass() { addPass(createWebAssemblyReplacePhysRegs()); // Preparations and optimizations related to register stackification. - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { // Depend on LiveIntervals and perform some optimizations on it. addPass(createWebAssemblyOptimizeLiveIntervals()); @@ -585,7 +585,7 @@ void WebAssemblyPassConfig::addPreEmitPass() { addPass(createWebAssemblyLowerBrUnless()); // Perform the very last peephole optimizations on the code. - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(createWebAssemblyPeephole()); // Create a mapping from LLVM CodeGen virtual registers to wasm registers. diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h index 04bf2de81fe69..2e8cd43840e3b 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h @@ -30,7 +30,7 @@ class WebAssemblyTargetMachine final : public LLVMTargetMachine { StringRef FS, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT); + CodeGenOptLevel OL, bool JIT); ~WebAssemblyTargetMachine() override; diff --git a/llvm/lib/Target/X86/X86.h b/llvm/lib/Target/X86/X86.h index 76ecc77bc39c2..3c5ca07884980 100644 --- a/llvm/lib/Target/X86/X86.h +++ b/llvm/lib/Target/X86/X86.h @@ -27,8 +27,7 @@ class X86TargetMachine; /// This pass converts a legalized DAG into a X86-specific DAG, ready for /// instruction scheduling. -FunctionPass *createX86ISelDag(X86TargetMachine &TM, - CodeGenOpt::Level OptLevel); +FunctionPass *createX86ISelDag(X86TargetMachine &TM, CodeGenOptLevel OptLevel); /// This pass initializes a global base register for PIC on x86-32. FunctionPass *createX86GlobalBaseRegPass(); diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp index fed26111f60ec..fa5874833c33d 100644 --- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -173,7 +173,7 @@ namespace { X86DAGToDAGISel() = delete; - explicit X86DAGToDAGISel(X86TargetMachine &tm, CodeGenOpt::Level OptLevel) + explicit X86DAGToDAGISel(X86TargetMachine &tm, CodeGenOptLevel OptLevel) : SelectionDAGISel(ID, tm, OptLevel), Subtarget(nullptr), OptForMinSize(false), IndirectTlsSegRefs(false) {} @@ -624,7 +624,8 @@ bool X86DAGToDAGISel::isMaskZeroExtended(SDNode *N) const { bool X86DAGToDAGISel::IsProfitableToFold(SDValue N, SDNode *U, SDNode *Root) const { - if (OptLevel == CodeGenOpt::None) return false; + if (OptLevel == CodeGenOptLevel::None) + return false; if (!N.hasOneUse()) return false; @@ -1242,7 +1243,7 @@ void X86DAGToDAGISel::PreprocessISelDAG() { } } - if (OptLevel != CodeGenOpt::None && + if (OptLevel != CodeGenOptLevel::None && // Only do this when the target can fold the load into the call or // jmp. !Subtarget->useIndirectThunkCalls() && @@ -1481,7 +1482,7 @@ bool X86DAGToDAGISel::tryOptimizeRem8Extend(SDNode *N) { void X86DAGToDAGISel::PostprocessISelDAG() { // Skip peepholes at -O0. - if (TM.getOptLevel() == CodeGenOpt::None) + if (TM.getOptLevel() == CodeGenOptLevel::None) return; SelectionDAG::allnodes_iterator Position = CurDAG->allnodes_end(); @@ -6351,6 +6352,6 @@ bool X86DAGToDAGISel::SelectInlineAsmMemoryOperand( /// This pass converts a legalized DAG into a X86-specific DAG, /// ready for instruction scheduling. FunctionPass *llvm::createX86ISelDag(X86TargetMachine &TM, - CodeGenOpt::Level OptLevel) { + CodeGenOptLevel OptLevel) { return new X86DAGToDAGISel(TM, OptLevel); } diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 008e34ae3c7ff..5c0c3af364259 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -116,7 +116,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM, setStackPointerRegisterToSaveRestore(RegInfo->getStackRegister()); // Bypass expensive divides and use cheaper ones. - if (TM.getOptLevel() >= CodeGenOpt::Default) { + if (TM.getOptLevel() >= CodeGenOptLevel::Default) { if (Subtarget.hasSlowDivide32()) addBypassSlowDiv(32, 8); if (Subtarget.hasSlowDivide64() && Subtarget.is64Bit()) @@ -21513,7 +21513,7 @@ static SDValue LowerFABSorFNEG(SDValue Op, SelectionDAG &DAG) { DAG.getTargetLoweringInfo().isTypeLegal(VT) && "Unexpected type in LowerFABSorFNEG"); - // FIXME: Use function attribute "OptimizeForSize" and/or CodeGenOpt::Level to + // FIXME: Use function attribute "OptimizeForSize" and/or CodeGenOptLevel to // decide if we should generate a 16-byte constant mask when we only need 4 or // 8 bytes for the scalar case. diff --git a/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp b/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp index 102a8ce568527..71637606ddb8d 100644 --- a/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp +++ b/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp @@ -646,7 +646,7 @@ class X86LowerAMXIntrinsicsLegacyPass : public FunctionPass { return false; TargetMachine *TM = &getAnalysis().getTM(); if (!F.hasFnAttribute(Attribute::OptimizeNone) && - TM->getOptLevel() != CodeGenOpt::None) + TM->getOptLevel() != CodeGenOptLevel::None) return false; auto *DTWP = getAnalysisIfAvailable(); diff --git a/llvm/lib/Target/X86/X86LowerAMXType.cpp b/llvm/lib/Target/X86/X86LowerAMXType.cpp index d20d5fe96f492..cea8b80dd13f2 100644 --- a/llvm/lib/Target/X86/X86LowerAMXType.cpp +++ b/llvm/lib/Target/X86/X86LowerAMXType.cpp @@ -1247,8 +1247,8 @@ class X86LowerAMXTypeLegacyPass : public FunctionPass { // Prepare for fast register allocation at O0. // Todo: May better check the volatile model of AMX code, not just - // by checking Attribute::OptimizeNone and CodeGenOpt::None. - if (TM->getOptLevel() == CodeGenOpt::None) { + // by checking Attribute::OptimizeNone and CodeGenOptLevel::None. + if (TM->getOptLevel() == CodeGenOptLevel::None) { // If Front End not use O0 but the Mid/Back end use O0, (e.g. // "Clang -O2 -S -emit-llvm t.c" + "llc t.ll") we should make // sure the amx data is volatile, that is nessary for AMX fast diff --git a/llvm/lib/Target/X86/X86PreAMXConfig.cpp b/llvm/lib/Target/X86/X86PreAMXConfig.cpp index c9c59af8d6d74..7872a64061d43 100644 --- a/llvm/lib/Target/X86/X86PreAMXConfig.cpp +++ b/llvm/lib/Target/X86/X86PreAMXConfig.cpp @@ -383,7 +383,7 @@ class X86PreAMXConfigPass : public FunctionPass { bool C = false; // Prepare for fast register allocation at O0. - if (TM->getOptLevel() == CodeGenOpt::None) { + if (TM->getOptLevel() == CodeGenOptLevel::None) { // We pre-config each key AMX intrinsic at O0. // In theory, one tile config can cover several AMX intrinsics, but diff --git a/llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp b/llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp index d57871130b0cb..5d93a370782d7 100644 --- a/llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp +++ b/llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp @@ -95,7 +95,7 @@ bool X86SpeculativeExecutionSideEffectSuppression::runOnMachineFunction( // user explicitly passed an SESES flag, or whether the SESES target feature // was set. if (!EnableSpeculativeExecutionSideEffectSuppression && - !(Subtarget.useLVILoadHardening() && OptLevel == CodeGenOpt::None) && + !(Subtarget.useLVILoadHardening() && OptLevel == CodeGenOptLevel::None) && !Subtarget.useSpeculativeExecutionSideEffectSuppression()) return false; diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp index 14f37e6ac212e..c0d3b8aa93e6c 100644 --- a/llvm/lib/Target/X86/X86TargetMachine.cpp +++ b/llvm/lib/Target/X86/X86TargetMachine.cpp @@ -224,7 +224,7 @@ X86TargetMachine::X86TargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine( T, computeDataLayout(TT), TT, CPU, FS, Options, getEffectiveRelocModel(TT, JIT, RM), @@ -443,7 +443,7 @@ void X86PassConfig::addIRPasses() { TargetPassConfig::addIRPasses(); - if (TM->getOptLevel() != CodeGenOpt::None) { + if (TM->getOptLevel() != CodeGenOptLevel::None) { addPass(createInterleavedAccessPass()); addPass(createX86PartialReductionPass()); } @@ -473,7 +473,7 @@ bool X86PassConfig::addInstSelector() { // For ELF, cleanup any local-dynamic TLS accesses. if (TM->getTargetTriple().isOSBinFormatELF() && - getOptLevel() != CodeGenOpt::None) + getOptLevel() != CodeGenOptLevel::None) addPass(createCleanupLocalDynamicTLSPass()); addPass(createX86GlobalBaseRegPass()); @@ -518,7 +518,7 @@ bool X86PassConfig::addPreISel() { } void X86PassConfig::addPreRegAlloc() { - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { addPass(&LiveRangeShrinkID); addPass(createX86FixupSetCC()); addPass(createX86OptimizeLEAs()); @@ -530,7 +530,7 @@ void X86PassConfig::addPreRegAlloc() { addPass(createX86FlagsCopyLoweringPass()); addPass(createX86DynAllocaExpander()); - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(createX86PreTileConfigPass()); else addPass(createX86FastPreTileConfigPass()); @@ -548,7 +548,7 @@ void X86PassConfig::addPostRegAlloc() { // to using the Speculative Execution Side Effect Suppression pass for // mitigation. This is to prevent slow downs due to // analyses needed by the LVIHardening pass when compiling at -O0. - if (getOptLevel() != CodeGenOpt::None) + if (getOptLevel() != CodeGenOptLevel::None) addPass(createX86LoadValueInjectionLoadHardeningPass()); } @@ -558,7 +558,7 @@ void X86PassConfig::addPreSched2() { } void X86PassConfig::addPreEmitPass() { - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { addPass(new X86ExecutionDomainFix()); addPass(createBreakFalseDeps()); } @@ -567,7 +567,7 @@ void X86PassConfig::addPreEmitPass() { addPass(createX86IssueVZeroUpperPass()); - if (getOptLevel() != CodeGenOpt::None) { + if (getOptLevel() != CodeGenOptLevel::None) { addPass(createX86FixupBWInsts()); addPass(createX86PadShortFunctions()); addPass(createX86FixupLEAs()); diff --git a/llvm/lib/Target/X86/X86TargetMachine.h b/llvm/lib/Target/X86/X86TargetMachine.h index 5ea51e2fc22c3..4836be4db0e8e 100644 --- a/llvm/lib/Target/X86/X86TargetMachine.h +++ b/llvm/lib/Target/X86/X86TargetMachine.h @@ -35,7 +35,7 @@ class X86TargetMachine final : public LLVMTargetMachine { X86TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); ~X86TargetMachine() override; diff --git a/llvm/lib/Target/XCore/XCore.h b/llvm/lib/Target/XCore/XCore.h index aae1e34fd5ef2..f019fa49f185e 100644 --- a/llvm/lib/Target/XCore/XCore.h +++ b/llvm/lib/Target/XCore/XCore.h @@ -29,7 +29,7 @@ namespace llvm { FunctionPass *createXCoreFrameToArgsOffsetEliminationPass(); FunctionPass *createXCoreISelDag(XCoreTargetMachine &TM, - CodeGenOpt::Level OptLevel); + CodeGenOptLevel OptLevel); ModulePass *createXCoreLowerThreadLocalPass(); void initializeXCoreDAGToDAGISelPass(PassRegistry &); diff --git a/llvm/lib/Target/XCore/XCoreISelDAGToDAG.cpp b/llvm/lib/Target/XCore/XCoreISelDAGToDAG.cpp index 54ee759b1ef3d..1288597fc6b01 100644 --- a/llvm/lib/Target/XCore/XCoreISelDAGToDAG.cpp +++ b/llvm/lib/Target/XCore/XCoreISelDAGToDAG.cpp @@ -45,8 +45,8 @@ namespace { XCoreDAGToDAGISel() = delete; - XCoreDAGToDAGISel(XCoreTargetMachine &TM, CodeGenOpt::Level OptLevel) - : SelectionDAGISel(ID, TM, OptLevel) {} + XCoreDAGToDAGISel(XCoreTargetMachine &TM, CodeGenOptLevel OptLevel) + : SelectionDAGISel(ID, TM, OptLevel) {} void Select(SDNode *N) override; bool tryBRIND(SDNode *N); @@ -88,8 +88,8 @@ INITIALIZE_PASS(XCoreDAGToDAGISel, DEBUG_TYPE, PASS_NAME, false, false) /// XCore-specific DAG, ready for instruction scheduling. /// FunctionPass *llvm::createXCoreISelDag(XCoreTargetMachine &TM, - CodeGenOpt::Level OptLevel) { - return new XCoreDAGToDAGISel(TM, OptLevel); + CodeGenOptLevel OptLevel) { + return new XCoreDAGToDAGISel(TM, OptLevel); } bool XCoreDAGToDAGISel::SelectADDRspii(SDValue Addr, SDValue &Base, diff --git a/llvm/lib/Target/XCore/XCoreTargetMachine.cpp b/llvm/lib/Target/XCore/XCoreTargetMachine.cpp index 410c854a02103..345a8365ed49b 100644 --- a/llvm/lib/Target/XCore/XCoreTargetMachine.cpp +++ b/llvm/lib/Target/XCore/XCoreTargetMachine.cpp @@ -47,7 +47,7 @@ XCoreTargetMachine::XCoreTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : LLVMTargetMachine( T, "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32", TT, CPU, FS, Options, getEffectiveRelocModel(RM), diff --git a/llvm/lib/Target/XCore/XCoreTargetMachine.h b/llvm/lib/Target/XCore/XCoreTargetMachine.h index b45287da3a1c0..23276935713b6 100644 --- a/llvm/lib/Target/XCore/XCoreTargetMachine.h +++ b/llvm/lib/Target/XCore/XCoreTargetMachine.h @@ -31,7 +31,7 @@ class XCoreTargetMachine : public LLVMTargetMachine { XCoreTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); ~XCoreTargetMachine() override; diff --git a/llvm/lib/Target/Xtensa/XtensaTargetMachine.cpp b/llvm/lib/Target/Xtensa/XtensaTargetMachine.cpp index 561ff4f0d5bb9..c891ecd9c0c3f 100644 --- a/llvm/lib/Target/Xtensa/XtensaTargetMachine.cpp +++ b/llvm/lib/Target/Xtensa/XtensaTargetMachine.cpp @@ -47,7 +47,7 @@ XtensaTargetMachine::XtensaTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT, + CodeGenOptLevel OL, bool JIT, bool IsLittle) : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options, IsLittle), TT, CPU, FS, Options, getEffectiveRelocModel(JIT, RM), @@ -61,7 +61,7 @@ XtensaTargetMachine::XtensaTargetMachine(const Target &T, const Triple &TT, const TargetOptions &Options, std::optional RM, std::optional CM, - CodeGenOpt::Level OL, bool JIT) + CodeGenOptLevel OL, bool JIT) : XtensaTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, true) {} TargetPassConfig *XtensaTargetMachine::createPassConfig(PassManagerBase &PM) { diff --git a/llvm/lib/Target/Xtensa/XtensaTargetMachine.h b/llvm/lib/Target/Xtensa/XtensaTargetMachine.h index 866ccdc1e85d0..dd76f45b3bb71 100644 --- a/llvm/lib/Target/Xtensa/XtensaTargetMachine.h +++ b/llvm/lib/Target/Xtensa/XtensaTargetMachine.h @@ -27,13 +27,13 @@ class XtensaTargetMachine : public LLVMTargetMachine { XtensaTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT, bool isLittle); XtensaTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional RM, - std::optional CM, CodeGenOpt::Level OL, + std::optional CM, CodeGenOptLevel OL, bool JIT); TargetPassConfig *createPassConfig(PassManagerBase &PM) override; diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index d43f27d9216ab..d9e5983a4bacd 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -868,7 +868,7 @@ static std::unique_ptr createLTO(IndexWriteCallback OnIndexWrite, Conf.MAttrs = codegen::getMAttrs(); Conf.RelocModel = RelocationModel; Conf.CodeModel = codegen::getExplicitCodeModel(); - std::optional CGOptLevelOrNone = + std::optional CGOptLevelOrNone = CodeGenOpt::getLevel(options::OptLevel); assert(CGOptLevelOrNone && "Invalid optimization level"); Conf.CGOptLevel = *CGOptLevelOrNone; @@ -924,7 +924,7 @@ static std::unique_ptr createLTO(IndexWriteCallback OnIndexWrite, /* UseInputModulePath */ true)); break; case options::OT_ASM_ONLY: - Conf.CGFileType = CGFT_AssemblyFile; + Conf.CGFileType = CodeGenFileType::AssemblyFile; break; } diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp index 8934130f99133..e6fdf631e7912 100644 --- a/llvm/tools/llc/llc.cpp +++ b/llvm/tools/llc/llc.cpp @@ -250,7 +250,7 @@ static std::unique_ptr GetOutputStream(const char *TargetName, OutputFilename = std::string(IFN); switch (codegen::getFileType()) { - case CGFT_AssemblyFile: + case CodeGenFileType::AssemblyFile: if (TargetName[0] == 'c') { if (TargetName[1] == 0) OutputFilename += ".cbe.c"; @@ -261,13 +261,13 @@ static std::unique_ptr GetOutputStream(const char *TargetName, } else OutputFilename += ".s"; break; - case CGFT_ObjectFile: + case CodeGenFileType::ObjectFile: if (OS == Triple::Win32) OutputFilename += ".obj"; else OutputFilename += ".o"; break; - case CGFT_Null: + case CodeGenFileType::Null: OutputFilename = "-"; break; } @@ -277,10 +277,10 @@ static std::unique_ptr GetOutputStream(const char *TargetName, // Decide if we need "binary" output. bool Binary = false; switch (codegen::getFileType()) { - case CGFT_AssemblyFile: + case CodeGenFileType::AssemblyFile: break; - case CGFT_ObjectFile: - case CGFT_Null: + case CodeGenFileType::ObjectFile: + case CodeGenFileType::Null: Binary = true; break; } @@ -468,7 +468,7 @@ static int compileModule(char **argv, LLVMContext &Context) { bool SkipModule = CPUStr == "help" || (!MAttrs.empty() && MAttrs.front() == "help"); - CodeGenOpt::Level OLvl; + CodeGenOptLevel OLvl; if (auto Level = CodeGenOpt::parseLevel(OptLevel)) { OLvl = *Level; } else { @@ -665,7 +665,8 @@ static int compileModule(char **argv, LLVMContext &Context) { // flags. codegen::setFunctionAttributes(CPUStr, FeaturesStr, *M); - if (mc::getExplicitRelaxAll() && codegen::getFileType() != CGFT_ObjectFile) + if (mc::getExplicitRelaxAll() && + codegen::getFileType() != CodeGenFileType::ObjectFile) WithColor::warning(errs(), argv[0]) << ": warning: ignoring -mc-relax-all because filetype != obj"; @@ -676,7 +677,7 @@ static int compileModule(char **argv, LLVMContext &Context) { // so we can memcmp the contents in CompileTwice mode SmallVector Buffer; std::unique_ptr BOS; - if ((codegen::getFileType() != CGFT_AssemblyFile && + if ((codegen::getFileType() != CodeGenFileType::AssemblyFile && !Out->os().supportsSeeking()) || CompileTwice) { BOS = std::make_unique(Buffer); diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp index 6f6cf3c2d7b4b..360ffa628a47b 100644 --- a/llvm/tools/lli/lli.cpp +++ b/llvm/tools/lli/lli.cpp @@ -405,7 +405,7 @@ static void addCygMingExtraModule(ExecutionEngine &EE, LLVMContext &Context, EE.addModule(std::move(M)); } -CodeGenOpt::Level getOptLevel() { +CodeGenOptLevel getOptLevel() { if (auto Level = CodeGenOpt::parseLevel(OptLevel)) return *Level; WithColor::error(errs(), "lli") << "invalid optimization level.\n"; diff --git a/llvm/tools/llvm-exegesis/lib/Assembler.cpp b/llvm/tools/llvm-exegesis/lib/Assembler.cpp index 97b461ebd8e98..167fb6373377c 100644 --- a/llvm/tools/llvm-exegesis/lib/Assembler.cpp +++ b/llvm/tools/llvm-exegesis/lib/Assembler.cpp @@ -299,7 +299,8 @@ Error assembleToStream(const ExegesisTarget &ET, TPC->setInitialized(); // AsmPrinter is responsible for generating the assembly into AsmBuffer. - if (TM->addAsmPrinter(PM, AsmStream, nullptr, CGFT_ObjectFile, MCContext)) + if (TM->addAsmPrinter(PM, AsmStream, nullptr, CodeGenFileType::ObjectFile, + MCContext)) return make_error("Cannot add AsmPrinter passes"); PM.run(*Module); // Run all the passes diff --git a/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp b/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp index eda165d55b0be..9f47609394a5d 100644 --- a/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp +++ b/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp @@ -99,7 +99,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { TargetLibraryInfoImpl TLII(TM->getTargetTriple()); PM.add(new TargetLibraryInfoWrapperPass(TLII)); raw_null_ostream OS; - TM->addPassesToEmitFile(PM, OS, nullptr, CGFT_Null); + TM->addPassesToEmitFile(PM, OS, nullptr, CodeGenFileType::Null); PM.run(*M); return 0; @@ -144,7 +144,7 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(int *argc, std::string CPUStr = codegen::getCPUStr(), FeaturesStr = codegen::getFeaturesStr(); - CodeGenOpt::Level OLvl; + CodeGenOptLevel OLvl; if (auto Level = CodeGenOpt::parseLevel(OptLevel)) { OLvl = *Level; } else { diff --git a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp index d952ea1b06d99..0b2cb9598e5bf 100644 --- a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp +++ b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp @@ -213,7 +213,7 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(int *argc, TM.reset(TheTarget->createTargetMachine( TargetTriple.getTriple(), codegen::getCPUStr(), codegen::getFeaturesStr(), Options, codegen::getExplicitRelocModel(), - codegen::getExplicitCodeModel(), CodeGenOpt::Default)); + codegen::getExplicitCodeModel(), CodeGenOptLevel::Default)); assert(TM && "Could not allocate target machine!"); // Check that pass pipeline is specified and correct diff --git a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp index e71072602ec76..c377fe557cb16 100644 --- a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp +++ b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp @@ -787,7 +787,7 @@ llvm::parseReducerWorkItem(StringRef ToolName, StringRef Filename, std::string FeaturesStr = codegen::getFeaturesStr(); TM = std::unique_ptr(TheTarget->createTargetMachine( TheTriple.getTriple(), CPUStr, FeaturesStr, Options, RM, - codegen::getExplicitCodeModel(), CodeGenOpt::Default)); + codegen::getExplicitCodeModel(), CodeGenOptLevel::Default)); assert(TM && "Could not allocate target machine!"); return TM->createDataLayout().getStringRepresentation(); diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp index 22ebf54e7cbfe..ece6dd0f10830 100644 --- a/llvm/tools/lto/lto.cpp +++ b/llvm/tools/lto/lto.cpp @@ -528,7 +528,7 @@ thinlto_code_gen_t thinlto_create_codegen(void) { if (OptLevel < '0' || OptLevel > '3') report_fatal_error("Optimization level must be between 0 and 3"); CodeGen->setOptLevel(OptLevel - '0'); - std::optional CGOptLevelOrNone = + std::optional CGOptLevelOrNone = CodeGenOpt::getLevel(OptLevel - '0'); assert(CGOptLevelOrNone); CodeGen->setCodeGenOptLevel(*CGOptLevelOrNone); diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index ad53fc2f3defc..9c61fd1f13593 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -174,7 +174,7 @@ static cl::opt OptLevelO3("O3", cl::desc("Optimization level 3. Similar to clang -O3. " "Same as -passes='default'")); -static cl::opt CodeGenOptLevel( +static cl::opt CodeGenOptLevelCL( "codegen-opt-level", cl::desc("Override optimization level for codegen hooks, legacy PM only")); @@ -282,8 +282,8 @@ static cl::list // CodeGen-related helper functions. // -static CodeGenOpt::Level GetCodeGenOptLevel() { - return static_cast(unsigned(CodeGenOptLevel)); +static CodeGenOptLevel GetCodeGenOptLevel() { + return static_cast(unsigned(CodeGenOptLevelCL)); } // Returns the TargetMachine instance or zero if no triple is provided. diff --git a/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp b/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp index 47529f3b11345..0e1f2736907ff 100644 --- a/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp +++ b/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp @@ -42,7 +42,7 @@ class AArch64SelectionDAGTest : public testing::Test { TargetOptions Options; TM = std::unique_ptr(static_cast( T->createTargetMachine("AArch64", "", "+sve", Options, std::nullopt, - std::nullopt, CodeGenOpt::Aggressive))); + std::nullopt, CodeGenOptLevel::Aggressive))); if (!TM) GTEST_SKIP(); @@ -61,7 +61,7 @@ class AArch64SelectionDAGTest : public testing::Test { MF = std::make_unique(*F, *TM, *TM->getSubtargetImpl(*F), 0, MMI); - DAG = std::make_unique(*TM, CodeGenOpt::None); + DAG = std::make_unique(*TM, CodeGenOptLevel::None); if (!DAG) report_fatal_error("DAG?"); OptimizationRemarkEmitter ORE(F); diff --git a/llvm/unittests/CodeGen/AMDGPUMetadataTest.cpp b/llvm/unittests/CodeGen/AMDGPUMetadataTest.cpp index ed2aa552822a0..4f4112dd7f905 100644 --- a/llvm/unittests/CodeGen/AMDGPUMetadataTest.cpp +++ b/llvm/unittests/CodeGen/AMDGPUMetadataTest.cpp @@ -70,7 +70,7 @@ class AMDGPUSelectionDAGTest : public testing::Test { PM.add(new AddMetadataPass(PalMDString)); raw_svector_ostream OutStream(Elf); if (TM->addPassesToEmitFile(PM, OutStream, nullptr, - CodeGenFileType::CGFT_ObjectFile)) + CodeGenFileType::ObjectFile)) report_fatal_error("Target machine cannot emit a file of this type"); PM.run(*M); diff --git a/llvm/unittests/CodeGen/GlobalISel/GISelMITest.cpp b/llvm/unittests/CodeGen/GlobalISel/GISelMITest.cpp index 602ecc71221b6..db9fb3a2d316e 100644 --- a/llvm/unittests/CodeGen/GlobalISel/GISelMITest.cpp +++ b/llvm/unittests/CodeGen/GlobalISel/GISelMITest.cpp @@ -40,7 +40,7 @@ AArch64GISelMITest::createTargetMachine() const { TargetOptions Options; return std::unique_ptr(static_cast( T->createTargetMachine("AArch64", "", "", Options, std::nullopt, - std::nullopt, CodeGenOpt::Aggressive))); + std::nullopt, CodeGenOptLevel::Aggressive))); } void AArch64GISelMITest::getTargetTestModuleString(SmallString<512> &S, @@ -79,7 +79,7 @@ AMDGPUGISelMITest::createTargetMachine() const { return std::unique_ptr(static_cast( T->createTargetMachine("amdgcn-amd-amdhsa", "gfx900", "", Options, std::nullopt, std::nullopt, - CodeGenOpt::Aggressive))); + CodeGenOptLevel::Aggressive))); } void AMDGPUGISelMITest::getTargetTestModuleString( diff --git a/llvm/unittests/CodeGen/InstrRefLDVTest.cpp b/llvm/unittests/CodeGen/InstrRefLDVTest.cpp index aad99a1099d29..c0272c337dfef 100644 --- a/llvm/unittests/CodeGen/InstrRefLDVTest.cpp +++ b/llvm/unittests/CodeGen/InstrRefLDVTest.cpp @@ -81,7 +81,7 @@ class InstrRefLDVTest : public testing::Test { TargetOptions Options; Machine = std::unique_ptr(T->createTargetMachine( Triple::normalize("x86_64--"), "", "", Options, std::nullopt, - std::nullopt, CodeGenOpt::Aggressive)); + std::nullopt, CodeGenOptLevel::Aggressive)); auto Type = FunctionType::get(Type::getVoidTy(Ctx), false); auto F = diff --git a/llvm/unittests/CodeGen/MFCommon.inc b/llvm/unittests/CodeGen/MFCommon.inc index 4fa18accb0d07..7de7eabdd1f60 100644 --- a/llvm/unittests/CodeGen/MFCommon.inc +++ b/llvm/unittests/CodeGen/MFCommon.inc @@ -106,7 +106,7 @@ public: BogusTargetMachine() : LLVMTargetMachine(Target(), "", Triple(""), "", "", getTargetOptionsForBogusMachine(), Reloc::Static, - CodeModel::Small, CodeGenOpt::Default), + CodeModel::Small, CodeGenOptLevel::Default), ST(*this) {} ~BogusTargetMachine() override {} diff --git a/llvm/unittests/CodeGen/SelectionDAGAddressAnalysisTest.cpp b/llvm/unittests/CodeGen/SelectionDAGAddressAnalysisTest.cpp index a8e868d8d4041..d95fc2fb4f1d4 100644 --- a/llvm/unittests/CodeGen/SelectionDAGAddressAnalysisTest.cpp +++ b/llvm/unittests/CodeGen/SelectionDAGAddressAnalysisTest.cpp @@ -48,7 +48,7 @@ class SelectionDAGAddressAnalysisTest : public testing::Test { TargetOptions Options; TM = std::unique_ptr(static_cast( T->createTargetMachine("AArch64", "", "+sve", Options, std::nullopt, - std::nullopt, CodeGenOpt::Aggressive))); + std::nullopt, CodeGenOptLevel::Aggressive))); if (!TM) GTEST_SKIP(); @@ -73,7 +73,7 @@ class SelectionDAGAddressAnalysisTest : public testing::Test { MF = std::make_unique(*F, *TM, *TM->getSubtargetImpl(*F), 0, MMI); - DAG = std::make_unique(*TM, CodeGenOpt::None); + DAG = std::make_unique(*TM, CodeGenOptLevel::None); if (!DAG) report_fatal_error("DAG?"); OptimizationRemarkEmitter ORE(F); diff --git a/llvm/unittests/CodeGen/TargetOptionsTest.cpp b/llvm/unittests/CodeGen/TargetOptionsTest.cpp index e9d8d9a653c2e..2105427e55012 100644 --- a/llvm/unittests/CodeGen/TargetOptionsTest.cpp +++ b/llvm/unittests/CodeGen/TargetOptionsTest.cpp @@ -40,7 +40,7 @@ std::unique_ptr createTargetMachine(bool EnableIPRA) { Options.EnableIPRA = EnableIPRA; return std::unique_ptr( T->createTargetMachine("X86", "", "", Options, std::nullopt, std::nullopt, - CodeGenOpt::Aggressive)); + CodeGenOptLevel::Aggressive)); } typedef std::function TargetOptionsTest; diff --git a/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h b/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h index e0c4b07a71b08..cfd5416585d12 100644 --- a/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h +++ b/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h @@ -274,7 +274,7 @@ class TrivialModuleBuilder { class MCJITTestBase : public MCJITTestAPICommon, public TrivialModuleBuilder { protected: MCJITTestBase() - : TrivialModuleBuilder(HostTriple), OptLevel(CodeGenOpt::None), + : TrivialModuleBuilder(HostTriple), OptLevel(CodeGenOptLevel::None), CodeModel(CodeModel::Small), MArch(""), MM(new SectionMemoryManager) { // The architectures below are known to be compatible with MCJIT as they // are copied from test/ExecutionEngine/MCJIT/lit.local.cfg and should be @@ -307,18 +307,18 @@ class MCJITTestBase : public MCJITTestAPICommon, public TrivialModuleBuilder { EngineBuilder EB(std::move(M)); std::string Error; TheJIT.reset(EB.setEngineKind(EngineKind::JIT) - .setMCJITMemoryManager(std::move(MM)) - .setErrorStr(&Error) - .setOptLevel(CodeGenOpt::None) - .setMArch(MArch) - .setMCPU(sys::getHostCPUName()) - //.setMAttrs(MAttrs) - .create()); + .setMCJITMemoryManager(std::move(MM)) + .setErrorStr(&Error) + .setOptLevel(CodeGenOptLevel::None) + .setMArch(MArch) + .setMCPU(sys::getHostCPUName()) + //.setMAttrs(MAttrs) + .create()); // At this point, we cannot modify the module any more. assert(TheJIT.get() != NULL && "error creating MCJIT with EngineBuilder"); } - CodeGenOpt::Level OptLevel; + CodeGenOptLevel OptLevel; CodeModel::Model CodeModel; StringRef MArch; SmallVector MAttrs; diff --git a/llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp b/llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp index 40993b618eb5a..79e39878d214b 100644 --- a/llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp +++ b/llvm/unittests/ExecutionEngine/Orc/JITTargetMachineBuilderTest.cpp @@ -28,7 +28,7 @@ TEST(ExecutionUtilsTest, JITTargetMachineBuilder) { JTMB.setCPU(""); JTMB.setRelocationModel(std::nullopt); JTMB.setCodeModel(std::nullopt); - JTMB.setCodeGenOptLevel(CodeGenOpt::None); + JTMB.setCodeGenOptLevel(CodeGenOptLevel::None); JTMB.addFeatures(std::vector()); SubtargetFeatures &STF = JTMB.getFeatures(); (void)STF; diff --git a/llvm/unittests/MI/LiveIntervalTest.cpp b/llvm/unittests/MI/LiveIntervalTest.cpp index e3b07c9a4353b..1fd1c78a5e55d 100644 --- a/llvm/unittests/MI/LiveIntervalTest.cpp +++ b/llvm/unittests/MI/LiveIntervalTest.cpp @@ -50,7 +50,7 @@ std::unique_ptr createTargetMachine() { TargetOptions Options; return std::unique_ptr(static_cast( T->createTargetMachine("AMDGPU", "gfx900", "", Options, std::nullopt, - std::nullopt, CodeGenOpt::Aggressive))); + std::nullopt, CodeGenOptLevel::Aggressive))); } std::unique_ptr parseMIR(LLVMContext &Context, diff --git a/llvm/unittests/Target/AArch64/AArch64SVESchedPseudoTest.cpp b/llvm/unittests/Target/AArch64/AArch64SVESchedPseudoTest.cpp index feb7c1d0085c4..9d8633353e1f9 100644 --- a/llvm/unittests/Target/AArch64/AArch64SVESchedPseudoTest.cpp +++ b/llvm/unittests/Target/AArch64/AArch64SVESchedPseudoTest.cpp @@ -27,7 +27,7 @@ std::unique_ptr createTargetMachine(const std::string &CPU) { return std::unique_ptr(static_cast( TheTarget->createTargetMachine(TT, CPU, "", TargetOptions(), std::nullopt, - std::nullopt, CodeGenOpt::Default))); + std::nullopt, CodeGenOptLevel::Default))); } std::unique_ptr createInstrInfo(TargetMachine *TM) { diff --git a/llvm/unittests/Target/AArch64/AddressingModes.cpp b/llvm/unittests/Target/AArch64/AddressingModes.cpp index 0da8ca94ca2e6..284ea7ae9233e 100644 --- a/llvm/unittests/Target/AArch64/AddressingModes.cpp +++ b/llvm/unittests/Target/AArch64/AddressingModes.cpp @@ -166,7 +166,7 @@ TEST(AddressingModes, AddressingModes) { std::unique_ptr TM( T->createTargetMachine(TT, "generic", "", TargetOptions(), std::nullopt, - std::nullopt, CodeGenOpt::Default)); + std::nullopt, CodeGenOptLevel::Default)); AArch64Subtarget ST(TM->getTargetTriple(), TM->getTargetCPU(), TM->getTargetCPU(), TM->getTargetFeatureString(), *TM, true); diff --git a/llvm/unittests/Target/AArch64/InstSizes.cpp b/llvm/unittests/Target/AArch64/InstSizes.cpp index 76bad4d3e99bd..d7e4b4a91cdbd 100644 --- a/llvm/unittests/Target/AArch64/InstSizes.cpp +++ b/llvm/unittests/Target/AArch64/InstSizes.cpp @@ -25,7 +25,7 @@ std::unique_ptr createTargetMachine() { return std::unique_ptr(static_cast( TheTarget->createTargetMachine(TT, CPU, FS, TargetOptions(), std::nullopt, - std::nullopt, CodeGenOpt::Default))); + std::nullopt, CodeGenOptLevel::Default))); } std::unique_ptr createInstrInfo(TargetMachine *TM) { diff --git a/llvm/unittests/Target/AArch64/MatrixRegisterAliasing.cpp b/llvm/unittests/Target/AArch64/MatrixRegisterAliasing.cpp index b4e2fea90432e..ebd49be989921 100644 --- a/llvm/unittests/Target/AArch64/MatrixRegisterAliasing.cpp +++ b/llvm/unittests/Target/AArch64/MatrixRegisterAliasing.cpp @@ -21,7 +21,7 @@ std::unique_ptr createTargetMachine() { return std::unique_ptr(static_cast( TheTarget->createTargetMachine(TT, CPU, FS, TargetOptions(), std::nullopt, - std::nullopt, CodeGenOpt::Default))); + std::nullopt, CodeGenOptLevel::Default))); } std::unique_ptr createInstrInfo(TargetMachine *TM) { diff --git a/llvm/unittests/Target/ARM/InstSizes.cpp b/llvm/unittests/Target/ARM/InstSizes.cpp index cef9dc2f618e7..6c0d9cb96df89 100644 --- a/llvm/unittests/Target/ARM/InstSizes.cpp +++ b/llvm/unittests/Target/ARM/InstSizes.cpp @@ -83,7 +83,7 @@ TEST(InstSizes, PseudoInst) { TargetOptions Options; auto TM = std::unique_ptr(static_cast( T->createTargetMachine(TT, "generic", "", Options, std::nullopt, - std::nullopt, CodeGenOpt::Default))); + std::nullopt, CodeGenOptLevel::Default))); ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), std::string(TM->getTargetFeatureString()), *static_cast(TM.get()), false); diff --git a/llvm/unittests/Target/ARM/MachineInstrTest.cpp b/llvm/unittests/Target/ARM/MachineInstrTest.cpp index 243b027d95a9c..aeb25bf012d03 100644 --- a/llvm/unittests/Target/ARM/MachineInstrTest.cpp +++ b/llvm/unittests/Target/ARM/MachineInstrTest.cpp @@ -85,7 +85,7 @@ TEST(MachineInstructionDoubleWidthResult, IsCorrect) { TargetOptions Options; auto TM = std::unique_ptr(static_cast( T->createTargetMachine(TT, "generic", "", Options, std::nullopt, - std::nullopt, CodeGenOpt::Default))); + std::nullopt, CodeGenOptLevel::Default))); ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), std::string(TM->getTargetFeatureString()), *static_cast(TM.get()), false); @@ -241,7 +241,7 @@ TEST(MachineInstructionHorizontalReduction, IsCorrect) { TargetOptions Options; auto TM = std::unique_ptr(static_cast( T->createTargetMachine(TT, "generic", "", Options, std::nullopt, - std::nullopt, CodeGenOpt::Default))); + std::nullopt, CodeGenOptLevel::Default))); ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), std::string(TM->getTargetFeatureString()), *static_cast(TM.get()), false); @@ -340,7 +340,7 @@ TEST(MachineInstructionRetainsPreviousHalfElement, IsCorrect) { TargetOptions Options; auto TM = std::unique_ptr(static_cast( T->createTargetMachine(TT, "generic", "", Options, std::nullopt, - std::nullopt, CodeGenOpt::Default))); + std::nullopt, CodeGenOptLevel::Default))); ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), std::string(TM->getTargetFeatureString()), *static_cast(TM.get()), false); @@ -1046,7 +1046,7 @@ TEST(MachineInstrValidTailPredication, IsCorrect) { TargetOptions Options; auto TM = std::unique_ptr(static_cast( T->createTargetMachine(TT, "generic", "", Options, std::nullopt, - std::nullopt, CodeGenOpt::Default))); + std::nullopt, CodeGenOptLevel::Default))); ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), std::string(TM->getTargetFeatureString()), *static_cast(TM.get()), false); @@ -1187,7 +1187,7 @@ TEST(MachineInstr, HasSideEffects) { TargetOptions Options; auto TM = std::unique_ptr(static_cast( T->createTargetMachine(TT, "generic", "", Options, std::nullopt, - std::nullopt, CodeGenOpt::Default))); + std::nullopt, CodeGenOptLevel::Default))); ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), std::string(TM->getTargetFeatureString()), *static_cast(TM.get()), false); @@ -2067,7 +2067,7 @@ TEST(MachineInstr, MVEVecSize) { TargetOptions Options; auto TM = std::unique_ptr(static_cast( T->createTargetMachine(TT, "generic", "", Options, std::nullopt, - std::nullopt, CodeGenOpt::Default))); + std::nullopt, CodeGenOptLevel::Default))); ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), std::string(TM->getTargetFeatureString()), *static_cast(TM.get()), false); diff --git a/llvm/unittests/Target/LoongArch/InstSizes.cpp b/llvm/unittests/Target/LoongArch/InstSizes.cpp index 1a5d4369c48be..e027f256825b6 100644 --- a/llvm/unittests/Target/LoongArch/InstSizes.cpp +++ b/llvm/unittests/Target/LoongArch/InstSizes.cpp @@ -26,7 +26,7 @@ std::unique_ptr createTargetMachine() { return std::unique_ptr(static_cast( TheTarget->createTargetMachine(TT, CPU, FS, TargetOptions(), std::nullopt, - std::nullopt, CodeGenOpt::Default))); + std::nullopt, CodeGenOptLevel::Default))); } std::unique_ptr createInstrInfo(TargetMachine *TM) { diff --git a/llvm/unittests/Target/PowerPC/AIXRelocModelTest.cpp b/llvm/unittests/Target/PowerPC/AIXRelocModelTest.cpp index 3e2568a7b8763..6df0e3ac655da 100644 --- a/llvm/unittests/Target/PowerPC/AIXRelocModelTest.cpp +++ b/llvm/unittests/Target/PowerPC/AIXRelocModelTest.cpp @@ -29,7 +29,7 @@ TEST_F(AIXRelocModelTest, DefalutToPIC) { std::unique_ptr Target(TheTarget->createTargetMachine( /*TT*/ TheTriple.getTriple(), /*CPU*/ "", /*Features*/ "", /*Options*/ Options, /*RM*/ std::nullopt, /*CM*/ std::nullopt, - /*OL*/ CodeGenOpt::Default)); + /*OL*/ CodeGenOptLevel::Default)); ASSERT_TRUE(Target) << "Could not allocate target machine!"; // The relocation model on AIX should be forced to PIC regardless. diff --git a/llvm/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp b/llvm/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp index eec1cc28f490b..d4e214c43e98c 100644 --- a/llvm/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp +++ b/llvm/unittests/Target/WebAssembly/WebAssemblyExceptionInfoTest.cpp @@ -36,7 +36,7 @@ std::unique_ptr createTargetMachine() { return std::unique_ptr(static_cast( TheTarget->createTargetMachine(TT, CPU, FS, TargetOptions(), std::nullopt, - std::nullopt, CodeGenOpt::Default))); + std::nullopt, CodeGenOptLevel::Default))); } std::unique_ptr parseMIR(LLVMContext &Context, diff --git a/llvm/unittests/Target/X86/MachineSizeOptsTest.cpp b/llvm/unittests/Target/X86/MachineSizeOptsTest.cpp index 84286455a269e..5afc1e01d5fe8 100644 --- a/llvm/unittests/Target/X86/MachineSizeOptsTest.cpp +++ b/llvm/unittests/Target/X86/MachineSizeOptsTest.cpp @@ -33,7 +33,7 @@ std::unique_ptr createTargetMachine() { const Target *TheTarget = TargetRegistry::lookupTarget(TT, Error); return std::unique_ptr(static_cast( TheTarget->createTargetMachine(TT, "", "", TargetOptions(), std::nullopt, - std::nullopt, CodeGenOpt::Default))); + std::nullopt, CodeGenOptLevel::Default))); } class MachineSizeOptsTest : public testing::Test { diff --git a/llvm/unittests/Target/X86/TernlogTest.cpp b/llvm/unittests/Target/X86/TernlogTest.cpp index df9d1cc9b2980..072a91d57f65d 100644 --- a/llvm/unittests/Target/X86/TernlogTest.cpp +++ b/llvm/unittests/Target/X86/TernlogTest.cpp @@ -29,7 +29,7 @@ static std::unique_ptr initTM() { const Target *TheTarget = TargetRegistry::lookupTarget(TT, Error); return std::unique_ptr(static_cast( TheTarget->createTargetMachine(TT, "", "", TargetOptions(), std::nullopt, - std::nullopt, CodeGenOpt::Default))); + std::nullopt, CodeGenOptLevel::Default))); } struct TernTester { diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h index 573a94d34b1c6..66f49c787c190 100644 --- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h +++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h @@ -68,7 +68,7 @@ struct ExecutionEngineOptions { /// `jitCodeGenOptLevel`, when provided, is used as the optimization level for /// target code generation. - std::optional jitCodeGenOptLevel; + std::optional jitCodeGenOptLevel; /// If `sharedLibPaths` are provided, the underlying JIT-compilation will /// open and link the shared libraries for symbol resolution. Libraries that diff --git a/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp index 067cf677ee348..507be9171d328 100644 --- a/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp +++ b/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp @@ -53,12 +53,11 @@ mlirExecutionEngineCreate(MlirModule op, int optLevel, int numPaths, // Create a transformer to run all LLVM optimization passes at the // specified optimization level. - auto llvmOptLevel = static_cast(optLevel); auto transformer = mlir::makeOptimizingTransformer( - llvmOptLevel, /*sizeLevel=*/0, /*targetMachine=*/tmOrError->get()); + optLevel, /*sizeLevel=*/0, /*targetMachine=*/tmOrError->get()); ExecutionEngineOptions jitOptions; jitOptions.transformer = transformer; - jitOptions.jitCodeGenOptLevel = llvmOptLevel; + jitOptions.jitCodeGenOptLevel = static_cast(optLevel); jitOptions.sharedLibPaths = libPaths; jitOptions.enableObjectDump = enableObjectDump; auto jitOrError = ExecutionEngine::create(unwrap(op), jitOptions); diff --git a/mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp b/mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp index 2758689045df2..1fdfe972a8b59 100644 --- a/mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp @@ -56,7 +56,7 @@ gpu::SerializeToBlobPass::translateToISA(llvm::Module &llvmModule, llvm::legacy::PassManager codegenPasses; if (targetMachine.addPassesToEmitFile(codegenPasses, pstream, nullptr, - llvm::CGFT_AssemblyFile)) + llvm::CodeGenFileType::AssemblyFile)) return std::nullopt; codegenPasses.run(llvmModule); @@ -110,7 +110,7 @@ gpu::SerializeToBlobPass::optimizeLlvm(llvm::Module &llvmModule, return getOperation().emitError() << "invalid optimization level " << optLevel; - targetMachine.setOptLevel(static_cast(optLevel)); + targetMachine.setOptLevel(static_cast(optLevel)); auto transformer = makeOptimizingTransformer(optLevel, /*sizeLevel=*/0, &targetMachine); diff --git a/mlir/lib/ExecutionEngine/JitRunner.cpp b/mlir/lib/ExecutionEngine/JitRunner.cpp index 4fbd124e928bf..cf462ddf6f17c 100644 --- a/mlir/lib/ExecutionEngine/JitRunner.cpp +++ b/mlir/lib/ExecutionEngine/JitRunner.cpp @@ -181,9 +181,9 @@ static Error compileAndExecute(Options &options, Operation *module, StringRef entryPoint, CompileAndExecuteConfig config, void **args, std::unique_ptr tm = nullptr) { - std::optional jitCodeGenOptLevel; + std::optional jitCodeGenOptLevel; if (auto clOptLevel = getCommandLineOptLevel(options)) - jitCodeGenOptLevel = static_cast(*clOptLevel); + jitCodeGenOptLevel = static_cast(*clOptLevel); SmallVector sharedLibs(options.clSharedLibs.begin(), options.clSharedLibs.end()); diff --git a/mlir/lib/Target/LLVM/ModuleToObject.cpp b/mlir/lib/Target/LLVM/ModuleToObject.cpp index b7594f4cd5bf5..e68ae8311ecfb 100644 --- a/mlir/lib/Target/LLVM/ModuleToObject.cpp +++ b/mlir/lib/Target/LLVM/ModuleToObject.cpp @@ -143,7 +143,7 @@ LogicalResult ModuleToObject::optimizeModule(llvm::Module &module, return getOperation().emitError() << "Invalid optimization level: " << optLevel << "."; - targetMachine.setOptLevel(static_cast(optLevel)); + targetMachine.setOptLevel(static_cast(optLevel)); auto transformer = makeOptimizingTransformer(optLevel, /*sizeLevel=*/0, &targetMachine); @@ -170,7 +170,7 @@ ModuleToObject::translateToISA(llvm::Module &llvmModule, llvm::legacy::PassManager codegenPasses; if (targetMachine.addPassesToEmitFile(codegenPasses, pstream, nullptr, - llvm::CGFT_AssemblyFile)) + llvm::CodeGenFileType::AssemblyFile)) return std::nullopt; codegenPasses.run(llvmModule); diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp index 657996ff112aa..3def95ee49205 100644 --- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp +++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp @@ -112,10 +112,10 @@ OptimizationLevel getOptLevel(unsigned OptLevel) { Expected> createTargetMachine(Module &M, std::string CPU, unsigned OptLevel) { Triple TT(M.getTargetTriple()); - std::optional CGOptLevelOrNone = + std::optional CGOptLevelOrNone = CodeGenOpt::getLevel(OptLevel); assert(CGOptLevelOrNone && "Invalid optimization level"); - CodeGenOpt::Level CGOptLevel = *CGOptLevelOrNone; + CodeGenOptLevel CGOptLevel = *CGOptLevelOrNone; std::string Msg; const Target *T = TargetRegistry::lookupTarget(M.getTargetTriple(), Msg); @@ -182,7 +182,8 @@ void JITEngine::codegen(TargetMachine *TM, TargetLibraryInfoImpl *TLII, MachineModuleInfoWrapperPass *MMIWP = new MachineModuleInfoWrapperPass( reinterpret_cast(TM)); TM->addPassesToEmitFile(PM, OS, nullptr, - TT.isNVPTX() ? CGFT_AssemblyFile : CGFT_ObjectFile, + TT.isNVPTX() ? CodeGenFileType::AssemblyFile + : CodeGenFileType::ObjectFile, /* DisableVerify */ false, MMIWP); PM.run(M);