Skip to content

Conversation

apach301
Copy link
Contributor

@apach301 apach301 commented Sep 8, 2025

Fixes #157450

@llvmbot
Copy link
Member

llvmbot commented Sep 8, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Daniel Kuts (apach301)

Changes

Fixes #157450


Full diff: https://github.com/llvm/llvm-project/pull/157461.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp (+1-1)
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();

@nikic nikic requested a review from XChy September 8, 2025 13:29
Co-authored-by: Nikita Popov <github@npopov.com>
@XChy XChy changed the title [llvm] Fix possible null dereference in Transforms/Scalar [DFAJumpThreading] Fix possible null dereference Sep 8, 2025
Copy link
Member

@XChy XChy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. LGTM.

@XChy XChy merged commit 3119945 into llvm:main Sep 8, 2025
9 checks passed
@apach301 apach301 deleted the llvm-transforms-null-dereference branch September 15, 2025 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible NULL dereference in llvm/Transforms/Scalar
4 participants