Skip to content

[sycl-post-link] Adds property listing exported functions #4626

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8941,6 +8941,7 @@ void SYCLPostLink::ConstructJob(Compilation &C, const JobAction &JA,
// Symbol file and specialization constant info generation is mandatory -
// add options unconditionally
addArgs(CmdArgs, TCArgs, {"-symbols"});
addArgs(CmdArgs, TCArgs, {"-emit-exported-symbols"});
addArgs(CmdArgs, TCArgs, {"-split-esimd"});
addArgs(CmdArgs, TCArgs, {"-lower-esimd"});
}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/sycl-device-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
// RUN: | FileCheck %s -check-prefix=SYCL_LLVM_LINK_NO_DEVICE_LIB
// SYCL_LLVM_LINK_NO_DEVICE_LIB: clang{{.*}} "-cc1" {{.*}} "-fsycl-is-device"
// SYCL_LLVM_LINK_NO_DEVICE_LIB-NOT: llvm-link{{.*}} "-only-needed"
// SYCL_LLVM_LINK_NO_DEVICE_LIB: sycl-post-link{{.*}} "-symbols" "-split-esimd" "-lower-esimd" "-O2" "-spec-const=rt" "-o" "{{.*}}.table" "{{.*}}.bc"
// SYCL_LLVM_LINK_NO_DEVICE_LIB: sycl-post-link{{.*}} "-symbols" "-emit-exported-symbols" "-split-esimd" "-lower-esimd" "-O2" "-spec-const=rt" "-o" "{{.*}}.table" "{{.*}}.bc"

/// ###########################################################################
/// test llvm-link behavior for special user input whose filename resembles SYCL device library
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Support/PropertySetIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class PropertySetRegistry {
static constexpr char SYCL_PROGRAM_METADATA[] = "SYCL/program metadata";
static constexpr char SYCL_MISC_PROP[] = "SYCL/misc properties";
static constexpr char SYCL_ASSERT_USED[] = "SYCL/assert used";
static constexpr char SYCL_EXPORTED_SYMBOLS[] = "SYCL/exported symbols";

// Function for bulk addition of an entire property set under given category
// (property set name).
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Support/PropertySetIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ constexpr char PropertySetRegistry::SYCL_KERNEL_PARAM_OPT_INFO[];
constexpr char PropertySetRegistry::SYCL_PROGRAM_METADATA[];
constexpr char PropertySetRegistry::SYCL_MISC_PROP[];
constexpr char PropertySetRegistry::SYCL_ASSERT_USED[];
constexpr char PropertySetRegistry::SYCL_EXPORTED_SYMBOLS[];

} // namespace util
} // namespace llvm
94 changes: 94 additions & 0 deletions llvm/test/tools/sycl-post-link/emit_exported_symbols.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
; This test checks that the post-link tool generates list of exported symbols.
;
; Global scope
; RUN: sycl-post-link -symbols -emit-exported-symbols -S %s -o %t.global.files.table
; RUN: FileCheck %s -input-file=%t.global.files_0.prop --implicit-check-not="NotExported" --check-prefix=CHECK-GLOBAL-PROP
;
; Per-module split
; RUN: sycl-post-link -symbols -split=source -emit-exported-symbols -S %s -o %t.per_module.files.table
; RUN: FileCheck %s -input-file=%t.per_module.files_0.prop -implicit-check-not="NotExported" --check-prefix=CHECK-PERMODULE-0-PROP
; RUN: FileCheck %s -input-file=%t.per_module.files_1.prop -implicit-check-not="NotExported" --check-prefix=CHECK-PERMODULE-1-PROP
; RUN: FileCheck %s -input-file=%t.per_module.files_2.prop -implicit-check-not="NotExported" --check-prefix=CHECK-KERNELONLY-PROP
;
; Per-kernel split
; RUN: sycl-post-link -symbols -split=kernel -emit-exported-symbols -S %s -o %t.per_kernel.files.table
; RUN: FileCheck %s -input-file=%t.per_kernel.files_0.prop --implicit-check-not="NotExported" --check-prefix=CHECK-PERKERNEL-0-PROP
; RUN: FileCheck %s -input-file=%t.per_kernel.files_1.prop --implicit-check-not="NotExported" --check-prefix=CHECK-PERKERNEL-1-PROP
; RUN: FileCheck %s -input-file=%t.per_kernel.files_2.prop --implicit-check-not="NotExported" --check-prefix=CHECK-PERKERNEL-2-PROP
; RUN: FileCheck %s -input-file=%t.per_kernel.files_3.prop --implicit-check-not="NotExported" --check-prefix=CHECK-KERNELONLY-PROP
; RUN: FileCheck %s -input-file=%t.per_kernel.files_4.prop --implicit-check-not="NotExported" --check-prefix=CHECK-KERNELONLY-PROP

