Skip to content

[PredicateInfo] Fix crash on nonnull assume taking a constant - #180440

Merged
philnik777 merged 1 commit into
llvm:mainfrom
philnik777:fix_sccp_crash
Feb 9, 2026
Merged

[PredicateInfo] Fix crash on nonnull assume taking a constant#180440
philnik777 merged 1 commit into
llvm:mainfrom
philnik777:fix_sccp_crash

Conversation

@philnik777

Copy link
Copy Markdown
Contributor

No description provided.

@llvmbot

llvmbot commented Feb 8, 2026

Copy link
Copy Markdown
Member

@llvm/pr-subscribers-llvm-transforms

Author: Nikolas Klauser (philnik777)

Changes

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

2 Files Affected:

  • (modified) llvm/lib/Transforms/Utils/PredicateInfo.cpp (+1-1)
  • (modified) llvm/test/Transforms/SCCP/assume-operand-bundles.ll (+8)
diff --git a/llvm/lib/Transforms/Utils/PredicateInfo.cpp b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
index 79ef0a608b35e..a5fff94b60d18 100644
--- a/llvm/lib/Transforms/Utils/PredicateInfo.cpp
+++ b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
@@ -365,7 +365,7 @@ void PredicateInfoBuilder::processAssume(
   if (II->hasOperandBundles()) {
     for (auto BOI : II->bundle_op_infos()) {
       if (RetainedKnowledge RK = getKnowledgeFromBundle(*II, BOI)) {
-        if (RK.AttrKind == Attribute::NonNull)
+        if (RK.AttrKind == Attribute::NonNull && shouldRename(RK.WasOn))
           addInfoFor(OpsToRename, RK.WasOn,
                      new (Allocator) PredicateBundleAssume(RK.WasOn, II,
                                                            Attribute::NonNull));
diff --git a/llvm/test/Transforms/SCCP/assume-operand-bundles.ll b/llvm/test/Transforms/SCCP/assume-operand-bundles.ll
index 6f86fc331422d..7485b9e289393 100644
--- a/llvm/test/Transforms/SCCP/assume-operand-bundles.ll
+++ b/llvm/test/Transforms/SCCP/assume-operand-bundles.ll
@@ -124,5 +124,13 @@ false1:
   %cf4 = icmp ne ptr null, %v
   call void @use(i1 %cf4)
   ret void
+}
+
+define void @check_for_constant() {
+; CHECK-LABEL: define void @check_for_constant() {
+; CHECK-NEXT:    call void @llvm.assume(i1 true) [ "nonnull"(ptr null) ]
+; CHECK-NEXT:    ret void
+;
+  call void @llvm.assume(i1 true) [ "nonnull"(ptr null) ]
   ret void
 }

@philnik777
philnik777 merged commit 6c31bf0 into llvm:main Feb 9, 2026
12 checks passed
@philnik777
philnik777 deleted the fix_sccp_crash branch February 9, 2026 08:18
rishabhmadan19 pushed a commit to rishabhmadan19/llvm-project that referenced this pull request Feb 9, 2026
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.

3 participants