Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/test/OpenMP/force-usm.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int main(void) {
// CHECK-USM-NEXT: br i1 [[EXEC_USER_CODE]], label [[USER_CODE_ENTRY:%.*]], label [[WORKER_EXIT:%.*]]
// CHECK-USM: user_code.entry:
// CHECK-USM-NEXT: store i32 1, ptr [[TMP0]], align 4
// CHECK-USM-NEXT: [[TMP2:%.*]] = load ptr, ptr addrspace(1) @pGI_decl_tgt_ref_ptr, align 8
// CHECK-USM-NEXT: [[TMP2:%.*]] = load ptr, ptr @pGI_decl_tgt_ref_ptr, align 8
// CHECK-USM-NEXT: [[TMP3:%.*]] = load ptr, ptr [[TMP2]], align 8
// CHECK-USM-NEXT: store i32 2, ptr [[TMP3]], align 4
// CHECK-USM-NEXT: call void @__kmpc_target_deinit()
Expand Down
11 changes: 9 additions & 2 deletions llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8472,8 +8472,15 @@ GlobalVariable *OpenMPIRBuilder::getOrCreateInternalVariable(
// create different versions of the function for different OMP internal
// variables.
const DataLayout &DL = M.getDataLayout();
unsigned AddressSpaceVal =
AddressSpace ? *AddressSpace : DL.getDefaultGlobalsAddressSpace();
// TODO: Investigate why AMDGPU expects AS 0 for globals even though the
// default global AS is 1.
// See double-target-call-with-declare-target.f90 and
// declare-target-vars-in-target-region.f90 libomptarget
// tests.
unsigned AddressSpaceVal = AddressSpace ? *AddressSpace
: M.getTargetTriple().isAMDGPU()
? 0
: DL.getDefaultGlobalsAddressSpace();
auto Linkage = this->M.getTargetTriple().getArch() == Triple::wasm32
? GlobalValue::InternalLinkage
: GlobalValue::CommonLinkage;
Expand Down