Skip to content

Commit 91e8c29

Browse files
committed
remove undef usage
1 parent 84d15cc commit 91e8c29

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5638,8 +5638,6 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
56385638
Init = llvm::UndefValue::get(getTypes().ConvertTypeForMem(ASTTy));
56395639
else if (D->hasAttr<LoaderUninitializedAttr>())
56405640
Init = llvm::UndefValue::get(getTypes().ConvertTypeForMem(ASTTy));
5641-
else if (GetGlobalVarAddressSpace(D) == LangAS::hlsl_input)
5642-
Init = llvm::UndefValue::get(getTypes().ConvertTypeForMem(ASTTy));
56435641
else if (!InitExpr) {
56445642
// This is a tentative definition; tentative definitions are
56455643
// implicitly initialized with { 0 }.
@@ -5763,15 +5761,16 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
57635761
getCUDARuntime().internalizeDeviceSideVar(D, Linkage);
57645762
}
57655763
getCUDARuntime().handleVarRegistration(D, *GV);
5766-
} else if (LangOpts.HLSL &&
5767-
GetGlobalVarAddressSpace(D) == LangAS::hlsl_input) {
5764+
}
5765+
5766+
if (LangOpts.HLSL && GetGlobalVarAddressSpace(D) == LangAS::hlsl_input) {
57685767
// HLSL Input variables are considered to be set by the driver/pipeline, but
57695768
// only visible to a single thread/wave.
57705769
GV->setExternallyInitialized(true);
5770+
} else {
5771+
GV->setInitializer(Init);
57715772
}
57725773

5773-
GV->setInitializer(Init);
5774-
57755774
if (LangOpts.HLSL)
57765775
getHLSLRuntime().handleGlobalVarDefinition(D, GV);
57775776

clang/test/CodeGenHLSL/vk-input-builtin.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[[vk::ext_builtin_input(/* WorkgroupId */ 26)]]
55
static const uint3 groupid;
6-
// CHECK: @_ZL7groupid = local_unnamed_addr addrspace(7) externally_initialized constant <3 x i32> undef, align 16, !spirv.Decorations [[META0:![0-9]+]]
6+
// CHECK: @_ZL7groupid = external local_unnamed_addr addrspace(7) externally_initialized constant <3 x i32>, align 16, !spirv.Decorations [[META0:![0-9]+]]
77

88
RWStructuredBuffer<int> output : register(u1, space0);
99

llvm/test/CodeGen/SPIRV/hlsl-intrinsics/vk-ext-builtin-input.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
; CHECK-DAG: %[[#ptr_Input_uint:]] = OpTypePointer Input %[[#uint]]
1212
; CHECK-DAG: %[[#ptr_Input_v3uint:]] = OpTypePointer Input %[[#v3uint]]
1313
; CHECK-DAG: %[[#WorkgroupId:]] = OpVariable %[[#ptr_Input_v3uint]] Input
14-
@var = local_unnamed_addr addrspace(7) externally_initialized constant <3 x i32> undef, align 16, !spirv.Decorations !0
14+
@var = external local_unnamed_addr addrspace(7) externally_initialized constant <3 x i32>, align 16, !spirv.Decorations !0
1515

1616
define i32 @foo() {
1717
entry:

0 commit comments

Comments
 (0)