[PredicateInfo] Fix crash on nonnull assume taking a constant - #180440
Merged
Conversation
Member
|
@llvm/pr-subscribers-llvm-transforms Author: Nikolas Klauser (philnik777) ChangesFull diff: https://github.com/llvm/llvm-project/pull/180440.diff 2 Files Affected:
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
}
|
nikic
approved these changes
Feb 8, 2026
rishabhmadan19
pushed a commit
to rishabhmadan19/llvm-project
that referenced
this pull request
Feb 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.