[clang] [llvm] [OptBisect][IR] Adding a new OptPassGate for disabling passes via name (PR #145059)
Mircea Trofin via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 23 10:26:31 PDT 2025
================
@@ -51,10 +51,59 @@ bool OptBisect::shouldRunPass(const StringRef PassName,
int CurBisectNum = ++LastBisectNum;
bool ShouldRun = (BisectLimit == -1 || CurBisectNum <= BisectLimit);
if (OptBisectVerbose)
- printPassMessage(PassName, CurBisectNum, IRDescription, ShouldRun);
+ printBisectPassMessage(PassName, CurBisectNum, IRDescription, ShouldRun);
return ShouldRun;
}
const int OptBisect::Disabled;
-OptPassGate &llvm::getGlobalPassGate() { return getOptBisector(); }
+static OptDisable &getOptDisabler() {
+ static OptDisable OptDisabler;
+ return OptDisabler;
+}
+
+static cl::opt<std::string> OptDisablePass(
+ "opt-disable", cl::Hidden, cl::init(""), cl::Optional,
+ cl::cb<void, std::string>([](std::string Passes) {
+ getOptDisabler().initMap();
+ getOptDisabler().setDisabled(Passes);
+ }),
+ cl::desc("Optimization pass(es) to disable (comma separated)"));
+
+static cl::opt<bool>
+ OptDisableVerbose("opt-disable-verbose",
----------------
mtrofin wrote:
I was confused by the flag when I read the commit message, I think I understand it now: it's verbosity *of* the opt-disable "thing". I read it initially as "disable verbosity" but everything says how it enables verbosity, except for the flag name itself :)
the best suggestion I can come with would be `opt-disable-enable-verbosity`. Not proud of it, but thinking that at least the reader is given pause to read the docstring of the flag.
Also, maybe say in the doc string that you're affecting the "opt-disable" pass. Then the dissonance may solve itself (for the reader).
https://github.com/llvm/llvm-project/pull/145059
More information about the cfe-commits
mailing list