-
Notifications
You must be signed in to change notification settings - Fork 787
[sycl-post-link] Do not drop SYCL_EXTERNAL functions #3793
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
pvchupin
merged 15 commits into
intel:sycl
from
DenisBakhvalov:external_funcs_post_link
Jun 18, 2021
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9e41ec7
[sycl-post-link] Do not drop unreferenced functions
DenisBakhvalov 7294ed5
[sycl-post-link] Do not drop unreferenced functions
DenisBakhvalov 966e154
[sycl-post-link] Support ESIMD lowering of unreferenced functions
DenisBakhvalov 253fc35
Distinguish module entry points by the presence of sycl-module-id att…
DenisBakhvalov 15ebc4b
Update erase_used.ll
DenisBakhvalov 6cc11f0
Update split-and-lower-esimd.ll
DenisBakhvalov e1a24e7
Update split-per-kernel.ll
DenisBakhvalov e9d0e27
Update split-per-source.ll
DenisBakhvalov 0313636
Fixed help text
DenisBakhvalov c59db7d
fixed review comments
DenisBakhvalov b3f5600
Fixed code review comments
DenisBakhvalov 86192f5
Added a comment
DenisBakhvalov cdffa9f
Update drop-unref-funcs.ll
DenisBakhvalov 1eec0c4
Backed of the check for unsupported calling conventions
DenisBakhvalov a54f245
SPIRV and SYCL builtin functions are not considered as module entry p…
DenisBakhvalov 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
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
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
33 changes: 33 additions & 0 deletions
33
llvm/test/tools/sycl-post-link/sycl-external-funcs/drop-known-builtins.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,33 @@ | ||
; RUN: sycl-post-link -ir-output-only -split=auto -S %s -o %t.ll | ||
; RUN: FileCheck %s -input-file=%t.ll | ||
|
||
; This test checks that known SPIRV and SYCL builtin functions | ||
; (that are also marked with SYCL_EXTRENAL) are not considered | ||
; as module entry points and thus are not added as entry to the | ||
; device binary symbol table. So, they can be dropped if | ||
; unreferenced. | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
target triple = "spir64-unknown-linux-sycldevice" | ||
|
||
define dso_local spir_func void @_Z28__spirv_GlobalInvocationId_xv() #0 { | ||
ret void | ||
} | ||
define dso_local spir_func void @_Z28__spXrv_GlobalInvocationId_xv() #0 { | ||
ret void | ||
} | ||
|
||
define dso_local spir_func void @_Z33__sycl_getScalarSpecConstantValue() #0 { | ||
ret void | ||
} | ||
define dso_local spir_func void @_Z33__sXcl_getScalarSpecConstantValue() #0 { | ||
ret void | ||
} | ||
|
||
attributes #0 = { "sycl-module-id"="a.cpp" } | ||
|
||
; CHECK-NOT: define dso_local spir_func void @_Z28__spirv_GlobalInvocationId_xv() | ||
; CHECK-NOT: define dso_local spir_func void @_Z33__sycl_getScalarSpecConstantValue() | ||
|
||
; CHECK-DAG: define dso_local spir_func void @_Z28__spXrv_GlobalInvocationId_xv() | ||
; CHECK-DAG: define dso_local spir_func void @_Z33__sXcl_getScalarSpecConstantValue() |
21 changes: 21 additions & 0 deletions
21
llvm/test/tools/sycl-post-link/sycl-external-funcs/drop-unref-funcs.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,21 @@ | ||
; RUN: sycl-post-link -ir-output-only -split=auto -S %s -o %t.ll | ||
; RUN: FileCheck %s -input-file=%t.ll | ||
|
||
; This test checks that unreferenced functions without sycl-module-id | ||
; attribute are dropped from the module after splitting. | ||
DenisBakhvalov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
target triple = "spir64-unknown-linux-sycldevice" | ||
|
||
define dso_local spir_func void @externalDeviceFunc() #0 { | ||
ret void | ||
} | ||
|
||
define dso_local spir_func void @unreferencedFunc() { | ||
ret void | ||
} | ||
|
||
attributes #0 = { "sycl-module-id"="a.cpp" } | ||
|
||
; CHECK: define dso_local spir_func void @externalDeviceFunc() | ||
; CHECK-NOT: define dso_local spir_func void @unreferencedFunc() |
16 changes: 16 additions & 0 deletions
16
llvm/test/tools/sycl-post-link/sycl-external-funcs/keep-indirectly-ref-funcs.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,16 @@ | ||
; RUN: sycl-post-link -ir-output-only -split=auto -S %s -o %t.ll | ||
; RUN: FileCheck %s -input-file=%t.ll | ||
|
||
; This test checks that indirectly referenced functions (with sycl-module-id | ||
; attribute) are not dropped from the module. | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
target triple = "spir64-unknown-linux-sycldevice" | ||
|
||
define dso_local spir_func void @indRefDeviceFunc() #0 { | ||
ret void | ||
} | ||
|
||
attributes #0 = { "sycl-module-id"="a.cpp" "referenced-indirectly"} | ||
|
||
; CHECK: define dso_local spir_func void @indRefDeviceFunc() |
30 changes: 30 additions & 0 deletions
30
llvm/test/tools/sycl-post-link/sycl-external-funcs/split-and-lower-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,30 @@ | ||
; RUN: sycl-post-link -split=auto -split-esimd -lower-esimd -O0 -S %s -o %t.table | ||
; RUN: FileCheck %s -input-file=%t_esimd_0.ll | ||
|
||
; This test checks that unreferenced functions with sycl-module-id | ||
; attribute are not dropped from the module and ESIMD lowering | ||
; happens for them as well. | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
target triple = "spir64-unknown-linux-sycldevice" | ||
|
||
@__spirv_BuiltInGlobalInvocationId = external dso_local local_unnamed_addr addrspace(1) constant <3 x i64>, align 32 | ||
DenisBakhvalov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
define dso_local spir_func void @externalESIMDDeviceFunc() #0 !sycl_explicit_simd !0 { | ||
entry: | ||
%0 = load <3 x i64>, <3 x i64> addrspace(4)* addrspacecast (<3 x i64> addrspace(1)* @__spirv_BuiltInGlobalInvocationId to <3 x i64> addrspace(4)*), align 32 | ||
%1 = extractelement <3 x i64> %0, i64 0 | ||
ret void | ||
} | ||
|
||
attributes #0 = { "sycl-module-id"="a.cpp" } | ||
|
||
!0 = !{} | ||
|
||
; CHECK: define dso_local spir_func void @externalESIMDDeviceFunc() | ||
; CHECK: entry: | ||
; CHECK: call <3 x i32> @llvm.genx.local.id.v3i32() | ||
; CHECK: call <3 x i32> @llvm.genx.local.size.v3i32() | ||
; CHECK: call i32 @llvm.genx.group.id.x() | ||
; CHECK: ret void | ||
; CHECK: } |
22 changes: 22 additions & 0 deletions
22
llvm/test/tools/sycl-post-link/sycl-external-funcs/split-global.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,22 @@ | ||
; RUN: sycl-post-link -ir-output-only -split=auto -S %s -o %t.ll | ||
; RUN: FileCheck %s -input-file=%t.ll | ||
|
||
; This test checks that unreferenced functions with sycl-module-id | ||
; attribute are not dropped from the module after splitting | ||
; in global mode. | ||
DenisBakhvalov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
target triple = "spir64-unknown-linux-sycldevice" | ||
|
||
define dso_local spir_func void @externalDeviceFunc() #0 { | ||
ret void | ||
} | ||
|
||
define dso_local spir_kernel void @kernel1() #0 { | ||
ret void | ||
} | ||
|
||
attributes #0 = { "sycl-module-id"="a.cpp" } | ||
|
||
; CHECK-DAG: define dso_local spir_func void @externalDeviceFunc() | ||
DenisBakhvalov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
; CHECK-DAG: define dso_local spir_kernel void @kernel1() |
28 changes: 28 additions & 0 deletions
28
llvm/test/tools/sycl-post-link/sycl-external-funcs/split-per-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,28 @@ | ||
; RUN: sycl-post-link -split=kernel -symbols -S %s -o %t.table | ||
; RUN: FileCheck %s -input-file=%t_0.ll --check-prefixes CHECK-IR1 | ||
; RUN: FileCheck %s -input-file=%t_1.ll --check-prefixes CHECK-IR2 | ||
; RUN: FileCheck %s -input-file=%t_0.sym --check-prefixes CHECK-SYM1 | ||
; RUN: FileCheck %s -input-file=%t_1.sym --check-prefixes CHECK-SYM2 | ||
|
||
; This test checks that unreferenced functions with sycl-module-id | ||
; attribute are not dropped from the module after splitting | ||
; in per-kernel mode. | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
target triple = "spir64-unknown-linux-sycldevice" | ||
|
||
define dso_local spir_func void @externalDeviceFunc() #0 { | ||
ret void | ||
} | ||
|
||
define dso_local spir_kernel void @kernel1() #0 { | ||
ret void | ||
} | ||
|
||
attributes #0 = { "sycl-module-id"="a.cpp" } | ||
|
||
; CHECK-IR1: define dso_local spir_func void @externalDeviceFunc() | ||
DenisBakhvalov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
; CHECK-IR2: define dso_local spir_kernel void @kernel1() | ||
|
||
; CHECK-SYM1: externalDeviceFunc | ||
; CHECK-SYM2: kernel1 |
29 changes: 29 additions & 0 deletions
29
llvm/test/tools/sycl-post-link/sycl-external-funcs/split-per-source1.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,29 @@ | ||
; RUN: sycl-post-link -split=source -symbols -S %s -o %t.table | ||
; RUN: FileCheck %s -input-file=%t_0.ll --check-prefixes CHECK-IR1 | ||
; RUN: FileCheck %s -input-file=%t_1.ll --check-prefixes CHECK-IR2 | ||
; RUN: FileCheck %s -input-file=%t_0.sym --check-prefixes CHECK-SYM1 | ||
; RUN: FileCheck %s -input-file=%t_1.sym --check-prefixes CHECK-SYM2 | ||
|
||
; This test checks that unreferenced functions with sycl-module-id | ||
; attribute are not dropped from the module after splitting | ||
; in per-source mode. | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
target triple = "spir64-unknown-linux-sycldevice" | ||
|
||
define dso_local spir_func void @externalDeviceFunc() #0 { | ||
ret void | ||
} | ||
|
||
define dso_local spir_kernel void @kernel1() #1 { | ||
ret void | ||
} | ||
|
||
attributes #0 = { "sycl-module-id"="a.cpp" } | ||
attributes #1 = { "sycl-module-id"="b.cpp" } | ||
|
||
; CHECK-IR1: define dso_local spir_func void @externalDeviceFunc() | ||
DenisBakhvalov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
; CHECK-IR2: define dso_local spir_kernel void @kernel1() | ||
|
||
; CHECK-SYM1: externalDeviceFunc | ||
; CHECK-SYM2: kernel1 |
30 changes: 30 additions & 0 deletions
30
llvm/test/tools/sycl-post-link/sycl-external-funcs/split-per-source2.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,30 @@ | ||
; RUN: sycl-post-link -split=source -symbols -S %s -o %t.table | ||
; RUN: FileCheck %s -input-file=%t_0.ll --check-prefixes CHECK-IR1 | ||
; RUN: FileCheck %s -input-file=%t_1.ll --check-prefixes CHECK-IR2 | ||
; RUN: FileCheck %s -input-file=%t_0.sym --check-prefixes CHECK-SYM1 | ||
; RUN: FileCheck %s -input-file=%t_1.sym --check-prefixes CHECK-SYM2 | ||
|
||
; This test checks that the definition of function externalDeviceFunc is | ||
; present in both resulting modules when per-source split is requested. | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" | ||
target triple = "spir64-unknown-linux-sycldevice" | ||
|
||
define dso_local spir_func void @externalDeviceFunc() #0 { | ||
ret void | ||
} | ||
|
||
define dso_local spir_kernel void @kernel1() #1 { | ||
call void @externalDeviceFunc() | ||
ret void | ||
} | ||
|
||
attributes #0 = { "sycl-module-id"="a.cpp" } | ||
attributes #1 = { "sycl-module-id"="b.cpp" } | ||
|
||
; CHECK-IR1: define dso_local spir_func void @externalDeviceFunc() | ||
DenisBakhvalov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
; CHECK-IR2: define dso_local spir_func void @externalDeviceFunc() | ||
; CHECK-IR2: define dso_local spir_kernel void @kernel1() | ||
|
||
; CHECK-SYM1: externalDeviceFunc | ||
; CHECK-SYM2: kernel1 |
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 |
---|---|---|
|
@@ -6,20 +6,22 @@ | |
; RUN: FileCheck %s -input-file=%t.files.table --check-prefixes CHECK-TABLE | ||
; RUN: FileCheck %s -input-file=%t.files_0.sym --match-full-lines --check-prefixes CHECK-SYM | ||
|
||
define dso_local spir_kernel void @KERNEL_AAA() { | ||
define dso_local spir_kernel void @KERNEL_AAA() #0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
; CHECK-SYM-NOT: {{[a-zA-Z0-9._@]+}} | ||
; CHECK-SYM: KERNEL_AAA | ||
entry: | ||
ret void | ||
} | ||
|
||
define dso_local spir_kernel void @KERNEL_BBB() { | ||
define dso_local spir_kernel void @KERNEL_BBB() #0 { | ||
; CHECK-SYM-NEXT: KERNEL_BBB | ||
; CHECK-SYM-EMPTY: | ||
entry: | ||
ret void | ||
} | ||
|
||
attributes #0 = { "sycl-module-id"="a.cpp" } | ||
|
||
; CHECK-TABLE: [Code|Properties|Symbols] | ||
; CHECK-TABLE-NEXT: {{.*}}files_0.sym | ||
; CHECK-TABLE-EMPTY: |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, why do we need to add the attribute to this test. Why It wasn't here before? Is it not possible to process the code without the attribute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, this is how we detect whether the function should be considered as an entry point or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct.