Skip to content

Commit 4030b27

Browse files
committed
[Loads] Handle ptrtoaddr in isPointerUseReplaceable()
Unlike the ptrtoint case, this is actually correct for ptrtoaddr.
1 parent e43da72 commit 4030b27

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

llvm/lib/Analysis/Loads.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,9 @@ static bool isPointerUseReplacable(const Use &U) {
812812
auto *User = Worklist.pop_back_val();
813813
if (!Visited.insert(User).second)
814814
continue;
815-
if (isa<ICmpInst, PtrToIntInst>(User))
815+
// FIXME: The PtrToIntInst case here is not strictly correct, as it
816+
// changes which provenance is exposed.
817+
if (isa<ICmpInst, PtrToIntInst, PtrToAddrInst>(User))
816818
continue;
817819
if (isa<PHINode, SelectInst>(User))
818820
Worklist.append(User->user_begin(), User->user_end());

llvm/test/Transforms/GVN/assume-equal.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ define i64 @assume_ptr_eq_different_prov_does_not_matter_ptrtoaddr(ptr %p, ptr %
393393
; CHECK-SAME: ptr [[P:%.*]], ptr [[P2:%.*]]) {
394394
; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[P]], [[P2]]
395395
; CHECK-NEXT: call void @llvm.assume(i1 [[CMP]])
396-
; CHECK-NEXT: [[INT:%.*]] = ptrtoaddr ptr [[P2]] to i64
396+
; CHECK-NEXT: [[INT:%.*]] = ptrtoaddr ptr [[P]] to i64
397397
; CHECK-NEXT: ret i64 [[INT]]
398398
;
399399
%cmp = icmp eq ptr %p, %p2

0 commit comments

Comments
 (0)