<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68270>68270</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Inferring function argument attributes incorrectly ignoes (sets `readnone`) intrinsics that return aliasing pointers
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
krzysz00
</td>
</tr>
</table>
<pre>
# Steps to reproduce
Run `opt -passes='default<O3>'` on the following LLVM IR (I haven't managed to scope this down, but I think the function attributor has something to do with it)
```llvm
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8"
target triple = "amdgcn--"
define amdgpu_kernel void @buffer_creation_attributor_fail(ptr noalias %x, ptr noalias %y) {
%x.rsrc = call ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr %x, i16 0, i32 4, i32 822243328)
%y.rsrc = call ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr %y, i16 0, i32 4, i32 822243328)
%v = call float @llvm.amdgcn.raw.ptr.buffer.load.f32(ptr addrspace(8) %x.rsrc, i32 0, i32 0, i32 0)
call void @llvm.amdgcn.raw.ptr.buffer.store.f32(float %v, ptr addrspace(8) %y.rsrc, i32 0, i32 0, i32 0)
ret void
}
declare ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr nocapture readnone, i16, i32, i32) #0
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: read)
declare float @llvm.amdgcn.raw.ptr.buffer.load.f32(ptr addrspace(8) nocapture readonly, i32, i32, i32 immarg) #1
; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: write)
declare void @llvm.amdgcn.raw.ptr.buffer.store.f32(float, ptr addrspace(8) nocapture writeonly, i32, i32, i32 immarg) #2
attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: read) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: write) }
```
# Expected results
```llvm
define amdgpu_kernel void @buffer_creation_attributor_fail(ptr noalias nocapture readonly %x, ptr noalias nocapture writeonly %y) local_unnamed_addr #0 {
...
}
```
Note the `readonly` and `writeonly` attributions
# Actual results
```llvm
define amdgpu_kernel void @buffer_creation_attributor_fail(ptr noalias nocapture readnone %x, ptr noalias nocapture readnone %y) local_unnamed_addr #0 {
...
}
```
Note that the function arguments are incorrectly labelled `readnone`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEV9-PozYQ_mucFwsENhB4yEP2clutdG2lO6mvK4MnxF1jI9uQy_31lQ1ks9lce3fda6XIgH_M980347HDrBWtAtig_A7luxUb3EGbzZP5crJfkmRVa37aIELxJwe9xU5jA73RfGgAJTuUbKf246AwKhLdOxz1zFqwiO4QWXPYs0E6RN_9ThF9j8gaFQnWCrsD4L2WUh-FavGHD3_8ih8-YkTKB3xgIyhE1g53TLEWuEe1je4Bu4OwmOujQuQdrgeHH3yXeprMDapxQivMnDOiHpw2-MAstroDP6v1drjGR-EOWDhEqtmDIpl-Uo7d1OWYacFhzhyT7KQHhxHdYUQIRD2i2yILTdSnlx8E0S2dmqinlx_Z5bT8cqS4_Fgjuk2LBNEtyYtz60dKP0LmNhKLrTEtwpJoJNk0c1yMjVk5z6mKedmYVmSyGo1ngGjMU9-bpyQa0yTY8Y9oJEkw4R-RCmaLLPpESbTNo1_SSAlEt55xiQh5oZozopewKMY63jYqis6zppbDXijAfrQfHp_AKJB41IJjlCX1sN-DeWwMMB_Qx-eAPu6ZkIiUvTNYaSYFsxiR_LPPh6u-EyIVRus7PAGGabGxp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