================ @@ -5384,6 +5384,11 @@ LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) { LangAS AS; if (OpenMPRuntime->hasAllocateAttributeForGlobalVar(D, AS)) return AS; + if (LangOpts.OpenMPIsTargetDevice && getTriple().isSPIRV()) ---------------- sarnex wrote:
Yep, I see the problem with the string even with pure `spirv64-unknown-unknown`. Repro: ``` extern int printf(const char*); int main() { printf("foo"); return 0; } ``` ``` clang++ -cc1 -triple spirv64-unknown-unknown -emit-llvm test.cpp -o - ``` ``` ; ModuleID = 'test.cpp' source_filename = "test.cpp" target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1" target triple = "spirv64-unknown-unknown" @.str = private unnamed_addr constant [4 x i8] c"foo\00", align 1 ; Function Attrs: mustprogress noinline norecurse nounwind optnone define noundef i32 @main() #0 { entry: %retval = alloca i32, align 4 store i32 0, ptr %retval, align 4 %call = call spir_func noundef i32 @_Z6printfPKc(ptr noundef @.str) ret i32 0 } declare spir_func noundef i32 @_Z6printfPKc(ptr noundef) #1 attributes #0 = { mustprogress noinline norecurse nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" } !llvm.module.flags = !{!0} !llvm.ident = !{!1} !0 = !{i32 1, !"wchar_size", i32 4} !1 = !{!"clang version 21.0.0git (https://github.com/llvm/llvm-project.git 06bfbba877c26630b6c5b0ffef7f6623aa2e9ee8)"} ``` [Here](https://github.com/llvm/llvm-project/blob/10bef367a5643bc41d0172b02e080645c68f821a/clang/lib/CodeGen/CodeGenModule.cpp#L6600C1-L6605C44)'s where we get the addrspace from: ``` unsigned AddrSpace = CGM.getContext().getTargetAddressSpace( CGM.GetGlobalConstantAddressSpace()); ``` In `GetGlobalConstantAddressSpace`, we [do](https://github.com/llvm/llvm-project/blob/10bef367a5643bc41d0172b02e080645c68f821a/clang/lib/CodeGen/CodeGenModule.cpp#L5391) ``` if (auto AS = getTarget().getConstantAddressSpace()) return *AS; ``` and since there's no override for SPIR-V we just [get](https://github.com/llvm/llvm-project/blob/10bef367a5643bc41d0172b02e080645c68f821a/clang/include/clang/Basic/TargetInfo.h#L1670) the default: ``` virtual std::optional<LangAS> getConstantAddressSpace() const { return LangAS::Default; } ``` If you see something wrong in this callstack let me know, I'm happy to fix it! https://github.com/llvm/llvm-project/pull/134399 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits