[llvm] [OptBisect] Add an option to disable print of pass message (PR #101065)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 11:58:37 PDT 2024


https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/101065

The print could take a huge amount of time if there are millions of optimization
passes running. This patch simply adds an option to disable the print.

>From abcbb8e09371ab47571520fa0bcc6dd2e2186f65 Mon Sep 17 00:00:00 2001
From: Shilei Tian <i at tianshilei.me>
Date: Mon, 29 Jul 2024 14:55:58 -0400
Subject: [PATCH] [OptBisect] Add an option to disable print of pass message

The print could take a huge amount of time if there are millions of optimization
passes running. This patch simply adds an option to disable the print.
---
 llvm/lib/IR/OptBisect.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/IR/OptBisect.cpp b/llvm/lib/IR/OptBisect.cpp
index 893a5e59c86a6..1a5fc1411ed42 100644
--- a/llvm/lib/IR/OptBisect.cpp
+++ b/llvm/lib/IR/OptBisect.cpp
@@ -32,6 +32,11 @@ static cl::opt<int> OptBisectLimit("opt-bisect-limit", cl::Hidden,
                                    }),
                                    cl::desc("Maximum optimization to perform"));
 
+static cl::opt<bool> OptBisectPrintPassMessage(
+    "opt-bisect-print-pass-message",
+    cl::desc("Whether print pass message when opt-bisect-limit is set."),
+    cl::Hidden, cl::init(true), cl::Optional);
+
 static void printPassMessage(const StringRef &Name, int PassNum,
                              StringRef TargetDesc, bool Running) {
   StringRef Status = Running ? "" : "NOT ";
@@ -45,7 +50,8 @@ bool OptBisect::shouldRunPass(const StringRef PassName,
 
   int CurBisectNum = ++LastBisectNum;
   bool ShouldRun = (BisectLimit == -1 || CurBisectNum <= BisectLimit);
-  printPassMessage(PassName, CurBisectNum, IRDescription, ShouldRun);
+  if (OptBisectPrintPassMessage)
+    printPassMessage(PassName, CurBisectNum, IRDescription, ShouldRun);
   return ShouldRun;
 }
 



More information about the llvm-commits mailing list