[llvm] Attributor: Don't rely on use_empty for constants (PR #137218)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 24 10:50:53 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
This allows inferring noalias on a null argument parameter. This
avoids a non-NFC diff in a future change.
---
Full diff: https://github.com/llvm/llvm-project/pull/137218.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/IPO/AttributorAttributes.cpp (+1-1)
- (modified) llvm/test/Transforms/Attributor/issue87856.ll (+1-1)
``````````diff
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)
``````````
</details>
https://github.com/llvm/llvm-project/pull/137218
More information about the llvm-commits
mailing list