[llvm] [BasicAA] Treat IntToPtr(Argument) similarly to Argument in relation to function-local objects. (PR #134505)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 7 12:29:31 PDT 2025


================
@@ -24,21 +24,21 @@ define void @test2(i64 %Q_as_int) {
   ret void
 }
 
-; Verify that escaped noalias parameter may alias inttoptr
+; Verify that escaped noalias parameter are no alias inttoptr
 define void @test3(ptr noalias %P, i64 %Q_as_int) {
   ; CHECK-LABEL: Function: test3:
-  ; CHECK: MayAlias:	i8* %P, i8* %Q
+  ; CHECK: NoAlias:	i8* %P, i8* %Q
----------------
nikic wrote:

I don't really see how we could accept this, regardless of noalias. Maybe to make it more explicit, we expect that the following code is not UB:

```
test(int * restrict P, uintptr_t Q_as_int) {
    if ((uintptr_t)P == Q_as_int) {
        (int *)Q_as_int = 1; // Can alias P.
    }
}
```

Here `(uintptr_t)P` exposes the provenance of `P` and then `(int *)Q_as_int` chooses it.

(In the test case, the call to `@escape` stands in for the provenance exposure.)

https://github.com/llvm/llvm-project/pull/134505


More information about the llvm-commits mailing list