From 8b8da01d8827fb17412a57c90fd7056828a0ad67 Mon Sep 17 00:00:00 2001 From: Wael Yehia Date: Wed, 29 Sep 2021 19:42:43 +0000 Subject: [PATCH] Revert "[LTO][Legacy] Add -debug-pass-manager option to enable pass run/skip trace." This reverts commit a60405cf035dc114e7ee090139bed2577f4ea7ef. --- llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h | 7 +++++++ llvm/lib/LTO/LTO.cpp | 6 ------ llvm/lib/LTO/LTOCodeGenerator.cpp | 3 --- llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 9 +++++---- llvm/test/tools/llvm-lto/lto-passes.ll | 12 ------------ llvm/tools/llvm-lto/llvm-lto.cpp | 6 ++++++ llvm/tools/llvm-lto2/llvm-lto2.cpp | 8 ++++---- 7 files changed, 22 insertions(+), 29 deletions(-) delete mode 100644 llvm/test/tools/llvm-lto/lto-passes.ll diff --git a/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h b/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h index 062be35..b8daea9 100644 --- a/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h +++ b/llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h @@ -229,6 +229,9 @@ public: /// Enable or disable the new pass manager. void setUseNewPM(unsigned Enabled) { UseNewPM = Enabled; } + /// Enable or disable debug output for the new pass manager. + void setDebugPassManager(unsigned Enabled) { DebugPassManager = Enabled; } + /// Disable CodeGen, only run the stages till codegen and stop. The output /// will be bitcode. void disableCodeGen(bool Disable) { DisableCodeGen = Disable; } @@ -348,6 +351,10 @@ private: /// Flag to indicate whether the new pass manager should be used for IR /// optimizations. bool UseNewPM = LLVM_ENABLE_NEW_PASS_MANAGER; + + /// Flag to indicate whether debug output should be enabled for the new pass + /// manager. + bool DebugPassManager = false; }; } #endif diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 841ed4d..111fdc8 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -73,12 +73,6 @@ cl::opt EnableLTOInternalization( "enable-lto-internalization", cl::init(true), cl::Hidden, cl::desc("Enable global value internalization in LTO")); -namespace llvm { -cl::opt - DebugPassManager("debug-pass-manager", cl::init(false), cl::Hidden, - cl::desc("Print pass management debugging information")); -} - // Computes a unique hash for the Module considering the current list of // export/import and other global analysis results. // The hash is produced in \p Key. diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index 5d7252e6..7bffcbf 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -117,8 +117,6 @@ cl::opt LTOStatsFile( "lto-stats-file", cl::desc("Save statistics to the specified file"), cl::Hidden); - -extern cl::opt DebugPassManager; } LTOCodeGenerator::LTOCodeGenerator(LLVMContext &Context) @@ -132,7 +130,6 @@ LTOCodeGenerator::LTOCodeGenerator(LLVMContext &Context) Config.PreCodeGenPassesHook = [](legacy::PassManager &PM) { PM.add(createObjCARCContractPass()); }; - Config.DebugPassManager = DebugPassManager; } LTOCodeGenerator::~LTOCodeGenerator() {} diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index d1966ca..e9602b3 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -84,7 +84,6 @@ extern cl::opt RemarksWithHotness; extern cl::opt, false, remarks::HotnessThresholdParser> RemarksHotnessThreshold; extern cl::opt RemarksFormat; -extern cl::opt DebugPassManager; } namespace { @@ -270,6 +269,7 @@ static void optimizeModule(Module &TheModule, TargetMachine &TM, static void optimizeModuleNewPM(Module &TheModule, TargetMachine &TM, unsigned OptLevel, bool Freestanding, + bool DebugPassManager, ModuleSummaryIndex *Index) { Optional PGOOpt; LoopAnalysisManager LAM; @@ -489,7 +489,7 @@ ProcessThinLTOModule(Module &TheModule, ModuleSummaryIndex &Index, const ThinLTOCodeGenerator::CachingOptions &CacheOptions, bool DisableCodeGen, StringRef SaveTempsDir, bool Freestanding, unsigned OptLevel, unsigned count, - bool UseNewPM) { + bool UseNewPM, bool DebugPassManager) { // "Benchmark"-like optimization: single-source case bool SingleModule = (ModuleMap.size() == 1); @@ -530,7 +530,8 @@ ProcessThinLTOModule(Module &TheModule, ModuleSummaryIndex &Index, } if (UseNewPM) - optimizeModuleNewPM(TheModule, TM, OptLevel, Freestanding, &Index); + optimizeModuleNewPM(TheModule, TM, OptLevel, Freestanding, DebugPassManager, + &Index); else optimizeModule(TheModule, TM, OptLevel, Freestanding, &Index); @@ -1218,7 +1219,7 @@ void ThinLTOCodeGenerator::run() { ExportList, GUIDPreservedSymbols, ModuleToDefinedGVSummaries[ModuleIdentifier], CacheOptions, DisableCodeGen, SaveTempsDir, Freestanding, OptLevel, count, - UseNewPM); + UseNewPM, DebugPassManager); // Commit to the cache (if enabled) CacheEntry.write(*OutputBuffer); diff --git a/llvm/test/tools/llvm-lto/lto-passes.ll b/llvm/test/tools/llvm-lto/lto-passes.ll deleted file mode 100644 index c8424ec..0000000 --- a/llvm/test/tools/llvm-lto/lto-passes.ll +++ /dev/null @@ -1,12 +0,0 @@ -; Test that -debug-pass-manager works in LTOCodeGenerator. The actual list of -; passes that is run during LTO is tested in: -; llvm/test/Other/new-pm-lto-defaults.ll -; -; RUN: llvm-as < %s > %t.bc -; RUN: llvm-lto %t.bc -O0 --debug-pass-manager 2>&1 | FileCheck %s -; CHECK: Running pass: WholeProgramDevirtPass - -define i32 @main() { -entry: - ret i32 42 -} diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp index dbf0b18..45cca0f 100644 --- a/llvm/tools/llvm-lto/llvm-lto.cpp +++ b/llvm/tools/llvm-lto/llvm-lto.cpp @@ -259,6 +259,11 @@ static cl::opt 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 + DebugPassManager("debug-pass-manager", cl::init(false), cl::Hidden, + cl::desc("Print pass management debugging information"), + cl::cat(LTOCategory)); + namespace { struct ModuleInfo { @@ -599,6 +604,7 @@ public: ThinGenerator.setCacheMaxSizeBytes(ThinLTOCacheMaxSizeBytes); ThinGenerator.setFreestanding(EnableFreestanding); ThinGenerator.setUseNewPM(UseNewPM); + ThinGenerator.setDebugPassManager(DebugPassManager); // Add all the exported symbols to the table of symbols to preserve. for (unsigned i = 0; i < ExportedSymbols.size(); ++i) diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp index d6c69bc..c0bff1e 100644 --- a/llvm/tools/llvm-lto2/llvm-lto2.cpp +++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp @@ -147,6 +147,10 @@ static cl::opt cl::desc("Run LTO passes using the new pass manager"), cl::init(LLVM_ENABLE_NEW_PASS_MANAGER), cl::Hidden); +static cl::opt + DebugPassManager("debug-pass-manager", cl::init(false), cl::Hidden, + cl::desc("Print pass management debugging information")); + static cl::opt StatsFile("stats-file", cl::desc("Filename to write statistics to")); @@ -168,10 +172,6 @@ static void check(Error E, std::string Msg) { exit(1); } -namespace llvm { -extern cl::opt DebugPassManager; -} - template static T check(Expected E, std::string Msg) { if (E) return std::move(*E); -- 2.7.4