[PATCH] D109878: [ModuleInlinerWrapperPass] Do some naive printing of wrapped pipeline with -print-pipeline-passes

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 16 06:03:40 PDT 2021


bjope created this revision.
bjope added reviewers: aeubanks, mtrofin, markus.
Herald added subscribers: ormris, hiraditya, eraman.
bjope requested review of this revision.
Herald added a project: LLVM.

Bisecting and reducing opt pipelines that includes the
ModuleInlinerWrapperPass has turned out to be a bit problematic.
This is far from perfect, but it should give some kind of hint
to what the wrapped pipeline looks like when using
-print-pipeline-passes.

We are using some unparseable 'ModuleInlinerWrapperPass<<< ... >>>'
tags when printing the pipeline to indicate that this can't be
assumed to be working if just taking the printed pipeline and trying
to use it in the -passes opt option. Because it still lacks
information about inline advisors etc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109878

Files:
  llvm/include/llvm/Transforms/IPO/Inliner.h
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/test/Other/new-pm-print-pipeline.ll


Index: llvm/test/Other/new-pm-print-pipeline.ll
===================================================================
--- llvm/test/Other/new-pm-print-pipeline.ll
+++ llvm/test/Other/new-pm-print-pipeline.ll
@@ -60,3 +60,18 @@
 
 ; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only>,loop-vectorize<interleave-forced-only;vectorize-forced-only>)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-19
 ; CHECK-19: function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,loop-vectorize<interleave-forced-only;vectorize-forced-only;>)
+
+; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='inliner-wrapper,inliner-wrapper-no-mandatory-first' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-20
+; XXX: Not sure exactly how to print this considering InlineAnalysisAdvisor
+; and ModuleInlinerWrapper pass parameters. But this could give a hint at what
+; is going on. even if it can just be inserted and used in 'opt -passes='.
+; CHECK-20: ModuleInlinerWrapperPass<<<cgscc(inline<only-mandatory>,inline)>>>,ModuleInlinerWrapperPass<<<cgscc(inline)>>>
+
+; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='scc-oz-module-inliner' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-21
+; XXX: Not sure exactly how to print this considering InlineAnalysisAdvisor
+; and ModuleInlinerWrapper pass parameters. But this could give a hint at what
+; is going on. even if it can just be inserted and used in 'opt -passes='.
+; XXX: Not sure exactly how to print this considering InlineAnalysisAdvisor
+; and ModuleInlinerWrapper pass parameters. But this could give a hint at what
+; is going on. even if it can just be inserted and used in 'opt -passes='.
+; CHECK-21: ModuleInlinerWrapperPass<<<require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline<only-mandatory>,inline,{{.*}},instcombine{{.*}}))>>>
Index: llvm/lib/Transforms/IPO/Inliner.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Inliner.cpp
+++ llvm/lib/Transforms/IPO/Inliner.cpp
@@ -1061,3 +1061,23 @@
   if (OnlyMandatory)
     OS << "<only-mandatory>";
 }
+
+void ModuleInlinerWrapperPass::printPipeline(
+    raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) {
+  // Print some info about passes added to the wrapper. This is however
+  // incomplete as InlineAdvisorAnalysis part isn't included (which also depends
+  // on Params and Mode).
+  OS << "ModuleInlinerWrapperPass<<<";
+  if (!MPM.isEmpty()) {
+    MPM.printPipeline(OS, MapClassName2PassName);
+    OS << ",";
+  }
+  OS << "cgscc(";
+  if (MaxDevirtIterations != 0)
+    OS << "devirt<" << MaxDevirtIterations << ">(";
+  PM.printPipeline(OS, MapClassName2PassName);
+  if (MaxDevirtIterations != 0)
+    OS << ")";
+  OS << ")";
+  OS << ">>>";
+}
Index: llvm/include/llvm/Transforms/IPO/Inliner.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/Inliner.h
+++ llvm/include/llvm/Transforms/IPO/Inliner.h
@@ -138,6 +138,9 @@
     MPM.addPass(std::move(Pass));
   }
 
+  void printPipeline(raw_ostream &OS,
+                     function_ref<StringRef(StringRef)> MapClassName2PassName);
+
 private:
   const InlineParams Params;
   const InliningAdvisorMode Mode;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109878.372913.patch
Type: text/x-patch
Size: 3456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210916/f3480bfb/attachment.bin>


More information about the llvm-commits mailing list