[PATCH] D36195: Fix the bug that parseAAPipeline is not invoked in runNewPMPasses in release compiler.

Dehao Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 1 18:34:56 PDT 2017


danielcdh updated this revision to Diff 109259.
danielcdh added a comment.

Add test.


https://reviews.llvm.org/D36195

Files:
  include/llvm/LTO/Config.h
  lib/LTO/LTOBackend.cpp
  test/tools/llvm-lto2/X86/pipeline.ll
  tools/llvm-lto2/llvm-lto2.cpp


Index: tools/llvm-lto2/llvm-lto2.cpp
===================================================================
--- tools/llvm-lto2/llvm-lto2.cpp
+++ tools/llvm-lto2/llvm-lto2.cpp
@@ -109,6 +109,10 @@
              cl::desc("Run LTO passes using the new pass manager"),
              cl::init(false), cl::Hidden);
 
+static cl::opt<bool>
+    DebugPassManager("debug-pass-manager", cl::init(false), cl::Hidden,
+                     cl::desc("Print pass management debugging information"));
+
 static void check(Error E, std::string Msg) {
   if (!E)
     return;
@@ -195,6 +199,8 @@
     Conf.RelocModel = *RM;
   Conf.CodeModel = CMModel;
 
+  Conf.DebugPassManager = DebugPassManager;
+
   if (SaveTemps)
     check(Conf.addSaveTemps(OutputFilename + "."),
           "Config::addSaveTemps failed");
Index: test/tools/llvm-lto2/X86/pipeline.ll
===================================================================
--- test/tools/llvm-lto2/X86/pipeline.ll
+++ test/tools/llvm-lto2/X86/pipeline.ll
@@ -1,5 +1,10 @@
 ; RUN: llvm-as < %s > %t1.bc
 
+; Try the default pipeline and check is BasicAA is invoked.
+; RUN: llvm-lto2 run %t1.bc -o %t.o -r %t1.bc,patatino,px -debug-pass-manager \
+; RUN:  -use-new-pm 2>&1 | FileCheck %s --check-prefix=DEFAULT
+; DEFAULT: Running analysis: BasicAA on patatino
+
 ; Try a custom pipeline
 ; RUN: llvm-lto2 run %t1.bc -o %t.o -save-temps \
 ; RUN:  -r %t1.bc,patatino,px -opt-pipeline loweratomic \
Index: lib/LTO/LTOBackend.cpp
===================================================================
--- lib/LTO/LTOBackend.cpp
+++ lib/LTO/LTOBackend.cpp
@@ -141,12 +141,13 @@
   AAManager AA;
 
   // Parse a custom AA pipeline if asked to.
-  assert(PB.parseAAPipeline(AA, "default"));
+  if (!PB.parseAAPipeline(AA, "default"))
+    report_fatal_error("Error parsing default AA pipeline");
 
-  LoopAnalysisManager LAM;
-  FunctionAnalysisManager FAM;
-  CGSCCAnalysisManager CGAM;
-  ModuleAnalysisManager MAM;
+  LoopAnalysisManager LAM(Conf.DebugPassManager);
+  FunctionAnalysisManager FAM(Conf.DebugPassManager);
+  CGSCCAnalysisManager CGAM(Conf.DebugPassManager);
+  ModuleAnalysisManager MAM(Conf.DebugPassManager);
 
   // Register the AA manager first so that our version is the one used.
   FAM.registerPass([&] { return std::move(AA); });
@@ -158,7 +159,7 @@
   PB.registerLoopAnalyses(LAM);
   PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
 
-  ModulePassManager MPM;
+  ModulePassManager MPM(Conf.DebugPassManager);
   // FIXME (davide): verify the input.
 
   PassBuilder::OptimizationLevel OL;
@@ -181,9 +182,9 @@
   }
 
   if (IsThinLTO)
-    MPM = PB.buildThinLTODefaultPipeline(OL, false /* DebugLogging */);
+    MPM = PB.buildThinLTODefaultPipeline(OL, Conf.DebugPassManager);
   else
-    MPM = PB.buildLTODefaultPipeline(OL, false /* DebugLogging */);
+    MPM = PB.buildLTODefaultPipeline(OL, Conf.DebugPassManager);
   MPM.run(Mod, MAM);
 
   // FIXME (davide): verify the output.
Index: include/llvm/LTO/Config.h
===================================================================
--- include/llvm/LTO/Config.h
+++ include/llvm/LTO/Config.h
@@ -79,6 +79,9 @@
   /// Whether to emit optimization remarks with hotness informations.
   bool RemarksWithHotness = false;
 
+  /// Whether to emit the pass manager debuggging informations.
+  bool DebugPassManager = false;
+
   bool ShouldDiscardValueNames = true;
   DiagnosticHandlerFunction DiagHandler;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36195.109259.patch
Type: text/x-patch
Size: 3411 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170802/c7f38e76/attachment.bin>


More information about the llvm-commits mailing list