Skip to content

Commit bd06b1f

Browse files
committed
remove undef usage
1 parent 51e6ea3 commit bd06b1f

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
@@ -5636,8 +5636,6 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
56365636
Init = llvm::UndefValue::get(getTypes().ConvertTypeForMem(ASTTy));
56375637
else if (D->hasAttr<LoaderUninitializedAttr>())
56385638
Init = llvm::UndefValue::get(getTypes().ConvertTypeForMem(ASTTy));
5639-
else if (GetGlobalVarAddressSpace(D) == LangAS::hlsl_input)
5640-
Init = llvm::UndefValue::get(getTypes().ConvertTypeForMem(ASTTy));
56415639
else if (!InitExpr) {
56425640
// This is a tentative definition; tentative definitions are
56435641
// implicitly initialized with { 0 }.
@@ -5761,15 +5759,16 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
57615759
getCUDARuntime().internalizeDeviceSideVar(D, Linkage);
57625760
}
57635761
getCUDARuntime().handleVarRegistration(D, *GV);
5764-
} else if (LangOpts.HLSL &&
5765-
GetGlobalVarAddressSpace(D) == LangAS::hlsl_input) {
5762+
}
5763+
5764+
if (LangOpts.HLSL && GetGlobalVarAddressSpace(D) == LangAS::hlsl_input) {
57665765
// HLSL Input variables are considered to be set by the driver/pipeline, but
57675766
// only visible to a single thread/wave.
57685767
GV->setExternallyInitialized(true);
5768+
} else {
5769+
GV->setInitializer(Init);
57695770
}
57705771

5771-
GV->setInitializer(Init);
5772-
57735772
if (LangOpts.HLSL)
57745773
getHLSLRuntime().handleGlobalVarDefinition(D, GV);
57755774

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)