-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Attributor: Don't rely on use_empty for constants #137218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
arsenm
merged 1 commit into
main
from
users/arsenm/attributor/do-not-rely-on-constants-with-use-empty
Apr 24, 2025
Merged
Attributor: Don't rely on use_empty for constants #137218
arsenm
merged 1 commit into
main
from
users/arsenm/attributor/do-not-rely-on-constants-with-use-empty
Apr 24, 2025
Conversation
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
This allows inferring noalias on a null argument parameter. This avoids a non-NFC diff in a future change.
@llvm/pr-subscribers-llvm-transforms Author: Matt Arsenault (arsenm) ChangesThis allows inferring noalias on a null argument parameter. This Full diff: https://github.com/llvm/llvm-project/pull/137218.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index ac56df3823e20..1032dede7cb36 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -5746,7 +5746,7 @@ bool AANoCapture::isImpliedByIR(Attributor &A, const IRPosition &IRP,
assert(ImpliedAttributeKind == Attribute::Captures &&
"Unexpected attribute kind");
Value &V = IRP.getAssociatedValue();
- if (!IRP.isArgumentPosition())
+ if (!isa<Constant>(V) && !IRP.isArgumentPosition())
return V.use_empty();
// You cannot "capture" null in the default address space.
diff --git a/llvm/test/Transforms/Attributor/issue87856.ll b/llvm/test/Transforms/Attributor/issue87856.ll
index 4990ef909dfaa..592ec33a31369 100644
--- a/llvm/test/Transforms/Attributor/issue87856.ll
+++ b/llvm/test/Transforms/Attributor/issue87856.ll
@@ -4,7 +4,7 @@
define void @null_ptr_is_valid_call_with_null() #0 {
; CHECK-LABEL: define void @null_ptr_is_valid_call_with_null(
; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
-; CHECK-NEXT: call void @store_as0(ptr nofree noundef writeonly null) #[[ATTR4:[0-9]+]]
+; CHECK-NEXT: call void @store_as0(ptr noalias nofree noundef writeonly null) #[[ATTR4:[0-9]+]]
; CHECK-NEXT: ret void
;
call void @store_as0(ptr null)
|
shiltian
approved these changes
Apr 24, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
This allows inferring noalias on a null argument parameter. This avoids a non-NFC diff in a future change.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
This allows inferring noalias on a null argument parameter. This avoids a non-NFC diff in a future change.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
This allows inferring noalias on a null argument parameter. This avoids a non-NFC diff in a future change.
Ankur-0429
pushed a commit
to Ankur-0429/llvm-project
that referenced
this pull request
May 9, 2025
This allows inferring noalias on a null argument parameter. This avoids a non-NFC diff in a future change.
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.
This allows inferring noalias on a null argument parameter. This
avoids a non-NFC diff in a future change.