Skip to content

Commit 37b135c

Browse files
authored
Attributor: Don't rely on use_empty for constants (#137218)
This allows inferring noalias on a null argument parameter. This avoids a non-NFC diff in a future change.
1 parent 1636f4a commit 37b135c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5746,7 +5746,7 @@ bool AANoCapture::isImpliedByIR(Attributor &A, const IRPosition &IRP,
57465746
assert(ImpliedAttributeKind == Attribute::Captures &&
57475747
"Unexpected attribute kind");
57485748
Value &V = IRP.getAssociatedValue();
5749-
if (!IRP.isArgumentPosition())
5749+
if (!isa<Constant>(V) && !IRP.isArgumentPosition())
57505750
return V.use_empty();
57515751

57525752
// You cannot "capture" null in the default address space.

llvm/test/Transforms/Attributor/issue87856.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
define void @null_ptr_is_valid_call_with_null() #0 {
55
; CHECK-LABEL: define void @null_ptr_is_valid_call_with_null(
66
; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
7-
; CHECK-NEXT: call void @store_as0(ptr nofree noundef writeonly null) #[[ATTR4:[0-9]+]]
7+
; CHECK-NEXT: call void @store_as0(ptr noalias nofree noundef writeonly null) #[[ATTR4:[0-9]+]]
88
; CHECK-NEXT: ret void
99
;
1010
call void @store_as0(ptr null)

0 commit comments

Comments
 (0)