aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 4146876..677d8bc 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5796,11 +5796,16 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
(D->getType()->isCUDADeviceBuiltinSurfaceType() ||
D->getType()->isCUDADeviceBuiltinTextureType());
if (getLangOpts().CUDA &&
- (IsCUDASharedVar || IsCUDAShadowVar || IsCUDADeviceShadowVar))
+ (IsCUDASharedVar || IsCUDAShadowVar || IsCUDADeviceShadowVar)) {
Init = llvm::UndefValue::get(getTypes().ConvertTypeForMem(ASTTy));
- else if (D->hasAttr<LoaderUninitializedAttr>())
+ } else if (getLangOpts().HLSL &&
+ (D->getType()->isHLSLResourceRecord() ||
+ D->getType()->isHLSLResourceRecordArray())) {
+ Init = llvm::PoisonValue::get(getTypes().ConvertType(ASTTy));
+ NeedsGlobalCtor = D->getType()->isHLSLResourceRecord();
+ } else if (D->hasAttr<LoaderUninitializedAttr>()) {
Init = llvm::UndefValue::get(getTypes().ConvertTypeForMem(ASTTy));
- else if (!InitExpr) {
+ } else if (!InitExpr) {
// This is a tentative definition; tentative definitions are
// implicitly initialized with { 0 }.
//
@@ -5821,11 +5826,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
if (D->getType()->isReferenceType())
T = D->getType();
- if (getLangOpts().HLSL &&
- D->getType().getTypePtr()->isHLSLResourceRecord()) {
- Init = llvm::PoisonValue::get(getTypes().ConvertType(ASTTy));
- NeedsGlobalCtor = true;
- } else if (getLangOpts().CPlusPlus) {
+ if (getLangOpts().CPlusPlus) {
Init = EmitNullConstant(T);
if (!IsDefinitionAvailableExternally)
NeedsGlobalCtor = true;