-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Add generation of device image with specialization constants replaced by default values #10115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AlexeySachkov
merged 19 commits into
intel:sycl
from
maksimsab:add_devimage_spec_consts
Aug 17, 2023
Merged
[SYCL] Add generation of device image with specialization constants replaced by default values #10115
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c4c9bdb
[SYCL] Add generation of device image with specialization constants r…
maksimsab 30c5715
[SYCL] address remarks from code review
maksimsab cfaae20
[SYCL] apply clang-format
maksimsab 9e2dc55
[SYCL] add handling of scalar types and padded structures
maksimsab b4dc7df
Merge branch 'sycl' into add_devimage_spec_consts
maksimsab 9debaa7
[SYCL] Enable test
maksimsab 1c94f5f
[SYCL] address code review remarks
maksimsab 23f006d
[SYCL] fix symbols generation
maksimsab c0b75bb
Merge branch 'sycl' into add_devimage_spec_consts
maksimsab a03754a
[SYCL] Incorporate logic for default values into the general loop
maksimsab e69a7f6
[SYCL] generate symbols more correctly
maksimsab a561166
[SYCL] refactor function
maksimsab 7697e7b
Merge branch 'sycl' into add_devimage_spec_consts
maksimsab 7af4749
[SYCL] polish PR
maksimsab f4fc91c
[SYCL] Add handling of bool specialization constant
maksimsab 12adaaa
[SYCL] fix help.test
maksimsab 1d6a55a
Merge branch 'sycl' into add_devimage_spec_consts
maksimsab a285f2c
[SYCL] adjust tests to parameter renaming
maksimsab b6c056f
[SYCL] add StripDeadPrototypesPass after SpecConstantPass
maksimsab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
llvm/test/tools/sycl-post-link/spec-constants/default-value/bool.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
; Test checks handling of bool specialization constant. | ||
|
||
; RUN: sycl-post-link -split=auto -spec-const=native -S -o %t.table %s -generate-device-image-default-spec-consts | ||
; RUN: FileCheck %s -input-file %t_1.ll --implicit-check-not="SpecConst" | ||
|
||
; CHECK: %bool1 = trunc i8 1 to i1 | ||
; CHECK: %frombool = zext i1 %bool1 to i8 | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
target triple = "spir64-unknown-unknown" | ||
|
||
%"class.sycl::_V1::specialization_id" = type { i8 } | ||
%struct.A = type { i8 } | ||
|
||
@__usid_str = private unnamed_addr constant [28 x i8] c"uida046125e6e1c1f8d____ZL1c\00", align 1 | ||
@_ZL1c = internal addrspace(1) constant %"class.sycl::_V1::specialization_id" { i8 1 }, align 4 | ||
|
||
; Function Attrs: convergent nounwind | ||
declare dso_local spir_func noundef zeroext i1 @_Z37__sycl_getScalar2020SpecConstantValueIbET_PKcPKvS4_(i8 addrspace(4)* noundef, i8 addrspace(4)* noundef, i8 addrspace(4)* noundef) | ||
|
||
define spir_kernel void @kernel() { | ||
entry: | ||
%bool = call spir_func noundef zeroext i1 @_Z37__sycl_getScalar2020SpecConstantValueIbET_PKcPKvS4_(i8 addrspace(4)* noundef addrspacecast (i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__usid_str, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)* noundef addrspacecast (i8 addrspace(1)* getelementptr inbounds (%"class.sycl::_V1::specialization_id", %"class.sycl::_V1::specialization_id" addrspace(1)* @_ZL1c, i64 0, i32 0) to i8 addrspace(4)*), i8 addrspace(4)* noundef null) #4 | ||
%frombool = zext i1 %bool to i8 | ||
ret void | ||
} |
90 changes: 90 additions & 0 deletions
90
llvm/test/tools/sycl-post-link/spec-constants/default-value/device-image.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
; Test checks the content of simple generated device image. | ||
; It checks scalar, sret and "return by value" versions of SpecConstant functions. | ||
; Also test checks generated symbols. | ||
|
||
; RUN: sycl-post-link -split=auto -spec-const=native -symbols -S -o %t.table %s -generate-device-image-default-spec-consts | ||
; RUN: FileCheck %s -input-file %t.table -check-prefix=CHECK-TABLE | ||
; RUN: FileCheck %s -input-file %t_0.prop -check-prefix=CHECK-PROP0 | ||
; RUN: FileCheck %s -input-file %t_1.prop -check-prefix=CHECK-PROP1 | ||
; RUN: FileCheck %s -input-file %t_0.ll -check-prefix=CHECK-IR0 | ||
; RUN: FileCheck %s -input-file %t_1.ll -check-prefix=CHECK-IR1 --implicit-check-not "SpecConstant" | ||
; RUN: FileCheck %s -input-file %t_0.sym -check-prefix=CHECK-SYM0 | ||
; RUN: FileCheck %s -input-file %t_1.sym -check-prefix=CHECK-SYM1 | ||
|
||
; CHECK-TABLE: {{.*}}_0.ll|{{.*}}_0.prop|{{.*}}_0.sym | ||
; CHECK-TABLE: {{.*}}_1.ll|{{.*}}_1.prop|{{.*}}_1.sym | ||
|
||
; CHECK-PROP0-NOT: specConstsReplacedWithDefault=1|1 | ||
|
||
; CHECK-PROP1: specConstsReplacedWithDefault=1|1 | ||
|
||
; CHECK-IR0: call i32 @_Z20__spirv_SpecConstantii | ||
; CHECK-IR0: call %struct.B @_Z29__spirv_SpecConstantCompositeiii_Rstruct.B | ||
; CHECK-IR0: call %struct.A @_Z29__spirv_SpecConstantCompositeistruct.B_Rstruct.A | ||
|
||
; CHECK-IR1: store %struct.A { i32 3, %struct.B { i32 3, i32 2, i32 1 } }, %struct.A addrspace(4)* %a.ascast.i, align 4 | ||
|
||
; Check that %scalar value has been replaced by global value. | ||
; CHECK-IR1-NOT: %scalar = call | ||
; CHECK-IR1: %scalar2 = add i32 123, 1 | ||
|
||
; Check that %returned_spec_const value has been replaced by global value. | ||
; CHECK-IR1-NOT: %returned_spec_const = call | ||
; CHECK-IR1: %sc.e = extractvalue %struct.C { i32 1 }, 0 | ||
|
||
; CHECK-SYM0: kernel | ||
; CHECK-SYM0-EMPTY: | ||
|
||
; CHECK-SYM1: kernel | ||
; CHECK-SYM1-EMPTY: | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
target triple = "spir64-unknown-unknown" | ||
|
||
%"class.sycl::_V1::specialization_id" = type { %struct.A } | ||
%"class.sycl::_V1::specialization_id.2" = type { i32 } | ||
%"class.sycl::_V1::specialization_id.3" = type { %struct.C } | ||
%struct.A = type { i32, %struct.B } | ||
%struct.B = type { i32, i32, i32 } | ||
%struct.C = type { i32 } | ||
|
||
@__usid_str = private unnamed_addr constant [28 x i8] c"uida046125e6e1c1f8d____ZL1c\00", align 1 | ||
@__usid_str.1 = private unnamed_addr constant [33 x i8] c"uidcac21ed8fab7d507____ZL6valueS\00", align 1 | ||
@__usid_str.2 = private unnamed_addr constant [28 x i8] c"uida046125e6e1c1f8f____ZL1b\00", align 1 | ||
@_ZL1c = internal addrspace(1) constant %"class.sycl::_V1::specialization_id" { %struct.A { i32 3, %struct.B { i32 3, i32 2, i32 1 } } }, align 4 | ||
@_ZL6valueS = internal addrspace(1) constant %"class.sycl::_V1::specialization_id.2" { i32 123 }, align 4 | ||
@_ZL1b = internal addrspace(1) constant %"class.sycl::_V1::specialization_id.3" { %struct.C { i32 1 } }, align 4 | ||
|
||
; This constant checks `zeroinitializer` field. | ||
@_ZL1d = internal addrspace(1) constant %"class.sycl::_V1::specialization_id" { %struct.A { i32 3, %struct.B zeroinitializer } }, align 4 | ||
|
||
declare spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI1AET_PKcPKvS5_(%struct.A addrspace(4)* sret(%struct.A) align 4, i8 addrspace(4)* noundef, i8 addrspace(4)* noundef, i8 addrspace(4)* noundef) | ||
|
||
declare spir_func %struct.C @_Z40__sycl_getComposite2020SpecConstantValueI1CET_PKcPKvS5_(i8 addrspace(4)* noundef, i8 addrspace(4)* noundef, i8 addrspace(4)* noundef) | ||
|
||
declare dso_local spir_func noundef i32 @_Z37__sycl_getScalar2020SpecConstantValueIiET_PKcPKvS4_(i8 addrspace(4)* noundef, i8 addrspace(4)* noundef, i8 addrspace(4)* noundef) | ||
|
||
; Function for testing symbol generation | ||
define spir_func void @func() { | ||
ret void | ||
} | ||
|
||
define spir_kernel void @kernel() { | ||
entry: | ||
%a.i = alloca %struct.A, align 4 | ||
%a.ascast.i = addrspacecast %struct.A* %a.i to %struct.A addrspace(4)* | ||
%0 = bitcast %struct.A* %a.i to i8* | ||
call spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI1AET_PKcPKvS5_(%struct.A addrspace(4)* sret(%struct.A) align 4 %a.ascast.i, i8 addrspace(4)* noundef addrspacecast (i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__usid_str, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)* noundef addrspacecast (i8 addrspace(1)* bitcast (%"class.sycl::_V1::specialization_id" addrspace(1)* @_ZL1c to i8 addrspace(1)*) to i8 addrspace(4)*), i8 addrspace(4)* noundef null) | ||
%scalar = call spir_func i32 @_Z37__sycl_getScalar2020SpecConstantValueIiET_PKcPKvS4_(i8 addrspace(4)* noundef addrspacecast (i8* getelementptr inbounds ([33 x i8], [33 x i8]* @__usid_str.1, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)* noundef addrspacecast (i8 addrspace(1)* bitcast (%"class.sycl::_V1::specialization_id.2" addrspace(1)* @_ZL6valueS to i8 addrspace(1)*) to i8 addrspace(4)*), i8 addrspace(4)* noundef null) | ||
%scalar2 = add i32 %scalar, 1 | ||
|
||
%returned_spec_const = call spir_func %struct.C @_Z40__sycl_getComposite2020SpecConstantValueI1CET_PKcPKvS5_(i8 addrspace(4)* noundef addrspacecast (i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__usid_str.2, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)* noundef addrspacecast (i8 addrspace(1)* bitcast (%"class.sycl::_V1::specialization_id.3" addrspace(1)* @_ZL1b to i8 addrspace(1)*) to i8 addrspace(4)*), i8 addrspace(4)* noundef null) | ||
%sc.e = extractvalue %struct.C %returned_spec_const, 0 | ||
%scalar3 = add i32 %sc.e, 1 | ||
|
||
call spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI1AET_PKcPKvS5_(%struct.A addrspace(4)* sret(%struct.A) align 4 %a.ascast.i, i8 addrspace(4)* noundef addrspacecast (i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__usid_str, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)* noundef addrspacecast (i8 addrspace(1)* bitcast (%"class.sycl::_V1::specialization_id" addrspace(1)* @_ZL1d to i8 addrspace(1)*) to i8 addrspace(4)*), i8 addrspace(4)* noundef null) | ||
|
||
|
||
call void @func() | ||
ret void | ||
} |
55 changes: 55 additions & 0 deletions
55
llvm/test/tools/sycl-post-link/spec-constants/default-value/esimd.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
; Test checks generation of device image of esimd kernel. | ||
|
||
; RUN: sycl-post-link -split=auto -split-esimd -lower-esimd -O2 -spec-const=native -o %t.table %s -generate-device-image-default-spec-consts | ||
; RUN: FileCheck %s -input-file=%t.table -check-prefix=CHECK-TABLE | ||
; RUN: FileCheck %s -input-file=%t_1.prop -check-prefix=CHECK-PROP | ||
; RUN: FileCheck %s -input-file=%t_esimd_1.prop -check-prefix=CHECK-ESIMD-PROP | ||
|
||
; CHECK-TABLE: {{.*}}_esimd_0.bc|{{.*}}_esimd_0.prop | ||
; CHECK-TABLE: {{.*}}_0.bc|{{.*}}_0.prop | ||
; CHECK-TABLE: {{.*}}_esimd_1.bc|{{.*}}_esimd_1.prop | ||
; CHECK-TABLE: {{.*}}_1.bc|{{.*}}_1.prop | ||
|
||
; CHECK-PROP: specConstsReplacedWithDefault=1|1 | ||
|
||
; CHECK-ESIMD-PROP: isEsimdImage=1|1 | ||
; CHECK-ESIMD-PROP: specConstsReplacedWithDefault=1|1 | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
target triple = "spir64-unknown-unknown" | ||
|
||
%"class.sycl::_V1::specialization_id" = type { %struct.A } | ||
%struct.A = type { i32, %struct.B } | ||
%struct.B = type { i32, i32, i32 } | ||
|
||
@__usid_str = private unnamed_addr constant [28 x i8] c"uida046125e6e1c1f8d____ZL1c\00", align 1 | ||
@_ZL1c = internal addrspace(1) constant %"class.sycl::_V1::specialization_id" { %struct.A { i32 3, %struct.B { i32 3, i32 2, i32 1 } } }, align 4 | ||
|
||
declare spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI1AET_PKcPKvS5_(%struct.A addrspace(4)* sret(%struct.A) align 4, i8 addrspace(4)* noundef, i8 addrspace(4)* noundef, i8 addrspace(4)* noundef) | ||
|
||
define spir_kernel void @func1() !kernel_arg_buffer_location !7 !sycl_kernel_omit_args !8 { | ||
entry: | ||
%a.i = alloca %struct.A, align 4 | ||
%a.ascast.i = addrspacecast %struct.A* %a.i to %struct.A addrspace(4)* | ||
%0 = bitcast %struct.A* %a.i to i8* | ||
call spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI1AET_PKcPKvS5_(%struct.A addrspace(4)* sret(%struct.A) align 4 %a.ascast.i, i8 addrspace(4)* noundef addrspacecast (i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__usid_str, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)* noundef addrspacecast (i8 addrspace(1)* bitcast (%"class.sycl::_V1::specialization_id" addrspace(1)* @_ZL1c to i8 addrspace(1)*) to i8 addrspace(4)*), i8 addrspace(4)* noundef null) | ||
ret void | ||
} | ||
|
||
define spir_kernel void @func2(i8 addrspace(1)* noundef align 1 %_arg__specialization_constants_buffer) !sycl_explicit_simd !1 !kernel_arg_addr_space !2 !kernel_arg_access_qual !3 !kernel_arg_type !4 !kernel_arg_base_type !4 !kernel_arg_type_qual !5 !kernel_arg_accessor_ptr !6 { | ||
entry: | ||
%a.i = alloca %struct.A, align 4 | ||
%a.ascast.i = addrspacecast %struct.A* %a.i to %struct.A addrspace(4)* | ||
%0 = bitcast %struct.A* %a.i to i8* | ||
call spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI1AET_PKcPKvS5_(%struct.A addrspace(4)* sret(%struct.A) align 4 %a.ascast.i, i8 addrspace(4)* noundef addrspacecast (i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__usid_str, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)* noundef addrspacecast (i8 addrspace(1)* bitcast (%"class.sycl::_V1::specialization_id" addrspace(1)* @_ZL1c to i8 addrspace(1)*) to i8 addrspace(4)*), i8 addrspace(4)* noundef null) | ||
ret void | ||
} | ||
|
||
!1 = !{} | ||
!2 = !{i32 1} | ||
!3 = !{!"none"} | ||
!4 = !{!"char*"} | ||
!5 = !{!""} | ||
!6 = !{i1 false} | ||
!7 = !{i32 -1} | ||
!8 = !{i1 true} |
51 changes: 51 additions & 0 deletions
51
llvm/test/tools/sycl-post-link/spec-constants/default-value/split-by-kernel.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
; Test checks generation of device images for splitted kernels. | ||
|
||
; RUN: sycl-post-link -split=kernel -o %t.table %s -generate-device-image-default-spec-consts | ||
; RUN: cat %t.table | FileCheck %s -check-prefix=CHECK-TABLE | ||
; RUN: cat %t_0.prop | FileCheck %s -check-prefix=CHECK-PROP0 | ||
; RUN: cat %t_1.prop | FileCheck %s -check-prefix=CHECK-PROP1 | ||
; RUN: cat %t_2.prop | FileCheck %s -check-prefix=CHECK-PROP2 | ||
; RUN: cat %t_3.prop | FileCheck %s -check-prefix=CHECK-PROP3 | ||
|
||
; CHECK-TABLE: {{.*}}_0.bc|{{.*}}_0.prop | ||
; CHECK-TABLE: {{.*}}_1.bc|{{.*}}_1.prop | ||
; CHECK-TABLE: {{.*}}_2.bc|{{.*}}_2.prop | ||
; CHECK-TABLE: {{.*}}_3.bc|{{.*}}_3.prop | ||
|
||
; CHECK-PROP0-NOT: specConstsReplacedWithDefault=1|1 | ||
|
||
; CHECK-PROP1: specConstsReplacedWithDefault=1|1 | ||
|
||
; CHECK-PROP2-NOT: specConstsReplacedWithDefault=1|1 | ||
|
||
; CHECK-PROP3: specConstsReplacedWithDefault=1|1 | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
target triple = "spir64-unknown-unknown" | ||
|
||
%"class.sycl::_V1::specialization_id" = type { %struct.A } | ||
%struct.A = type { i32, %struct.B } | ||
%struct.B = type { i32, i32, i32 } | ||
|
||
@__usid_str = private unnamed_addr constant [28 x i8] c"uida046125e6e1c1f8d____ZL1c\00", align 1 | ||
@_ZL1c = internal addrspace(1) constant %"class.sycl::_V1::specialization_id" { %struct.A { i32 3, %struct.B { i32 3, i32 2, i32 1 } } }, align 4 | ||
|
||
declare spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI1AET_PKcPKvS5_(%struct.A addrspace(4)* sret(%struct.A) align 4, i8 addrspace(4)* noundef, i8 addrspace(4)* noundef, i8 addrspace(4)* noundef) | ||
|
||
define spir_kernel void @kernel1() { | ||
entry: | ||
%a.i = alloca %struct.A, align 4 | ||
%a.ascast.i = addrspacecast %struct.A* %a.i to %struct.A addrspace(4)* | ||
%0 = bitcast %struct.A* %a.i to i8* | ||
call spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI1AET_PKcPKvS5_(%struct.A addrspace(4)* sret(%struct.A) align 4 %a.ascast.i, i8 addrspace(4)* noundef addrspacecast (i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__usid_str, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)* noundef addrspacecast (i8 addrspace(1)* bitcast (%"class.sycl::_V1::specialization_id" addrspace(1)* @_ZL1c to i8 addrspace(1)*) to i8 addrspace(4)*), i8 addrspace(4)* noundef null) | ||
ret void | ||
} | ||
|
||
define spir_kernel void @kernel2() { | ||
entry: | ||
%a.i = alloca %struct.A, align 4 | ||
%a.ascast.i = addrspacecast %struct.A* %a.i to %struct.A addrspace(4)* | ||
%0 = bitcast %struct.A* %a.i to i8* | ||
call spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI1AET_PKcPKvS5_(%struct.A addrspace(4)* sret(%struct.A) align 4 %a.ascast.i, i8 addrspace(4)* noundef addrspacecast (i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__usid_str, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)* noundef addrspacecast (i8 addrspace(1)* bitcast (%"class.sycl::_V1::specialization_id" addrspace(1)* @_ZL1c to i8 addrspace(1)*) to i8 addrspace(4)*), i8 addrspace(4)* noundef null) | ||
ret void | ||
} |
54 changes: 54 additions & 0 deletions
54
llvm/test/tools/sycl-post-link/spec-constants/default-value/split-by-source.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
; Test checks generation of device images for splitted kernels by source. | ||
|
||
; RUN: sycl-post-link -split=source -o %t.table %s -generate-device-image-default-spec-consts | ||
; RUN: cat %t.table | FileCheck %s -check-prefix=CHECK-TABLE | ||
; RUN: cat %t_0.prop | FileCheck %s -check-prefix=CHECK-PROP0 | ||
; RUN: cat %t_1.prop | FileCheck %s -check-prefix=CHECK-PROP1 | ||
; RUN: cat %t_2.prop | FileCheck %s -check-prefix=CHECK-PROP2 | ||
; RUN: cat %t_3.prop | FileCheck %s -check-prefix=CHECK-PROP3 | ||
|
||
; CHECK-TABLE: {{.*}}_0.bc|{{.*}}_0.prop | ||
; CHECK-TABLE: {{.*}}_1.bc|{{.*}}_1.prop | ||
; CHECK-TABLE: {{.*}}_2.bc|{{.*}}_2.prop | ||
; CHECK-TABLE: {{.*}}_3.bc|{{.*}}_3.prop | ||
|
||
; CHECK-PROP0-NOT: specConstsReplacedWithDefault=1|1 | ||
|
||
; CHECK-PROP1: specConstsReplacedWithDefault=1|1 | ||
|
||
; CHECK-PROP2-NOT: specConstsReplacedWithDefault=1|1 | ||
|
||
; CHECK-PROP3: specConstsReplacedWithDefault=1|1 | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
target triple = "spir64-unknown-unknown" | ||
|
||
%"class.sycl::_V1::specialization_id" = type { %struct.A } | ||
%struct.A = type { i32, %struct.B } | ||
%struct.B = type { i32, i32, i32 } | ||
|
||
@__usid_str = private unnamed_addr constant [28 x i8] c"uida046125e6e1c1f8d____ZL1c\00", align 1 | ||
@_ZL1c = internal addrspace(1) constant %"class.sycl::_V1::specialization_id" { %struct.A { i32 3, %struct.B { i32 3, i32 2, i32 1 } } }, align 4 | ||
|
||
declare spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI1AET_PKcPKvS5_(%struct.A addrspace(4)* sret(%struct.A) align 4, i8 addrspace(4)* noundef, i8 addrspace(4)* noundef, i8 addrspace(4)* noundef) | ||
|
||
define spir_kernel void @kernel1() #0 { | ||
entry: | ||
%a.i = alloca %struct.A, align 4 | ||
%a.ascast.i = addrspacecast %struct.A* %a.i to %struct.A addrspace(4)* | ||
%0 = bitcast %struct.A* %a.i to i8* | ||
call spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI1AET_PKcPKvS5_(%struct.A addrspace(4)* sret(%struct.A) align 4 %a.ascast.i, i8 addrspace(4)* noundef addrspacecast (i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__usid_str, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)* noundef addrspacecast (i8 addrspace(1)* bitcast (%"class.sycl::_V1::specialization_id" addrspace(1)* @_ZL1c to i8 addrspace(1)*) to i8 addrspace(4)*), i8 addrspace(4)* noundef null) | ||
ret void | ||
} | ||
|
||
define spir_kernel void @kernel2() #1 { | ||
entry: | ||
%a.i = alloca %struct.A, align 4 | ||
%a.ascast.i = addrspacecast %struct.A* %a.i to %struct.A addrspace(4)* | ||
%0 = bitcast %struct.A* %a.i to i8* | ||
call spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI1AET_PKcPKvS5_(%struct.A addrspace(4)* sret(%struct.A) align 4 %a.ascast.i, i8 addrspace(4)* noundef addrspacecast (i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__usid_str, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)* noundef addrspacecast (i8 addrspace(1)* bitcast (%"class.sycl::_V1::specialization_id" addrspace(1)* @_ZL1c to i8 addrspace(1)*) to i8 addrspace(4)*), i8 addrspace(4)* noundef null) | ||
ret void | ||
} | ||
|
||
attributes #0 = { "sycl-module-id"="TU1.cpp" } | ||
attributes #1 = { "sycl-module-id"="TU2.cpp" } |
32 changes: 32 additions & 0 deletions
32
llvm/test/tools/sycl-post-link/spec-constants/default-value/struct-with-padding.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
; Test checks that struct with padding is handled correctly. | ||
|
||
; RUN: sycl-post-link -split=auto -spec-const=native -S -o %t.table %s -generate-device-image-default-spec-consts | ||
; RUN: cat %t.table | FileCheck %s -check-prefix=CHECK-TABLE | ||
; RUN: cat %t_1.prop | FileCheck %s -check-prefix=CHECK-PROP1 | ||
; RUN: cat %t_1.ll | FileCheck %s -check-prefix=CHECK-IR1 --implicit-check-not SpecConstant | ||
|
||
; CHECK-TABLE: {{.*}}_0.ll|{{.*}}_0.prop | ||
; CHECK-TABLE: {{.*}}_1.ll|{{.*}}_1.prop | ||
|
||
; CHECK-PROP1: specConstsReplacedWithDefault=1|1 | ||
|
||
; CHECK-IR1: store { float, i32, i8 } { float 0x40091EB860000000, i32 42, i8 8 }, { float, i32, i8 } addrspace(4)* %1, align 4 | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
target triple = "spir64-unknown-unknown" | ||
|
||
%struct.A = type <{ float, i32, i8, [3 x i8] }> | ||
|
||
@__usid_str = private unnamed_addr constant [28 x i8] c"uida046125e6e1c1f8d____ZL1c\00", align 1 | ||
@_ZL1c = internal addrspace(1) constant { { float, i32, i8 } } { { float, i32, i8 } { float 0x40091EB860000000, i32 42, i8 8 } }, align 4 | ||
|
||
declare spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI1AET_PKcPKvS5_(%struct.A addrspace(4)* sret(%struct.A) align 4, i8 addrspace(4)* noundef, i8 addrspace(4)* noundef, i8 addrspace(4)* noundef) | ||
|
||
define spir_kernel void @func1() { | ||
entry: | ||
%a.i = alloca %struct.A, align 4 | ||
%a.ascast.i = addrspacecast %struct.A* %a.i to %struct.A addrspace(4)* | ||
%0 = bitcast %struct.A* %a.i to i8* | ||
call spir_func void @_Z40__sycl_getComposite2020SpecConstantValueI1AET_PKcPKvS5_(%struct.A addrspace(4)* sret(%struct.A) align 4 %a.ascast.i, i8 addrspace(4)* noundef addrspacecast (i8* getelementptr inbounds ([28 x i8], [28 x i8]* @__usid_str, i64 0, i64 0) to i8 addrspace(4)*), i8 addrspace(4)* noundef addrspacecast (i8 addrspace(1)* bitcast ({ { float, i32, i8 } } addrspace(1)* @_ZL1c to i8 addrspace(1)*) to i8 addrspace(4)*), i8 addrspace(4)* noundef null) | ||
ret void | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.