[llvm] [SelectOptimize] Emit Fatal Error instead of Asserting on null PSI (PR #192871)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 19 13:50:12 PDT 2026


https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/192871

SelectOptimize expects to have PSI available which will normally be available if the pipeline is set up correctly to require ProfileSummaryInfo at the beginning. However, we do not want to assert if someone sets up the pipeline incorrectly, instead reporting a fatal usage error.

Fixes #192759.

>From 652a0acf289dbc4e6d303924190ed35f79ae22ef Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Sun, 19 Apr 2026 20:48:34 +0000
Subject: [PATCH] [SelectOptimize] Emit Fatal Error instead of Asserting on
 null PSI

SelectOptimize expects to have PSI available which will normally be
available if the pipeline is set up correctly to require
ProfileSummaryInfo at the beginning. However, we do not want to assert
if someone sets up the pipeline incorrectly, instead reporting a fatal
usage error.

Fixes #192759.
---
 llvm/lib/CodeGen/SelectOptimize.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/CodeGen/SelectOptimize.cpp b/llvm/lib/CodeGen/SelectOptimize.cpp
index 4c6a20910f9af..5ac6758624438 100644
--- a/llvm/lib/CodeGen/SelectOptimize.cpp
+++ b/llvm/lib/CodeGen/SelectOptimize.cpp
@@ -369,7 +369,9 @@ PreservedAnalyses SelectOptimizeImpl::run(Function &F,
 
   PSI = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F)
             .getCachedResult<ProfileSummaryAnalysis>(*F.getParent());
-  assert(PSI && "This pass requires module analysis pass `profile-summary`!");
+  if (!PSI)
+    reportFatalUsageError("This pass requires the profile-summary module "
+                          "analysis to be available.");
   BFI = &FAM.getResult<BlockFrequencyAnalysis>(F);
 
   // When optimizing for size, selects are preferable over branches.



More information about the llvm-commits mailing list