Skip to content

Commit

Permalink
Fix remove-addrspaces pass in the presence of globals with addrspaces (
Browse files Browse the repository at this point in the history
…#51782)

This fixes an assertion that might trigger if we run this pass on sysimg
modules.

(cherry picked from commit 01f6c4c)
  • Loading branch information
gbaraldi authored and KristofferC committed Oct 29, 2024
1 parent bb62a53 commit 56f51da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/llvm-remove-addrspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ bool removeAddrspaces(Module &M, AddrspaceRemapFunction ASRemapper)

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

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

GA->setAliasee(nullptr);
}
Expand Down
6 changes: 6 additions & 0 deletions test/llvmpasses/remove-addrspaces.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
; 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


; COM: check that package image fptrs work
@pjlsys_BoundsError_32 = internal global {} addrspace(10)* ({}***, {} addrspace(10)*, [1 x i64] addrspace(11)*)* null
; CHECK: @pjlsys_BoundsError_32 = internal global
; TYPED-SAME: {}* ({}***, {}*, [1 x i64]*)* null
; OPAQUE-SAME: ptr null

define i64 @getindex({} addrspace(10)* nonnull align 16 dereferenceable(40)) {
; CHECK-LABEL: @getindex
top:
Expand Down

0 comments on commit 56f51da

Please sign in to comment.