Skip to content

Commit baedb1a

Browse files
author
git apple-llvm automerger
committed
Merge commit 'f36b9baaf221' from apple/main into swift/next
2 parents bed117e + f36b9ba commit baedb1a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

llvm/lib/Transforms/Utils/GlobalStatus.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ static bool analyzeGlobalAux(const Value *V, GlobalStatus &GS,
136136
GS.StoredType = GlobalStatus::Stored;
137137
}
138138
}
139-
} else if (isa<BitCastInst>(I) || isa<GetElementPtrInst>(I)) {
139+
} else if (isa<BitCastInst>(I) || isa<GetElementPtrInst>(I) ||
140+
isa<AddrSpaceCastInst>(I)) {
140141
// Skip over bitcasts and GEPs; we don't care about the type or offset
141142
// of the pointer.
142143
if (analyzeGlobalAux(I, GS, VisitedUsers))

llvm/test/Transforms/GlobalOpt/unnamed-addr.ll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
@c = internal global i32 0, align 4
66
@d = internal constant [4 x i8] c"foo\00", align 1
77
@e = linkonce_odr global i32 0
8+
@f = internal addrspace(3) global float undef, align 4
89

910
; CHECK: @a = internal global i32 0, align 4
1011
; CHECK: @b = internal global i32 0, align 4
1112
; CHECK: @c = internal unnamed_addr global i32 0, align 4
1213
; CHECK: @d = internal unnamed_addr constant [4 x i8] c"foo\00", align 1
1314
; CHECK: @e = linkonce_odr local_unnamed_addr global i32 0
15+
; CHECK: @f = internal unnamed_addr addrspace(3) global float undef, align 4
1416

1517
; CHECK: define internal fastcc void @used_internal() unnamed_addr {
1618
define internal void @used_internal() {
@@ -72,3 +74,15 @@ entry:
7274
%tmp1 = load i32, i32* @c, align 4
7375
ret i32 %tmp1
7476
}
77+
78+
define float @use_addrspace_cast_for_load() {
79+
%p = addrspacecast float addrspace(3)* @f to float*
80+
%v = load float, float* %p
81+
ret float %v
82+
}
83+
84+
define void @use_addrspace_cast_for_store(float %x) {
85+
%p = addrspacecast float addrspace(3)* @f to float*
86+
store float %x, float* %p
87+
ret void
88+
}

0 commit comments

Comments
 (0)