Skip to content

Commit 69f2de1

Browse files
committed
[InstCombine] Add test for inttoptr of ptrtoaddr (NFC)
And document that we're intentionally not folding this case. For inttoptr of ptrtoint this is controlled by the -disable-i2p-p2i-opt flag, but I don't think there is a need to replicate this known unsound fold for ptrtoaddr, given their different usage characteristics.
1 parent 9abb344 commit 69f2de1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

llvm/test/Transforms/InstCombine/ptrtoaddr.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,13 @@ define i32 @ptrtoaddr_gep_sub_addrsize() {
9999
;
100100
ret i32 ptrtoaddr (ptr addrspace(1) getelementptr (i8, ptr addrspace(1) @g.as1, i32 sub (i32 0, i32 ptrtoaddr (ptr addrspace(1) @g2.as1 to i32))) to i32)
101101
}
102+
103+
; Don't fold inttoptr of ptrtoaddr away. inttoptr will pick a previously
104+
; exposed provenance, which is not necessarily that of @g (especially as
105+
; ptrtoaddr does not expose the provenance.)
106+
define ptr @inttoptr_of_ptrtoaddr() {
107+
; CHECK-LABEL: define ptr @inttoptr_of_ptrtoaddr() {
108+
; CHECK-NEXT: ret ptr inttoptr (i64 ptrtoaddr (ptr @g to i64) to ptr)
109+
;
110+
ret ptr inttoptr (i64 ptrtoaddr (ptr @g to i64) to ptr)
111+
}

0 commit comments

Comments
 (0)