Skip to content

Commit 6d35ec2

Browse files
authored
ObjCARC: Fix regression from using ConstantData uselists (#139609)
Fixes regression after 9383fb2
1 parent c78e65c commit 6d35ec2

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ bool ProvenanceAnalysis::relatedPHI(const PHINode *A,
7878
/// Test if the value of P, or any value covered by its provenance, is ever
7979
/// stored within the function (not counting callees).
8080
static bool IsStoredObjCPointer(const Value *P) {
81+
if (!P->hasUseList())
82+
return true; // Assume the worst for a constant pointer.
83+
8184
SmallPtrSet<const Value *, 8> Visited;
8285
SmallVector<const Value *, 8> Worklist;
8386
Worklist.push_back(P);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -S -passes=objc-arc < %s | FileCheck %s
3+
4+
target triple = "x86_64-apple-macosx11.0.0"
5+
6+
declare ptr @llvm.objc.retain(ptr returned) #0
7+
declare void @llvm.objc.release(ptr) #0
8+
9+
declare ptr @foo(ptr)
10+
11+
define i1 @_ZN8GrMtlGpu20readOrTransferPixelsEP9GrSurface7SkIRect11GrColorTypePU19objcproto9MTLBuffer11objc_objectmmm(ptr %this) #1 {
12+
; CHECK-LABEL: define i1 @_ZN8GrMtlGpu20readOrTransferPixelsEP9GrSurface7SkIRect11GrColorTypePU19objcproto9MTLBuffer11objc_objectmmm(
13+
; CHECK-SAME: ptr [[THIS:%.*]]) #[[ATTR1:[0-9]+]] {
14+
; CHECK-NEXT: [[ENTRY:.*]]:
15+
; CHECK-NEXT: [[RETAIN:%.*]] = tail call ptr @llvm.objc.retain(ptr [[THIS]]) #[[ATTR0:[0-9]+]]
16+
; CHECK-NEXT: br i1 false, label %[[CLEANUP66:.*]], label %[[IF_END30:.*]]
17+
; CHECK: [[IF_END30]]:
18+
; CHECK-NEXT: [[LD_PTR:%.*]] = load ptr, ptr [[THIS]], align 8
19+
; CHECK-NEXT: call void @foo(ptr [[LD_PTR]])
20+
; CHECK-NEXT: br label %[[CLEANUP66]]
21+
; CHECK: [[CLEANUP66]]:
22+
; CHECK-NEXT: [[MTLTEXTURE_1103:%.*]] = phi ptr [ null, %[[ENTRY]] ], [ [[THIS]], %[[IF_END30]] ]
23+
; CHECK-NEXT: tail call void @llvm.objc.release(ptr [[MTLTEXTURE_1103]]) #[[ATTR0]]
24+
; CHECK-NEXT: ret i1 false
25+
;
26+
entry:
27+
%retain = tail call ptr @llvm.objc.retain(ptr %this)
28+
br i1 false, label %cleanup66, label %if.end30
29+
30+
if.end30: ; preds = %entry
31+
%ld.ptr = load ptr, ptr %this, align 8
32+
call void @foo(ptr %ld.ptr)
33+
br label %cleanup66
34+
35+
cleanup66: ; preds = %if.end30, %entry
36+
%mtlTexture.1103 = phi ptr [ null, %entry ], [ %this, %if.end30 ]
37+
tail call void @llvm.objc.release(ptr %mtlTexture.1103)
38+
ret i1 false
39+
}
40+
41+
attributes #0 = { nounwind }
42+
attributes #1 = { null_pointer_is_valid }

0 commit comments

Comments
 (0)