aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorHelena Kotas <hekotas@microsoft.com>2025-02-20 17:27:53 -0800
committerGitHub <noreply@github.com>2025-02-20 17:27:53 -0800
commit776cddacb1ab8fd92bcb3aa42f9c0b348d8aa2ba (patch)
tree48c9953fed0269349e213deefa1171de7af3d292 /clang/lib/CodeGen/CodeGenModule.cpp
parent9fa77c18548a4878cf53a5195f69d15a2d1d567f (diff)
downloadllvm-776cddacb1ab8fd92bcb3aa42f9c0b348d8aa2ba.zip
llvm-776cddacb1ab8fd92bcb3aa42f9c0b348d8aa2ba.tar.gz
llvm-776cddacb1ab8fd92bcb3aa42f9c0b348d8aa2ba.tar.bz2
[HLSL] Implement default constant buffer `$Globals` (#125807)
All variable declarations in the global scope that are not resources, static or empty are implicitly added to implicit constant buffer `$Globals`. They are created in `hlsl_constant` address space and collected in an implicit `HLSLBufferDecl` node that is added to the AST at the end of the translation unit. Codegen is the same as for explicit constant buffers. Fixes #123801
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 7924c32..1b7d0ac 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5513,6 +5513,11 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
if (getLangOpts().OpenCL && ASTTy->isSamplerT())
return;
+ // HLSL default buffer constants will be emitted during HLSLBufferDecl codegen
+ if (getLangOpts().HLSL &&
+ D->getType().getAddressSpace() == LangAS::hlsl_constant)
+ return;
+
// If this is OpenMP device, check if it is legal to emit this global
// normally.
if (LangOpts.OpenMPIsTargetDevice && OpenMPRuntime &&