diff options
author | Steven Perron <stevenperron@google.com> | 2025-03-05 14:02:39 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-05 14:02:39 -0500 |
commit | 6d4f8b1dbfd21811351bec205154992afddbc5ea (patch) | |
tree | 1d3a95ca9a30eed760d3a6b72ba7a5e580c9a7df /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | e49180d84c4d8b25fa944e494f4f292479eec1f6 (diff) | |
download | llvm-6d4f8b1dbfd21811351bec205154992afddbc5ea.zip llvm-6d4f8b1dbfd21811351bec205154992afddbc5ea.tar.gz llvm-6d4f8b1dbfd21811351bec205154992afddbc5ea.tar.bz2 |
[HLSL] Fix resource wrapper declaration (#129100)
The resource wrapper should have internal linkage because it contains a
handle to the global resource, and it not the actual global.
Makeing this changed exposed that we were zeroinitializing the resouce,
which is a problem. The handle cannot be zeroinitialized. This is
changed to use poison instead.
Fixes https://github.com/llvm/llvm-project/issues/122767.
---------
Co-authored-by: Helena Kotas <hekotas@microsoft.com>
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index cec8f12..bca0a93 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -5595,7 +5595,11 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D, if (D->getType()->isReferenceType()) T = D->getType(); - if (getLangOpts().CPlusPlus) { + if (getLangOpts().HLSL && + D->getType().getTypePtr()->isHLSLResourceRecord()) { + Init = llvm::PoisonValue::get(getTypes().ConvertType(ASTTy)); + NeedsGlobalCtor = true; + } else if (getLangOpts().CPlusPlus) { Init = EmitNullConstant(T); if (!IsDefinitionAvailableExternally) NeedsGlobalCtor = true; |