diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -26,6 +26,7 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/BinaryFormat/Magic.h" +#include "llvm/Config/llvm-config.h" #include "llvm/LTO/LTO.h" #include "llvm/Object/ArchiveWriter.h" #include "llvm/Object/COFFImportFile.h" @@ -1518,7 +1519,7 @@ unsigned icfLevel = args.hasArg(OPT_profile) ? 0 : 1; // 0: off, 1: limited, 2: on unsigned tailMerge = 1; - bool ltoNewPM = false; + bool ltoNewPM = LLVM_ENABLE_NEW_PASS_MANAGER; 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 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -47,6 +47,7 @@ #include "llvm/ADT/SetVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/Config/llvm-config.h" #include "llvm/LTO/LTO.h" #include "llvm/Remarks/HotnessThresholdParser.h" #include "llvm/Support/CommandLine.h" @@ -988,8 +989,9 @@ config->ltoCSProfileFile = args.getLastArgValue(OPT_lto_cs_profile_file); config->ltoDebugPassManager = args.hasArg(OPT_lto_debug_pass_manager); config->ltoEmitAsm = args.hasArg(OPT_lto_emit_asm); - config->ltoNewPassManager = args.hasFlag(OPT_lto_new_pass_manager, - OPT_no_lto_new_pass_manager, false); + config->ltoNewPassManager = + args.hasFlag(OPT_lto_new_pass_manager, OPT_no_lto_new_pass_manager, + LLVM_ENABLE_NEW_PASS_MANAGER); config->ltoNewPmPasses = args.getLastArgValue(OPT_lto_newpm_passes); config->ltoWholeProgramVisibility = args.hasFlag(OPT_lto_whole_program_visibility, diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp --- a/lld/wasm/Driver.cpp +++ b/lld/wasm/Driver.cpp @@ -21,6 +21,7 @@ #include "lld/Common/Strings.h" #include "lld/Common/Version.h" #include "llvm/ADT/Twine.h" +#include "llvm/Config/llvm-config.h" #include "llvm/Object/Wasm.h" #include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" @@ -379,8 +380,9 @@ config->importTable = args.hasArg(OPT_import_table); config->ltoo = args::getInteger(args, OPT_lto_O, 2); config->ltoPartitions = args::getInteger(args, OPT_lto_partitions, 1); - config->ltoNewPassManager = args.hasFlag(OPT_lto_new_pass_manager, - OPT_lto_no_new_pass_manager, false); + config->ltoNewPassManager = + args.hasFlag(OPT_lto_new_pass_manager, OPT_lto_no_new_pass_manager, + LLVM_ENABLE_NEW_PASS_MANAGER); config->ltoDebugPassManager = args.hasArg(OPT_lto_debug_pass_manager); config->mapFile = args.getLastArgValue(OPT_Map); config->optimize = args::getInteger(args, OPT_O, 0); diff --git a/llvm/include/llvm/LTO/Config.h b/llvm/include/llvm/LTO/Config.h --- a/llvm/include/llvm/LTO/Config.h +++ b/llvm/include/llvm/LTO/Config.h @@ -15,6 +15,7 @@ #define LLVM_LTO_CONFIG_H #include "llvm/ADT/DenseSet.h" +#include "llvm/Config/llvm-config.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/GlobalValue.h" #include "llvm/IR/LLVMContext.h" @@ -50,7 +51,7 @@ bool DisableVerify = false; /// Use the new pass manager - bool UseNewPM = false; + bool UseNewPM = LLVM_ENABLE_NEW_PASS_MANAGER; /// Flag to indicate that the optimizer should not assume builtins are present /// on the target. diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -16,6 +16,7 @@ #include "llvm/Bitcode/BitcodeWriter.h" #include "llvm/CodeGen/CommandFlags.h" #include "llvm/Config/config.h" // plugin-api.h requires HAVE_STDINT_H +#include "llvm/Config/llvm-config.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DiagnosticPrinter.h" #include "llvm/LTO/Caching.h" @@ -200,7 +201,7 @@ // Sample profile file path static std::string sample_profile; // New pass manager - static bool new_pass_manager = false; + static bool new_pass_manager = LLVM_ENABLE_NEW_PASS_MANAGER; // Debug new pass manager static bool debug_pass_manager = false; // Directory to store the .dwo files. diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp --- a/llvm/tools/llvm-lto2/llvm-lto2.cpp +++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp @@ -17,6 +17,7 @@ #include "llvm/Bitcode/BitcodeReader.h" #include "llvm/CodeGen/CommandFlags.h" +#include "llvm/Config/llvm-config.h" #include "llvm/IR/DiagnosticPrinter.h" #include "llvm/LTO/Caching.h" #include "llvm/LTO/LTO.h" @@ -144,7 +145,7 @@ static cl::opt UseNewPM("use-new-pm", cl::desc("Run LTO passes using the new pass manager"), - cl::init(false), cl::Hidden); + cl::init(LLVM_ENABLE_NEW_PASS_MANAGER), cl::Hidden); static cl::opt DebugPassManager("debug-pass-manager", cl::init(false), cl::Hidden,