target triple = "spir64-unknown-unknown"

define dso_local spir_kernel void @NotExportedSpirKernel1(float %arg1) #0 {
entry:
ret void
}

define dso_local spir_kernel void @NotExportedSpirKernel2(float %arg1) #2 {
entry:
ret void
}

define dso_local spir_func void @ExportedSpirFunc1(float %arg1) #0 {
entry:
ret void
}

define dso_local spir_func void @ExportedSpirFunc2(i32 %arg1, i32 %arg2) #1 {
entry:
ret void
}

define dso_local spir_func void @ExportedSpirFunc3(float %arg1) #0 {
entry:
ret void
}

define dso_local spir_func void @NotExportedSpirFunc1(float %arg1) {
entry:
ret void
}

attributes #0 = { "sycl-module-id"="a.cpp" }
attributes #1 = { "sycl-module-id"="b.cpp" }
attributes #2 = { "sycl-module-id"="c.cpp" }

; Global scope
; CHECK-GLOBAL-PROP: [SYCL/exported symbols]
; CHECK-GLOBAL-PROP-NEXT: ExportedSpirFunc1
; CHECK-GLOBAL-PROP-NEXT: ExportedSpirFunc2
; CHECK-GLOBAL-PROP-NEXT: ExportedSpirFunc3

; Per-module split
; CHECK-PERMODULE-0-PROP: [SYCL/exported symbols]
; CHECK-PERMODULE-0-PROP-NEXT: ExportedSpirFunc1
; CHECK-PERMODULE-0-PROP-NEXT: ExportedSpirFunc3
; CHECK-PERMODULE-0-PROP-NOT: ExportedSpirFunc2

; CHECK-PERMODULE-1-PROP: [SYCL/exported symbols]
; CHECK-PERMODULE-1-PROP-NEXT: ExportedSpirFunc2
; CHECK-PERMODULE-1-PROP-NOT: ExportedSpirFunc1
; CHECK-PERMODULE-1-PROP-NOT: ExportedSpirFunc3

; Per-kernel split
; CHECK-PERKERNEL-0-PROP: [SYCL/exported symbols]
; CHECK-PERKERNEL-0-PROP-NEXT: ExportedSpirFunc1
; CHECK-PERKERNEL-0-PROP-NOT: ExportedSpirFunc2
; CHECK-PERKERNEL-0-PROP-NOT: ExportedSpirFunc3

; CHECK-PERKERNEL-1-PROP: [SYCL/exported symbols]
; CHECK-PERKERNEL-1-PROP-NEXT: ExportedSpirFunc2
; CHECK-PERKERNEL-1-PROP-NOT: ExportedSpirFunc1
; CHECK-PERKERNEL-1-PROP-NOT: ExportedSpirFunc3

; CHECK-PERKERNEL-2-PROP: [SYCL/exported symbols]
; CHECK-PERKERNEL-2-PROP-NEXT: ExportedSpirFunc3
; CHECK-PERKERNEL-2-PROP-NOT: ExportedSpirFunc1
; CHECK-PERKERNEL-2-PROP-NOT: ExportedSpirFunc2

; Kernel-only generated modules should have no exported Symbols
; CHECK-KERNELONLY-PROP-NOT: [SYCL/exported symbols]
; CHECK-KERNELONLY-PROP-NOT: ExportedSpirFunc3
; CHECK-KERNELONLY-PROP-NOT: ExportedSpirFunc1
; CHECK-KERNELONLY-PROP-NOT: ExportedSpirFunc2
Loading