[llvm] [llvm] Fix possible null dereference in Transforms/Scalar (PR #157461)

Daniel Kuts via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 8 06:28:33 PDT 2025


https://github.com/apach301 created https://github.com/llvm/llvm-project/pull/157461

Fixes #157450

>From 3f873d194c7bd0bfb09c8c3024b2e0d2e843a64e Mon Sep 17 00:00:00 2001
From: Daniil Kutz <kutz at ispras.ru>
Date: Mon, 8 Sep 2025 16:13:34 +0300
Subject: [PATCH] [llvm] Fix possible null dereference in Transforms/Scalar

---
 llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
index 434b55868c99d..33f06e2abe801 100644
--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
@@ -521,7 +521,7 @@ struct MainSwitch {
 
     Instruction *SIUse = dyn_cast<Instruction>(SI->user_back());
     // The use of the select inst should be either a phi or another select.
-    if (!SIUse && !(isa<PHINode>(SIUse) || isa<SelectInst>(SIUse)))
+    if (SIUse && !(isa<PHINode>(SIUse) || isa<SelectInst>(SIUse)))
       return false;
 
     BasicBlock *SIBB = SI->getParent();



More information about the llvm-commits mailing list