[PATCH] D127221: [Clang] Enable -print-pipeline-passes in clang.

Joshua Cranmer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 7 08:31:08 PDT 2022


jcranmer-intel created this revision.
Herald added a subscriber: ormris.
Herald added a project: All.
jcranmer-intel requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127221

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/print-pipeline-passes.c


Index: clang/test/CodeGen/print-pipeline-passes.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/print-pipeline-passes.c
@@ -0,0 +1,9 @@
+// Test that -print-pipeline-passes works in Clang
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null -mllvm -print-pipeline-passes -O0 %s 2>&1 | FileCheck %s
+
+// Don't try to check all passes, just a fire to make sure that something is
+// actually printed.
+// CHECK: always-inline
+// CHECK-SAME: BitcodeWriterPass
+void Foo(void) {}
Index: clang/lib/CodeGen/BackendUtil.cpp
===================================================================
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -96,6 +96,7 @@
 
 namespace llvm {
 extern cl::opt<bool> DebugInfoCorrelate;
+extern cl::opt<bool> PrintPipelinePasses;
 }
 
 namespace {
@@ -958,6 +959,17 @@
     break;
   }
 
+  // Print a textual, '-passes=' compatible, representation of pipeline if
+  // requested.
+  if (PrintPipelinePasses) {
+    MPM.printPipeline(outs(), [&PIC](StringRef ClassName) {
+      auto PassName = PIC.getPassNameForClassName(ClassName);
+      return PassName.empty() ? ClassName : PassName;
+    });
+    outs() << "\n";
+    return;
+  }
+
   // Now that we have all of the passes ready, run them.
   {
     PrettyStackTraceString CrashInfo("Optimizer");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127221.434830.patch
Type: text/x-patch
Size: 1399 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220607/c257715e/attachment.bin>


More information about the cfe-commits mailing list