[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
This commit is contained in:
Nikita Popov 2022-04-05 15:05:46 +02:00
parent b0e2ffe151
commit ed4e6e0398
24 changed files with 33 additions and 67 deletions

View file

@ -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>;

View file

@ -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

View file

@ -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')

View file

@ -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@"

View file

@ -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

View file

@ -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();

View file

@ -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,

View file

@ -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;

View file

@ -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));

View file

@ -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);

View file

@ -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)

View file

@ -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()

View file

@ -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.

View file

@ -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}

View file

@ -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;

View file

@ -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.

View file

@ -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.

View file

@ -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,

View file

@ -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,

View file

@ -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

View file

@ -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.

View file

@ -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",

View file

@ -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 */

View file

@ -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}