[llvm] [opt] Do not exit on first emitError (PR #194858)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 08:52:05 PDT 2026


================
@@ -238,6 +240,22 @@ static cl::opt<bool> DisableLoopUnrolling(
     "disable-loop-unrolling",
     cl::desc("Disable loop unrolling in all relevant passes"), cl::init(false));
 
+bool OptDiagnosticHandler::handleDiagnostics(const DiagnosticInfo &DI) {
+  DiagnosticHandler::handleDiagnostics(DI);
+  // Mirror the filtering performed by LLVMContext::diagnose's default path:
+  // optimization remarks are gated by the -pass-remarks* flags (isEnabled),
+  // and verbose remarks additionally require hotness data.
+  if (auto *Remark = dyn_cast<DiagnosticInfoOptimizationBase>(&DI))
+    if (!Remark->isEnabled() || (Remark->isVerbose() && !Remark->getHotness()))
+      return true;
+
+  DiagnosticPrinterRawOStream DP(errs());
+  errs() << LLVMContext::getDiagnosticMessagePrefix(DI.getSeverity()) << ": ";
+  DI.print(DP);
+  errs() << "\n";
----------------
arsenm wrote:

```suggestion
  errs() << '\n';
```

https://github.com/llvm/llvm-project/pull/194858


More information about the llvm-commits mailing list