[llvm] [llubi] Add support for exposed provenance (PR #200596)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 02:59:21 PDT 2026


================
@@ -7,11 +7,19 @@ define void @main() {
   %ptr1 = inttoptr i64 0 to ptr
   %ptr2 = inttoptr i8 255 to ptr
   %ptr3 = inttoptr i128 -1 to ptr
+  %alloc = alloca i32
+  %off = ptrtoint ptr %alloc to i64
+  %gep = getelementptr i8, ptr %ptr1, i64 %off
+  %cast = inttoptr i64 %off to ptr
   ret void
 }
 ; CHECK: Entering function: main
 ; CHECK-NEXT:   %ptr1 = inttoptr i64 0 to ptr => ptr 0x0 [nullary]
 ; CHECK-NEXT:   %ptr2 = inttoptr i8 -1 to ptr => ptr 0xFF [nullary]
 ; CHECK-NEXT:   %ptr3 = inttoptr i128 -1 to ptr => ptr 0xFFFFFFFFFFFFFFFF [nullary]
+; CHECK-NEXT:   %alloc = alloca i32, align 4 => ptr 0x8 [alloc]
+; CHECK-NEXT:   %off = ptrtoint ptr %alloc to i64 => i64 8
+; CHECK-NEXT:   %gep = getelementptr i8, ptr %ptr1, i64 %off => ptr 0x8 [nullary]
+; CHECK-NEXT:   %cast = inttoptr i64 %off to ptr => ptr 0x8 [wildcard]
----------------
nikic wrote:

Missing test coverage for actually accessing the wildcard pointer?

BaseAddress is never assigned, so accessing a wildcard pointer multiple times currently results in UB:
```
define i32 @main() {
  %alloc = alloca i32
  store i32 42, ptr %alloc
  %off = ptrtoint ptr %alloc to i64
  %p   = inttoptr i64 %off to ptr
  %v1  = load i32, ptr %p
  %v2  = load i32, ptr %p   ; UB
  %sum = add i32 %v1, %v2
  ret i32 %sum
}
```

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


More information about the llvm-commits mailing list