diff --git a/llvm/lib/SYCLLowerIR/SpecConstants.cpp b/llvm/lib/SYCLLowerIR/SpecConstants.cpp index 287a0aabca359..a0bc46085c65f 100644 --- a/llvm/lib/SYCLLowerIR/SpecConstants.cpp +++ b/llvm/lib/SYCLLowerIR/SpecConstants.cpp @@ -633,7 +633,7 @@ Instruction *emitSpecConstantRecursiveImpl( // not generate a bunch of __spirv_SpecConstant for its elements but // pass it into __spirv_SpecConstantComposite as is. if (It == DefinedElements.end() || It->first != ElOffset) - HandleUndef(UndefValue::get(ElTy)); + HandleUndef(Constant::getNullValue(ElTy)); else Elements.push_back(emitSpecConstantRecursiveImpl( ElTy, InsertBefore, IDs, Index, ElOffset, DefinedElements)); diff --git a/llvm/test/tools/sycl-post-link/spec-constants/SYCL2020-struct-with-undef-padding.ll b/llvm/test/tools/sycl-post-link/spec-constants/SYCL2020-struct-with-undef-padding.ll index 48824faa78d75..19d423824f18a 100644 --- a/llvm/test/tools/sycl-post-link/spec-constants/SYCL2020-struct-with-undef-padding.ll +++ b/llvm/test/tools/sycl-post-link/spec-constants/SYCL2020-struct-with-undef-padding.ll @@ -35,7 +35,7 @@ define weak_odr dso_local spir_kernel void @_ZTSZ4mainEUlN2cl4sycl14kernel_handl ; CHECK-IR: %[[#NS3:]] = call spir_func [3 x float] @_Z29__spirv_SpecConstantCompositefff_RA3_f(float %[[#NS0]], float %[[#NS1]], float %[[#NS2]]) ; CHECK-IR: %[[#NS4:]] = call spir_func %"class.std::array" @"_Z29__spirv_SpecConstantCompositeA3_f_Rclass.std::array"([3 x float] %[[#NS3]]) ; CHECK-IR: %[[#NS5:]] = call spir_func i64 @_Z20__spirv_SpecConstantix(i32 [[#SCID3:]], i64 0) -; 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) +; 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) %4 = alloca %struct.coeff2_str_aligned_t, align 32 %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 ; CHECK-IR: %[[#NS10:]] = call spir_func [3 x float] @_Z29__spirv_SpecConstantCompositefff_RA3_f(float %[[#NS7]], float %[[#NS8]], float %[[#NS9]]) ; CHECK-IR: %[[#NS11:]] = call spir_func %"class.std::array" @"_Z29__spirv_SpecConstantCompositeA3_f_Rclass.std::array"([3 x float] %[[#NS10]]) ; CHECK-IR: %[[#NS12:]] = call spir_func i64 @_Z20__spirv_SpecConstantix(i32 [[#SCID7:]], i64 0) -; 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) +; 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) ret void } diff --git a/llvm/test/tools/sycl-post-link/spec-constants/hierarchy.ll b/llvm/test/tools/sycl-post-link/spec-constants/hierarchy.ll index 04ca51be21c96..10cb705e928bc 100644 --- a/llvm/test/tools/sycl-post-link/spec-constants/hierarchy.ll +++ b/llvm/test/tools/sycl-post-link/spec-constants/hierarchy.ll @@ -72,10 +72,10 @@ declare dso_local spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI5 ; CHECK: %[[#SCV30:]] = {{.*}}@{{.*}}SpecConstant{{.*}}(i32 21, i8 0) ; CHECK: %[[#SCV31:]] = {{.*}}@{{.*}}SpecConstant{{.*}}(i32 22, i8 0) ; CHECK: %[[#SCV32:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(i8 %[[#SCV27]], i8 %[[#SCV28]], i8 %[[#SCV29]], i8 %[[#SCV30]], i8 %[[#SCV31]]) -; CHECK: %[[#SCV33:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(i32 %[[#SCV9]], [4 x i8] undef, [5 x i64] %[[#SCV15]], [5 x %struct.anon.0] %[[#SCV26]], [5 x i8] %[[#SCV32]]) -; CHECK: %[[#SCV34:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(%struct.layer2 %[[#SCV8]], [4 x i8] undef, %struct.foo.base %[[#SCV33]]) +; CHECK: %[[#SCV33:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(i32 %[[#SCV9]], [4 x i8] zeroinitializer, [5 x i64] %[[#SCV15]], [5 x %struct.anon.0] %[[#SCV26]], [5 x i8] %[[#SCV32]]) +; CHECK: %[[#SCV34:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(%struct.layer2 %[[#SCV8]], [4 x i8] zeroinitializer, %struct.foo.base %[[#SCV33]]) ; CHECK: %[[#SCV35:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(%struct.layer3.base %[[#SCV34]]) -; CHECK: %[[#SCV36:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(%struct.layer4.base %[[#SCV35]], [15 x i8] undef) +; CHECK: %[[#SCV36:]] = {{.*}}@{{.*}}SpecConstantComposite{{.*}}(%struct.layer4.base %[[#SCV35]], [15 x i8] zeroinitializer) ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite) declare void @llvm.memcpy.p1.p0.i64(ptr addrspace(1) noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) diff --git a/llvm/test/tools/sycl-post-link/spec-constants/struct-with-padding-in-the-middle.ll b/llvm/test/tools/sycl-post-link/spec-constants/struct-with-padding-in-the-middle.ll index 80b03beb4f440..2387869d7f5d7 100644 --- a/llvm/test/tools/sycl-post-link/spec-constants/struct-with-padding-in-the-middle.ll +++ b/llvm/test/tools/sycl-post-link/spec-constants/struct-with-padding-in-the-middle.ll @@ -43,7 +43,7 @@ ; CHECK: %[[#SCV2:]] = call spir_func i8 @_Z20__spirv_SpecConstantia(i32 [[#SCID2:]], i8 97) ; CHECK: %[[#SCV3:]] = call spir_func i32 @_Z20__spirv_SpecConstantii(i32 [[#SCID3:]], i32 42) ; CHECK: %[[#SCV4:]] = call spir_func i8 @_Z20__spirv_SpecConstantia(i32 [[#SCID4:]], i8 8) -; 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) +; 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) ; CHECK: !sycl.specialization-constants = !{![[#SC:]]} ; CHECK: ![[#SC]] = !{!"uidc5885cee0b80ad9d____ZL7spec_id", diff --git a/llvm/test/tools/sycl-post-link/spec-constants/struct-with-undef-padding-2.ll b/llvm/test/tools/sycl-post-link/spec-constants/struct-with-undef-padding-2.ll index a7c73f4e52f40..d9eacab7e2e15 100644 --- a/llvm/test/tools/sycl-post-link/spec-constants/struct-with-undef-padding-2.ll +++ b/llvm/test/tools/sycl-post-link/spec-constants/struct-with-undef-padding-2.ll @@ -41,7 +41,7 @@ ; CHECK: %[[#A:]] = call spir_func float @_Z20__spirv_SpecConstantif(i32 [[#ID:]], float 0x40091EB860000000) ; CHECK: %[[#B:]] = call spir_func i32 @_Z20__spirv_SpecConstantii(i32 [[#ID+1]], i32 42) ; CHECK: %[[#C:]] = call spir_func i8 @_Z20__spirv_SpecConstantia(i32 2, i8 8) -; 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) +; 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) ; ; CHECK: !sycl.specialization-constants = !{![[#SC:]]} ; CHECK: ![[#SC]] = !{!"uidac684fbd602505be____ZL7spec_id",