Skip to content

Commit b3f5600

Browse files
Fixed code review comments
1 parent c59db7d commit b3f5600

File tree

7 files changed

+63
-15
lines changed

7 files changed

+63
-15
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; RUN: sycl-post-link -ir-output-only -split=auto -S %s -o %t.ll
2+
; RUN: FileCheck %s -input-file=%t.ll
3+
4+
; This test checks that unreferenced functions without sycl-module-id
5+
; attribute are dropped from the module after splitting.
6+
7+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
8+
target triple = "spir64-unknown-linux-sycldevice"
9+
10+
define dso_local spir_func void @externalDeviceFunc() #0 {
11+
ret void
12+
}
13+
14+
define dso_local spir_func void @unreferencedFunc() {
15+
ret void
16+
}
17+
18+
attributes #0 = { "sycl-module-id"="a.cpp" }
19+
20+
; CHECK: define dso_local spir_func void @externalDeviceFunc()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; RUN: sycl-post-link -ir-output-only -split=auto -S %s -o %t.ll
2+
; RUN: FileCheck %s -input-file=%t.ll
3+
4+
; This test checks that indirectly referenced functions (with sycl-module-id
5+
; attribute) are not dropped from the module.
6+
7+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
8+
target triple = "spir64-unknown-linux-sycldevice"
9+
10+
define dso_local spir_func void @indRefDeviceFunc() #0 {
11+
ret void
12+
}
13+
14+
attributes #0 = { "sycl-module-id"="a.cpp" "referenced-indirectly"}
15+
16+
; CHECK: define dso_local spir_func void @indRefDeviceFunc()

llvm/test/tools/sycl-post-link/sycl-external-funcs/split-and-lower-esimd.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
; RUN: sycl-post-link -split=auto -split-esimd -lower-esimd -O0 -S %s -o %t.table
22
; RUN: FileCheck %s -input-file=%t_esimd_0.ll
33

4-
; This test checks that unreferenced functions are not dropped
5-
; from the module and ESIMD lowering happens for them as well.
4+
; This test checks that unreferenced functions with sycl-module-id
5+
; attribute are not dropped from the module and ESIMD lowering
6+
; happens for them as well.
67

78
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
89
target triple = "spir64-unknown-linux-sycldevice"

llvm/test/tools/sycl-post-link/sycl-external-funcs/split-global.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
; RUN: sycl-post-link -ir-output-only -split=auto -S %s -o %t.ll
22
; RUN: FileCheck %s -input-file=%t.ll
33

4-
; This test checks that unreferenced functions are not dropped
5-
; from the module after splitting in global mode.
4+
; This test checks that unreferenced functions with sycl-module-id
5+
; attribute are not dropped from the module after splitting
6+
; in global mode.
67

78
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
89
target triple = "spir64-unknown-linux-sycldevice"

llvm/test/tools/sycl-post-link/sycl-external-funcs/split-per-kernel.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
; RUN: FileCheck %s -input-file=%t_0.sym --check-prefixes CHECK-SYM1
55
; RUN: FileCheck %s -input-file=%t_1.sym --check-prefixes CHECK-SYM2
66

7-
; This test checks that unreferenced functions are not dropped
8-
; from the module after splitting in per-kernel mode.
7+
; This test checks that unreferenced functions with sycl-module-id
8+
; attribute are not dropped from the module after splitting
9+
; in per-kernel mode.
910

1011
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
1112
target triple = "spir64-unknown-linux-sycldevice"

llvm/test/tools/sycl-post-link/sycl-external-funcs/split-per-source1.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
; RUN: FileCheck %s -input-file=%t_0.sym --check-prefixes CHECK-SYM1
55
; RUN: FileCheck %s -input-file=%t_1.sym --check-prefixes CHECK-SYM2
66

7-
; This test checks that unreferenced functions are not dropped
8-
; from the module after splitting in per-source mode.
7+
; This test checks that unreferenced functions with sycl-module-id
8+
; attribute are not dropped from the module after splitting
9+
; in per-source mode.
910

1011
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
1112
target triple = "spir64-unknown-linux-sycldevice"

llvm/tools/sycl-post-link/sycl-post-link.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,14 @@ static void collectKernelModuleMap(
242242
Module &M, std::map<StringRef, std::vector<Function *>> &ResKernelModuleMap,
243243
KernelMapEntryScope EntryScope) {
244244

245+
// Process module entry points: kernels and SYCL_EXTERNAL functions.
246+
// Only they have sycl-module-id attribute, so any other unrefenced
247+
// functions are dropped.
245248
for (auto &F : M.functions()) {
246-
// Process module entry points: kernels and SYCL_EXTERNAL functions.
247-
// Only they have sycl-module-id attribute, so any other unrefenced
248-
// functions are dropped.
249+
if (!F.isDeclaration() && F.getCallingConv() != CallingConv::SPIR_KERNEL &&
250+
F.getCallingConv() != CallingConv::SPIR_FUNC) {
251+
error("Unsupported calling convention in function " + F.getName());
252+
}
249253
if (F.hasFnAttribute(ATTR_SYCL_MODULE_ID)) {
250254
switch (EntryScope) {
251255
case Scope_PerKernel:
@@ -637,13 +641,17 @@ using ModulePair = std::pair<std::unique_ptr<Module>, std::unique_ptr<Module>>;
637641
// This function splits a module with a mix of SYCL and ESIMD kernels
638642
// into two separate modules.
639643
static ModulePair splitSyclEsimd(std::unique_ptr<Module> M) {
640-
// Collect information about the SYCL and ESIMD kernels in the module.
641644
std::vector<Function *> SyclFunctions;
642645
std::vector<Function *> EsimdFunctions;
646+
// Collect information about the SYCL and ESIMD functions in the module.
647+
// Process module entry points: kernels and SYCL_EXTERNAL functions.
648+
// Only they have sycl-module-id attribute, so any other unrefenced
649+
// functions are dropped.
643650
for (auto &F : M->functions()) {
644-
// Process module entry points: kernels and SYCL_EXTERNAL functions.
645-
// Only they have sycl-module-id attribute, so any other unrefenced
646-
// functions are dropped.
651+
if (!F.isDeclaration() && F.getCallingConv() != CallingConv::SPIR_KERNEL &&
652+
F.getCallingConv() != CallingConv::SPIR_FUNC) {
653+
error("Unsupported calling convention in function " + F.getName());
654+
}
647655
if (F.hasFnAttribute(ATTR_SYCL_MODULE_ID)) {
648656
if (F.getMetadata("sycl_explicit_simd"))
649657
EsimdFunctions.push_back(&F);

0 commit comments

Comments
 (0)