[PATCH] D127221: [Clang] Enable -print-pipeline-passes in clang.
Joshua Cranmer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 12 08:07:49 PDT 2023
jcranmer-intel updated this revision to Diff 556574.
jcranmer-intel added a comment.
Replace verify with annotation-remarks
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127221/new/
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 few to make sure that something is
+// actually printed.
+// CHECK: always-inline
+// CHECK-SAME: annotation-remarks
+void Foo(void) {}
Index: clang/lib/CodeGen/BackendUtil.cpp
===================================================================
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -91,6 +91,7 @@
namespace llvm {
extern cl::opt<bool> DebugInfoCorrelate;
+extern cl::opt<bool> PrintPipelinePasses;
// Experiment to move sanitizers earlier.
static cl::opt<bool> ClSanitizeOnOptimizerEarlyEP(
@@ -1090,6 +1091,17 @@
TheModule->addModuleFlag(Module::Error, "UnifiedLTO", uint32_t(1));
}
+ // 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");
@@ -1127,6 +1139,13 @@
return;
}
+ // If -print-pipeline-passes is requested, don't run the legacy pass manager.
+ // FIXME: when codegen is switched to use the new pass manager, it should also
+ // emit pass names here.
+ if (PrintPipelinePasses) {
+ return;
+ }
+
{
PrettyStackTraceString CrashInfo("Code generation");
llvm::TimeTraceScope TimeScope("CodeGenPasses");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127221.556574.patch
Type: text/x-patch
Size: 1944 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230912/be18cf99/attachment-0001.bin>
More information about the cfe-commits
mailing list