Skip to content

Commit cd683bd

Browse files
authored
[HipStdPar] Fix globle variable (#90627)
HipStdParAcceleratorCodeSelectionPass changes linkage of global variables to extern_weak, which does not allow initializer. An extern_weak global variable with initializer will cause llvm-as and llc to fail.
1 parent 5e67c41 commit cd683bd

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

llvm/lib/Transforms/HipStdPar/HipStdPar.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ static inline void maybeHandleGlobals(Module &M) {
133133
continue;
134134

135135
G.setLinkage(GlobalVariable::ExternalWeakLinkage);
136+
G.setInitializer(nullptr);
136137
G.setExternallyInitialized(true);
137138
}
138139
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=hipstdpar-select-accelerator-code \
2+
; RUN: %s | FileCheck %s
3+
4+
; CHECK: @var = extern_weak addrspace(1) externally_initialized global i32, align 4
5+
@var = addrspace(1) global i32 0, align 4
6+
7+
define amdgpu_kernel void @kernel() {
8+
entry:
9+
store i32 1, ptr addrspace(1) @var, align 4
10+
ret void
11+
}

0 commit comments

Comments
 (0)