Skip to content

Commit 9ace7db

Browse files
committed
[SYCL] Use zero instead of undef for padding fields in OpSpecConstantComposite
1 parent 0f5c2ad commit 9ace7db

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

llvm/lib/SYCLLowerIR/SpecConstants.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ Instruction *emitSpecConstantRecursiveImpl(
633633
// not generate a bunch of __spirv_SpecConstant for its elements but
634634
// pass it into __spirv_SpecConstantComposite as is.
635635
if (It == DefinedElements.end() || It->first != ElOffset)
636-
HandleUndef(UndefValue::get(ElTy));
636+
HandleUndef(Constant::getNullValue(ElTy));
637637
else
638638
Elements.push_back(emitSpecConstantRecursiveImpl(
639639
ElTy, InsertBefore, IDs, Index, ElOffset, DefinedElements));

llvm/test/tools/sycl-post-link/spec-constants/SYCL2020-struct-with-undef-padding.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ define weak_odr dso_local spir_kernel void @_ZTSZ4mainEUlN2cl4sycl14kernel_handl
3535
; CHECK-IR: %[[#NS3:]] = call spir_func [3 x float] @_Z29__spirv_SpecConstantCompositefff_RA3_f(float %[[#NS0]], float %[[#NS1]], float %[[#NS2]])
3636
; CHECK-IR: %[[#NS4:]] = call spir_func %"class.std::array" @"_Z29__spirv_SpecConstantCompositeA3_f_Rclass.std::array"([3 x float] %[[#NS3]])
3737
; CHECK-IR: %[[#NS5:]] = call spir_func i64 @_Z20__spirv_SpecConstantix(i32 [[#SCID3:]], i64 0)
38-
; CHECK-IR: %[[#NS6:]] = call spir_func %struct.coeff_str_aligned_t @"_Z29__spirv_SpecConstantCompositeclass.std::arrayxA8_a_Rstruct.coeff_str_aligned_t"(%"class.std::array" %[[#NS4]], i64 %[[#NS5]], [8 x i8] undef)
38+
; CHECK-IR: %[[#NS6:]] = call spir_func %struct.coeff_str_aligned_t @"_Z29__spirv_SpecConstantCompositeclass.std::arrayxA8_a_Rstruct.coeff_str_aligned_t"(%"class.std::array" %[[#NS4]], i64 %[[#NS5]], [8 x i8] zeroinitializer)
3939

4040
%4 = alloca %struct.coeff2_str_aligned_t, align 32
4141
%5 = addrspacecast %struct.coeff2_str_aligned_t* %4 to %struct.coeff2_str_aligned_t addrspace(4)*
@@ -47,7 +47,7 @@ define weak_odr dso_local spir_kernel void @_ZTSZ4mainEUlN2cl4sycl14kernel_handl
4747
; CHECK-IR: %[[#NS10:]] = call spir_func [3 x float] @_Z29__spirv_SpecConstantCompositefff_RA3_f(float %[[#NS7]], float %[[#NS8]], float %[[#NS9]])
4848
; CHECK-IR: %[[#NS11:]] = call spir_func %"class.std::array" @"_Z29__spirv_SpecConstantCompositeA3_f_Rclass.std::array"([3 x float] %[[#NS10]])
4949
; CHECK-IR: %[[#NS12:]] = call spir_func i64 @_Z20__spirv_SpecConstantix(i32 [[#SCID7:]], i64 0)
50-
; CHECK-IR: %[[#NS13:]] = call spir_func %struct.coeff2_str_aligned_t @"_Z29__spirv_SpecConstantCompositeclass.std::arrayxA7_aa_Rstruct.coeff2_str_aligned_t"(%"class.std::array" %[[#NS11]], i64 %[[#NS12]], [7 x i8] undef, i8 undef)
50+
; CHECK-IR: %[[#NS13:]] = call spir_func %struct.coeff2_str_aligned_t @"_Z29__spirv_SpecConstantCompositeclass.std::arrayxA7_aa_Rstruct.coeff2_str_aligned_t"(%"class.std::array" %[[#NS11]], i64 %[[#NS12]], [7 x i8] zeroinitializer, i8 0)
5151

5252
ret void
5353
}

llvm/test/tools/sycl-post-link/spec-constants/hierarchy.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ declare dso_local spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI5
7272
; CHECK: %[[#SCV30:]] = {{.*}}@{{.*}}SpecConstant{{.*}}(i32 21, i8 0)
7373
; CHECK: %[[#SCV31:]] = {{.*}}@{{.*}}SpecConstant{{.*}}(i32 22, i8 0)
7474
; CHECK: %[[#SCV32:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(i8 %[[#SCV27]], i8 %[[#SCV28]], i8 %[[#SCV29]], i8 %[[#SCV30]], i8 %[[#SCV31]])
75-
; CHECK: %[[#SCV33:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(i32 %[[#SCV9]], [4 x i8] undef, [5 x i64] %[[#SCV15]], [5 x %struct.anon.0] %[[#SCV26]], [5 x i8] %[[#SCV32]])
76-
; CHECK: %[[#SCV34:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(%struct.layer2 %[[#SCV8]], [4 x i8] undef, %struct.foo.base %[[#SCV33]])
75+
; CHECK: %[[#SCV33:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(i32 %[[#SCV9]], [4 x i8] zeroinitializer, [5 x i64] %[[#SCV15]], [5 x %struct.anon.0] %[[#SCV26]], [5 x i8] %[[#SCV32]])
76+
; CHECK: %[[#SCV34:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(%struct.layer2 %[[#SCV8]], [4 x i8] zeroinitializer, %struct.foo.base %[[#SCV33]])
7777
; CHECK: %[[#SCV35:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(%struct.layer3.base %[[#SCV34]])
78-
; CHECK: %[[#SCV36:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(%struct.layer4.base %[[#SCV35]], [15 x i8] undef)
78+
; CHECK: %[[#SCV36:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(%struct.layer4.base %[[#SCV35]], [15 x i8] zeroinitializer)
7979

8080
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
8181
declare void @llvm.memcpy.p1.p0.i64(ptr addrspace(1) noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)

llvm/test/tools/sycl-post-link/spec-constants/struct-with-padding-in-the-middle.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
; CHECK: %[[#SCV2:]] = call spir_func i8 @_Z20__spirv_SpecConstantia(i32 [[#SCID2:]], i8 97)
4444
; CHECK: %[[#SCV3:]] = call spir_func i32 @_Z20__spirv_SpecConstantii(i32 [[#SCID3:]], i32 42)
4545
; CHECK: %[[#SCV4:]] = call spir_func i8 @_Z20__spirv_SpecConstantia(i32 [[#SCID4:]], i8 8)
46-
; CHECK: call spir_func %struct.user_defined_type @_Z29__spirv_SpecConstantCompositefaA3_aiaA3_a_Rstruct.user_defined_type(float %[[#SCV1]], i8 %[[#SCV2]], [3 x i8] undef, i32 %[[#SCV3]], i8 %[[#SCV4]], [3 x i8] undef)
46+
; CHECK: call spir_func %struct.user_defined_type @_Z29__spirv_SpecConstantCompositefaA3_aiaA3_a_Rstruct.user_defined_type(float %[[#SCV1]], i8 %[[#SCV2]], [3 x i8] zeroinitializer, i32 %[[#SCV3]], i8 %[[#SCV4]], [3 x i8] zeroinitializer)
4747

4848
; CHECK: !sycl.specialization-constants = !{![[#SC:]]}
4949
; CHECK: ![[#SC]] = !{!"uidc5885cee0b80ad9d____ZL7spec_id",

llvm/test/tools/sycl-post-link/spec-constants/struct-with-undef-padding-2.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
; CHECK: %[[#A:]] = call spir_func float @_Z20__spirv_SpecConstantif(i32 [[#ID:]], float 0x40091EB860000000)
4242
; CHECK: %[[#B:]] = call spir_func i32 @_Z20__spirv_SpecConstantii(i32 [[#ID+1]], i32 42)
4343
; CHECK: %[[#C:]] = call spir_func i8 @_Z20__spirv_SpecConstantia(i32 2, i8 8)
44-
; CHECK: call spir_func %struct.user_defined_type @_Z29__spirv_SpecConstantCompositefiaA3_a_Rstruct.user_defined_type(float %[[#A]], i32 %[[#B]], i8 %[[#C]], [3 x i8] undef)
44+
; CHECK: call spir_func %struct.user_defined_type @_Z29__spirv_SpecConstantCompositefiaA3_a_Rstruct.user_defined_type(float %[[#A]], i32 %[[#B]], i8 %[[#C]], [3 x i8] zeroinitializer)
4545
;
4646
; CHECK: !sycl.specialization-constants = !{![[#SC:]]}
4747
; CHECK: ![[#SC]] = !{!"uidac684fbd602505be____ZL7spec_id",

0 commit comments

Comments
 (0)