Skip to content

Commit 648c9bc

Browse files
gbaraldiKristofferC
authored andcommitted
Backport of 088bb90
(Fix removal of globals with addrspaces in removeAddrspaces (#58322))
1 parent 2d5d191 commit 648c9bc

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/llvm-remove-addrspaces.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ bool removeAddrspaces(Module &M, AddrspaceRemapFunction ASRemapper)
271271
Name,
272272
(GlobalVariable *)nullptr,
273273
GV->getThreadLocalMode(),
274-
GV->getType()->getAddressSpace());
274+
cast<PointerType>(TypeRemapper.remapType(GV->getType()))->getAddressSpace());
275275
NGV->copyAttributesFrom(GV);
276276
VMap[GV] = NGV;
277277
}
@@ -291,7 +291,7 @@ bool removeAddrspaces(Module &M, AddrspaceRemapFunction ASRemapper)
291291

292292
auto *NGA = GlobalAlias::create(
293293
TypeRemapper.remapType(GA->getValueType()),
294-
GA->getType()->getPointerAddressSpace(),
294+
cast<PointerType>(TypeRemapper.remapType(GA->getType()))->getAddressSpace(),
295295
GA->getLinkage(),
296296
Name,
297297
&M);

test/llvmpasses/remove-addrspaces.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
; TYPED-SAME: {}* ({}***, {}*, [1 x i64]*)* null
1414
; OPAQUE-SAME: ptr null
1515

16+
; COM: check that the addrspace of the global itself is removed
17+
; OPAQUE: @ejl_enz_runtime_exc = external global {}
18+
@ejl_enz_runtime_exc = external addrspace(10) global {}
19+
1620
define i64 @getindex({} addrspace(10)* nonnull align 16 dereferenceable(40)) {
1721
; CHECK-LABEL: @getindex
1822
top:
@@ -123,6 +127,12 @@ define void @byval_type([1 x {} addrspace(10)*] addrspace(11)* byval([1 x {} add
123127
ret void
124128
}
125129

130+
define private fastcc void @diffejulia__mapreduce_97() {
131+
L6:
132+
; OPAQUE: store atomic ptr @ejl_enz_runtime_exc, ptr null unordered
133+
store atomic {} addrspace(10)* @ejl_enz_runtime_exc, {} addrspace(10)* addrspace(10)* null unordered, align 8
134+
unreachable
135+
}
126136

127137
; COM: check that function attributes are preserved on declarations too
128138
declare void @convergent_function() #0

0 commit comments

Comments
 (0)