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.
  • Loading branch information
gbaraldi authored Oct 20, 2023
1 parent ef3bf66 commit 01f6c4c
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 @@ -335,7 +335,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 @@ -400,7 +400,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 @@ -5,6 +5,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

1 comment on commit 01f6c4c

@vtjnash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nanosoldier runbenchmarks(ALL, isdaily = true)

Please sign in to comment.