Skip to content

Commit 56f51da

Browse files
gbaraldiKristofferC
authored andcommitted
Fix remove-addrspaces pass in the presence of globals with addrspaces (#51782)
This fixes an assertion that might trigger if we run this pass on sysimg modules. (cherry picked from commit 01f6c4c)
1 parent bb62a53 commit 56f51da

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/llvm-remove-addrspaces.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ bool removeAddrspaces(Module &M, AddrspaceRemapFunction ASRemapper)
336336

337337
GlobalVariable *NGV = cast<GlobalVariable>(VMap[GV]);
338338
if (GV->hasInitializer())
339-
NGV->setInitializer(MapValue(GV->getInitializer(), VMap));
339+
NGV->setInitializer(MapValue(GV->getInitializer(), VMap, RF_None, &TypeRemapper, &Materializer));
340340

341341
SmallVector<std::pair<unsigned, MDNode *>, 1> MDs;
342342
GV->getAllMetadata(MDs);
@@ -401,7 +401,7 @@ bool removeAddrspaces(Module &M, AddrspaceRemapFunction ASRemapper)
401401
for (GlobalAlias *GA : Aliases) {
402402
GlobalAlias *NGA = cast<GlobalAlias>(VMap[GA]);
403403
if (const Constant *C = GA->getAliasee())
404-
NGA->setAliasee(MapValue(C, VMap));
404+
NGA->setAliasee(MapValue(C, VMap, RF_None, &TypeRemapper, &Materializer));
405405

406406
GA->setAliasee(nullptr);
407407
}

test/llvmpasses/remove-addrspaces.ll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
; RUN: opt -enable-new-pm=1 --opaque-pointers=1 --load-pass-plugin=libjulia-codegen%shlibext -passes='RemoveJuliaAddrspaces' -S %s | FileCheck %s --check-prefixes=CHECK,OPAQUE
88

99

10+
; COM: check that package image fptrs work
11+
@pjlsys_BoundsError_32 = internal global {} addrspace(10)* ({}***, {} addrspace(10)*, [1 x i64] addrspace(11)*)* null
12+
; CHECK: @pjlsys_BoundsError_32 = internal global
13+
; TYPED-SAME: {}* ({}***, {}*, [1 x i64]*)* null
14+
; OPAQUE-SAME: ptr null
15+
1016
define i64 @getindex({} addrspace(10)* nonnull align 16 dereferenceable(40)) {
1117
; CHECK-LABEL: @getindex
1218
top:

0 commit comments

Comments
 (0)