diff options
author | Nikita Popov <npopov@redhat.com> | 2022-04-05 15:05:46 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2022-04-06 09:52:21 +0200 |
commit | ed4e6e03981a37d54c4ac635b2bdb2c2fe8fec92 (patch) | |
tree | fea672749e6b62c41a16a3c21fd134b83f21b9fe | |
parent | b0e2ffe151c34cae87e41f8f6a58207506796fee (diff) | |
download | llvm-ed4e6e03981a37d54c4ac635b2bdb2c2fe8fec92.zip llvm-ed4e6e03981a37d54c4ac635b2bdb2c2fe8fec92.tar.gz llvm-ed4e6e03981a37d54c4ac635b2bdb2c2fe8fec92.tar.bz2 |
[cmake] Remove LLVM_ENABLE_NEW_PASS_MANAGER cmake option
Or rather, error out if it is set to something other than ON. This
removes the ability to enable the legacy pass manager by default,
but does not remove the ability to explicitly enable it through
various flags like -flegacy-pass-manager or -enable-new-pm=0.
I checked, and our test suite definitely doesn't pass with
LLVM_ENABLE_NEW_PASS_MANAGER=OFF anymore.
Differential Revision: https://reviews.llvm.org/D123126
24 files changed, 33 insertions, 67 deletions
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index bc5aa1a..4862765 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1933,7 +1933,7 @@ def fglobal_isel : Flag<["-"], "fglobal-isel">, Group<f_clang_Group>, def fexperimental_isel : Flag<["-"], "fexperimental-isel">, Group<f_clang_Group>, Alias<fglobal_isel>; defm legacy_pass_manager : BoolOption<"f", "legacy-pass-manager", - CodeGenOpts<"LegacyPassManager">, Default<"!static_cast<unsigned>(LLVM_ENABLE_NEW_PASS_MANAGER)">, + CodeGenOpts<"LegacyPassManager">, DefaultFalse, PosFlag<SetTrue, [], "Use the legacy pass manager in LLVM (deprecated, to be removed in a future release)">, NegFlag<SetFalse, [], "Use the new pass manager in LLVM">, BothFlags<[CC1Option]>>, Group<f_clang_Group>; diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt index 1fb5386..7d050b2 100644 --- a/clang/test/CMakeLists.txt +++ b/clang/test/CMakeLists.txt @@ -9,7 +9,6 @@ llvm_canonicalize_cmake_booleans( CLANG_PLUGIN_SUPPORT CLANG_SPAWN_CC1 ENABLE_BACKTRACES - LLVM_ENABLE_NEW_PASS_MANAGER LLVM_ENABLE_ZLIB LLVM_ENABLE_PER_TARGET_RUNTIME_DIR LLVM_ENABLE_THREADS diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py index 1e6165c..d8eacce 100644 --- a/clang/test/lit.cfg.py +++ b/clang/test/lit.cfg.py @@ -140,10 +140,6 @@ if config.clang_default_cxx_stdlib != '': if platform.system() not in ['FreeBSD']: config.available_features.add('crash-recovery') -# Support for new pass manager. -if config.enable_experimental_new_pass_manager: - config.available_features.add('experimental-new-pass-manager') - # ANSI escape sequences in non-dumb terminal if platform.system() not in ['Windows']: config.available_features.add('ansi-escape-sequences') diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index de1dc0f..3725d84 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -29,7 +29,6 @@ config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@ config.clang_examples = @CLANG_BUILD_EXAMPLES@ config.enable_shared = @ENABLE_SHARED@ config.enable_backtrace = @ENABLE_BACKTRACES@ -config.enable_experimental_new_pass_manager = @LLVM_ENABLE_NEW_PASS_MANAGER@ config.enable_threads = @LLVM_ENABLE_THREADS@ config.host_arch = "@HOST_ARCH@" config.python_executable = "@Python3_EXECUTABLE@" diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp index 692d04a..d7f5af8 100644 --- a/clang/unittests/Frontend/CompilerInvocationTest.cpp +++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp @@ -259,49 +259,38 @@ TEST_F(CommandLineTest, BoolOptionDefaultFalsePresentNegReset) { // The flag with positive spelling can set the keypath to true. // The flag with negative spelling can set the keypath to false. -static constexpr unsigned PassManagerDefault = - !static_cast<unsigned>(LLVM_ENABLE_NEW_PASS_MANAGER); - -static constexpr const char *PassManagerResetByFlag = - LLVM_ENABLE_NEW_PASS_MANAGER ? "-fno-legacy-pass-manager" - : "-flegacy-pass-manager"; - -static constexpr const char *PassManagerChangedByFlag = - LLVM_ENABLE_NEW_PASS_MANAGER ? "-flegacy-pass-manager" - : "-fno-legacy-pass-manager"; - TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentNone) { const char *Args = {""}; ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags)); - ASSERT_EQ(Invocation.getCodeGenOpts().LegacyPassManager, PassManagerDefault); + ASSERT_EQ(Invocation.getCodeGenOpts().LegacyPassManager, false); Invocation.generateCC1CommandLine(GeneratedArgs, *this); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq(PassManagerResetByFlag)))); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq(PassManagerChangedByFlag)))); + ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-legacy-pass-manager")))); + ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-flegacy-pass-manager")))); } TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentChange) { - const char *Args[] = {PassManagerChangedByFlag}; + const char *Args[] = {"-flegacy-pass-manager"}; ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags)); - ASSERT_EQ(Invocation.getCodeGenOpts().LegacyPassManager, !PassManagerDefault); + ASSERT_EQ(Invocation.getCodeGenOpts().LegacyPassManager, true); Invocation.generateCC1CommandLine(GeneratedArgs, *this); - ASSERT_THAT(GeneratedArgs, Contains(StrEq(PassManagerChangedByFlag))); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq(PassManagerResetByFlag)))); + ASSERT_THAT(GeneratedArgs, Contains(StrEq("-flegacy-pass-manager"))); + ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-legacy-pass-manager")))); } TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentReset) { - const char *Args[] = {PassManagerResetByFlag}; + const char *Args[] = {"-fno-legacy-pass-manager"}; ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags)); - ASSERT_EQ(Invocation.getCodeGenOpts().LegacyPassManager, PassManagerDefault); + ASSERT_EQ(Invocation.getCodeGenOpts().LegacyPassManager, false); Invocation.generateCC1CommandLine(GeneratedArgs, *this); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq(PassManagerResetByFlag)))); - ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq(PassManagerChangedByFlag)))); + ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-legacy-pass-manager")))); + ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-flegacy-pass-manager")))); } // Boolean option that gets the CC1Option flag from a let statement (which diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp index 9cb836d..d4448e8 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -1679,7 +1679,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) { if (args.hasArg(OPT_profile)) icfLevel = ICFLevel::None; unsigned tailMerge = 1; - bool ltoNewPM = LLVM_ENABLE_NEW_PASS_MANAGER; + bool ltoNewPM = true; bool ltoDebugPM = false; for (auto *arg : args.filtered(OPT_opt)) { std::string str = StringRef(arg->getValue()).lower(); diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index b221d17..c28f819 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -1102,9 +1102,8 @@ static void readConfigs(opt::InputArgList &args) { OPT_no_lto_pgo_warn_mismatch, true); config->ltoDebugPassManager = args.hasArg(OPT_lto_debug_pass_manager); config->ltoEmitAsm = args.hasArg(OPT_lto_emit_asm); - config->ltoNewPassManager = - args.hasFlag(OPT_no_lto_legacy_pass_manager, OPT_lto_legacy_pass_manager, - LLVM_ENABLE_NEW_PASS_MANAGER); + config->ltoNewPassManager = args.hasFlag(OPT_no_lto_legacy_pass_manager, + OPT_lto_legacy_pass_manager, true); config->ltoNewPmPasses = args.getLastArgValue(OPT_lto_newpm_passes); config->ltoWholeProgramVisibility = args.hasFlag(OPT_lto_whole_program_visibility, diff --git a/lld/MachO/Config.h b/lld/MachO/Config.h index 60dd383..c6c6cfc 100644 --- a/lld/MachO/Config.h +++ b/lld/MachO/Config.h @@ -107,7 +107,7 @@ struct Configuration { bool implicitDylibs = false; bool isPic = false; bool headerPadMaxInstallNames = false; - bool ltoNewPassManager = LLVM_ENABLE_NEW_PASS_MANAGER; + bool ltoNewPassManager = true; bool markDeadStrippableDylib = false; bool printDylibSearch = false; bool printEachFile = false; diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp index e7996f8..8ab9793 100644 --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -1222,9 +1222,8 @@ bool macho::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS, config->umbrella = arg->getValue(); } config->ltoObjPath = args.getLastArgValue(OPT_object_path_lto); - config->ltoNewPassManager = - args.hasFlag(OPT_no_lto_legacy_pass_manager, OPT_lto_legacy_pass_manager, - LLVM_ENABLE_NEW_PASS_MANAGER); + config->ltoNewPassManager = args.hasFlag(OPT_no_lto_legacy_pass_manager, + OPT_lto_legacy_pass_manager, true); config->ltoo = args::getInteger(args, OPT_lto_O, 2); if (config->ltoo > 3) error("--lto-O: invalid optimization level: " + Twine(config->ltoo)); diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp index 6d84b60..187a228 100644 --- a/lld/wasm/Driver.cpp +++ b/lld/wasm/Driver.cpp @@ -365,9 +365,8 @@ static void readConfigs(opt::InputArgList &args) { config->importUndefined = args.hasArg(OPT_import_undefined); config->ltoo = args::getInteger(args, OPT_lto_O, 2); config->ltoPartitions = args::getInteger(args, OPT_lto_partitions, 1); - config->ltoNewPassManager = - args.hasFlag(OPT_no_lto_legacy_pass_manager, OPT_lto_legacy_pass_manager, - LLVM_ENABLE_NEW_PASS_MANAGER); + config->ltoNewPassManager = args.hasFlag(OPT_no_lto_legacy_pass_manager, + OPT_lto_legacy_pass_manager, true); config->ltoDebugPassManager = args.hasArg(OPT_lto_debug_pass_manager); config->mapFile = args.getLastArgValue(OPT_Map); config->optimize = args::getInteger(args, OPT_O, 1); diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 988c77b6..5e786b7 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -767,9 +767,8 @@ option(LLVM_ENABLE_PLUGINS "Enable plugin support" ${LLVM_ENABLE_PLUGINS_default set(LLVM_ENABLE_NEW_PASS_MANAGER TRUE CACHE BOOL "Enable the new pass manager by default.") if(NOT LLVM_ENABLE_NEW_PASS_MANAGER) - message(WARNING "Using the legacy pass manager for the optimization pipeline" - " is deprecated. The functionality will degrade over time and" - " be removed in a future release.") + message(FATAL_ERROR "Enabling the legacy pass manager on the cmake level is" + " no longer supported.") endif() include(HandleLLVMOptions) diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in index ab7eb09..d95fa919 100644 --- a/llvm/cmake/modules/LLVMConfig.cmake.in +++ b/llvm/cmake/modules/LLVMConfig.cmake.in @@ -88,8 +88,6 @@ set(LLVM_ENABLE_PIC @LLVM_ENABLE_PIC@) set(LLVM_BUILD_32_BITS @LLVM_BUILD_32_BITS@) -set(LLVM_ENABLE_NEW_PASS_MANAGER @LLVM_ENABLE_NEW_PASS_MANAGER@) - if (NOT "@LLVM_PTHREAD_LIB@" STREQUAL "") set(LLVM_PTHREAD_LIB "@LLVM_PTHREAD_LIB@") endif() diff --git a/llvm/docs/NewPassManager.rst b/llvm/docs/NewPassManager.rst index 74ed077..58d5a26 100644 --- a/llvm/docs/NewPassManager.rst +++ b/llvm/docs/NewPassManager.rst @@ -481,9 +481,8 @@ the new PM, whereas the backend target-dependent code generation only works with the legacy PM. For the optimization pipeline, the new PM is the default PM. The legacy PM is -available for the optimization pipeline either by setting the CMake flag -``-DLLVM_ENABLE_NEW_PASS_MANAGER=OFF`` when building LLVM, or by -various compiler/linker flags, e.g. ``-flegacy-pass-manager`` for ``clang``. +available for the optimization pipeline by setting various compiler/linker +flags, e.g. ``-flegacy-pass-manager`` for ``clang``. There will be efforts to deprecate and remove the legacy PM for the optimization pipeline in the future. diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake index f8281d8..f15eef3 100644 --- a/llvm/include/llvm/Config/llvm-config.h.cmake +++ b/llvm/include/llvm/Config/llvm-config.h.cmake @@ -97,9 +97,6 @@ /* Define to 1 if you have the <sysexits.h> header file. */ #cmakedefine HAVE_SYSEXITS_H ${HAVE_SYSEXITS_H} -/* Define to 1 to enable the experimental new pass manager by default */ -#cmakedefine01 LLVM_ENABLE_NEW_PASS_MANAGER - /* Define if the xar_open() function is supported on this platform. */ #cmakedefine LLVM_HAVE_LIBXAR ${LLVM_HAVE_LIBXAR} diff --git a/llvm/include/llvm/LTO/Config.h b/llvm/include/llvm/LTO/Config.h index 0cf84de..6142952 100644 --- a/llvm/include/llvm/LTO/Config.h +++ b/llvm/include/llvm/LTO/Config.h @@ -58,7 +58,7 @@ struct Config { bool DisableVerify = false; /// Use the new pass manager - bool UseNewPM = LLVM_ENABLE_NEW_PASS_MANAGER; + bool UseNewPM = true; /// Use the standard optimization pipeline. bool UseDefaultPipeline = false; diff --git a/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h b/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h index be1f315..fe9aef6 100644 --- a/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h +++ b/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h @@ -349,7 +349,7 @@ private: /// Flag to indicate whether the new pass manager should be used for IR /// optimizations. - bool UseNewPM = LLVM_ENABLE_NEW_PASS_MANAGER; + bool UseNewPM = true; /// Flag to indicate whether debug output should be enabled for the new pass /// manager. diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index 180c181..0477a15 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -201,7 +201,7 @@ namespace options { // Sample profile file path static std::string sample_profile; // New pass manager - static bool new_pass_manager = LLVM_ENABLE_NEW_PASS_MANAGER; + static bool new_pass_manager = true; // Debug new pass manager static bool debug_pass_manager = false; // Directory to store the .dwo files. diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp index 8fc3a5d..8d58d39 100644 --- a/llvm/tools/llvm-lto/llvm-lto.cpp +++ b/llvm/tools/llvm-lto/llvm-lto.cpp @@ -256,9 +256,10 @@ static cl::opt<bool> PrintMachOCPUOnly( cl::desc("Instead of running LTO, print the mach-o cpu in each IR file"), cl::cat(LTOCategory)); -static cl::opt<bool> UseNewPM( - "use-new-pm", cl::desc("Run LTO passes using the new pass manager"), - cl::init(LLVM_ENABLE_NEW_PASS_MANAGER), cl::Hidden, cl::cat(LTOCategory)); +static cl::opt<bool> + UseNewPM("use-new-pm", + cl::desc("Run LTO passes using the new pass manager"), + cl::init(true), cl::Hidden, cl::cat(LTOCategory)); static cl::opt<bool> DebugPassManager("debug-pass-manager", cl::init(false), cl::Hidden, diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp index 7416e58..7ca10c7 100644 --- a/llvm/tools/llvm-lto2/llvm-lto2.cpp +++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp @@ -146,7 +146,7 @@ static cl::opt<bool> static cl::opt<bool> UseNewPM("use-new-pm", cl::desc("Run LTO passes using the new pass manager"), - cl::init(LLVM_ENABLE_NEW_PASS_MANAGER), cl::Hidden); + cl::init(true), cl::Hidden); static cl::opt<bool> DebugPassManager("debug-pass-manager", cl::init(false), cl::Hidden, diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index dbcc401..3136ddb 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -75,7 +75,7 @@ static cl::opt<bool> EnableNewPassManager( cl::desc("Enable the new pass manager, translating " "'opt -foo' to 'opt -passes=foo'. This is strictly for the new PM " "migration, use '-passes=' when possible."), - cl::init(LLVM_ENABLE_NEW_PASS_MANAGER)); + cl::init(true)); // This flag specifies a textual description of the optimization pass pipeline // to run over the module. This flag switches opt to use the new pass manager diff --git a/llvm/utils/gn/secondary/clang/test/BUILD.gn b/llvm/utils/gn/secondary/clang/test/BUILD.gn index e919b01..ad88271 100644 --- a/llvm/utils/gn/secondary/clang/test/BUILD.gn +++ b/llvm/utils/gn/secondary/clang/test/BUILD.gn @@ -60,7 +60,6 @@ write_lit_config("lit_site_cfg") { "CMAKE_CXX_COMPILER=c++", "CMAKE_C_COMPILER=cc", "ENABLE_BACKTRACES=1", - "LLVM_ENABLE_NEW_PASS_MANAGER=1", "LLVM_EXTERNAL_LIT=", "LLVM_HOST_TRIPLE=$llvm_current_triple", "LLVM_LIT_TOOLS_DIR=", # Intentionally empty, matches cmake build. diff --git a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn index 506c72b..4cab34f 100644 --- a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn @@ -335,7 +335,6 @@ write_cmake_config("llvm-config") { "LLVM_BUILD_SHARED_LIBS=", "LLVM_DEFAULT_TARGET_TRIPLE=$llvm_target_triple", "LLVM_ENABLE_DUMP=", - "LLVM_ENABLE_NEW_PASS_MANAGER=1", "LLVM_FORCE_ENABLE_STATS=", "LLVM_FORCE_USE_OLD_TOOLCHAIN=", "LLVM_HAS_ATOMICS=1", diff --git a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h index 59d8aa6c..b1acc04 100644 --- a/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h +++ b/utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/llvm-config.h @@ -105,9 +105,6 @@ /* Define to 1 if you have the <sysexits.h> header file. */ /* HAVE_SYSEXITS_H defined in Bazel */ -/* Define to 1 to enable the experimental new pass manager by default */ -#define LLVM_ENABLE_NEW_PASS_MANAGER 0 - /* Define if the xar_open() function is supported this platform. */ /* #undef HAVE_LIBXAR */ diff --git a/utils/bazel/llvm_configs/llvm-config.h.cmake b/utils/bazel/llvm_configs/llvm-config.h.cmake index f8281d8..f15eef3 100644 --- a/utils/bazel/llvm_configs/llvm-config.h.cmake +++ b/utils/bazel/llvm_configs/llvm-config.h.cmake @@ -97,9 +97,6 @@ /* Define to 1 if you have the <sysexits.h> header file. */ #cmakedefine HAVE_SYSEXITS_H ${HAVE_SYSEXITS_H} -/* Define to 1 to enable the experimental new pass manager by default */ -#cmakedefine01 LLVM_ENABLE_NEW_PASS_MANAGER - /* Define if the xar_open() function is supported on this platform. */ #cmakedefine LLVM_HAVE_LIBXAR ${LLVM_HAVE_LIBXAR} |