Issue 131168
Summary [AA] Return-only captures can regress results
Labels llvm:optimizations, missed-optimization
Assignees
Reporter nikic
    ```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`.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to