[llvm] [IR] Disable unsound inttoptr(ptrtoint(p)) to p fold (PR #161662)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 2 11:10:52 PDT 2025


================
@@ -350,6 +351,9 @@ define i1 @test11() {
 ; CHECK-NEXT:    [[D:%.*]] = call i1 @test11a()
 ; CHECK-NEXT:    br i1 [[D]], label [[ONE]], label [[END]]
 ; CHECK:       end:
+; CHECK-NEXT:    [[I:%.*]] = ptrtoint ptr [[A]] to i64
+; CHECK-NEXT:    [[G:%.*]] = inttoptr i64 [[I]] to ptr
+; CHECK-NEXT:    store i32 10, ptr [[G]], align 4
----------------
efriedma-quic wrote:

How does that argument interact with restrict pointers?  (Say you have a pointer `@g`, and a restrict argument `%r` equal to that pointer, and a ptrtoint of both of those.  Can you replace a ptrtoint/inttoptr of `@g` with `@g`, or only `%r`?)

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


More information about the llvm-commits mailing list