================ @@ -5362,6 +5362,23 @@ LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) { if (OpenMPRuntime->hasAllocateAttributeForGlobalVar(D, AS)) return AS; } + + if (LangOpts.HLSL) { + if (D == nullptr) + return LangAS::hlsl_private; + + // Except resources (Uniform, UniformConstant) & instanglble (handles) + if (D->getType()->isHLSLResourceType() || + D->getType()->isHLSLIntangibleType()) + return D->getType().getAddressSpace(); + + if (D->getStorageClass() != SC_Static) + return D->getType().getAddressSpace(); + + LangAS AS = D->getType().getAddressSpace(); + return AS == LangAS::Default ? LangAS::hlsl_private : AS; + } + ---------------- Keenuts wrote:
I recall having tried this method first, but for some reasons moved it to Codegen, but I don't recall the full context. I just tried moving it in sema again, and seems there is a slight issue with `this-reference-template.hlsl` since the VarDecl type is from a template, something goes wrong (but works if the AS fixup is done in codegen). https://github.com/llvm/llvm-project/pull/122103 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits