<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/131168>131168</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AA] Return-only captures can regress results
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:optimizations,
missed-optimization
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nikic
</td>
</tr>
</table>
<pre>
```llvm
; RUN: opt -passes=aa-eval -print-all-alias-modref-info < %s
declare ptr @callee(ptr)
define void @test1(ptr noalias %a, ptr noalias %b) {
%p = call ptr @callee(ptr writeonly captures(ret: address, provenance) %a, ptr captures(none) %b) memory(argmem: readwrite)
load i32, ptr %p
ret void
}
define void @test2(ptr noalias %a, ptr noalias %b) {
%p = call ptr @callee(ptr writeonly %a, ptr captures(none) %b) memory(argmem: readwrite)
load i32, ptr %p
ret void
}
```
Results in:
```
Function: test1: 1 pointers, 1 call sites
Both ModRef: Ptr: i32* %p <-> %p = call ptr @callee(ptr writeonly captures(ret: address, provenance) %a, ptr captures(none) %b) #0
Function: test2: 1 pointers, 1 call sites
Just Mod: Ptr: i32* %p <-> %p = call ptr @callee(ptr writeonly %a, ptr captures(none) %b) #0
```
The problem here is that without the `captures(ret: address, provenance)`, the call result is an escape source, so we know it does not alias with the non-escaping `%b` and thus only the Mod effect on the `%a` parameter is relevant.
With the return-only capture it's no longer an escape source, and we currently are no longer able to determine it cannot alias with `%b`.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEVU2L6zYX_jXHm4ODLcWJs_DCk7xZvHBLGVq6lu3jWL2yZKTjhOmvL1Im3DCdwi20XAiY5Hw8H34iqRD0xRI1UL1AdcrUypPzjdVfdZ91bnhrYFfcP8ZcZyhakC_4-utPIFt0C2O-qBAogDwpldNVGcwXry3nyphcGa1CPrvB05hrOzoEeUQQVYCiHag3yhMu7BG2Ra-MIQJRL-xBHCJS7Bm1Jbw6Pc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