File tree Expand file tree Collapse file tree 3 files changed +56
-2
lines changed
test/tools/sycl-post-link Expand file tree Collapse file tree 3 files changed +56
-2
lines changed Original file line number Diff line number Diff line change
1
+ ; This test checks that the post-link tool doesn't incorrectly remove function
2
+ ; declarations which are still in use while erasing the "llvm.used" global.
3
+ ;
4
+ ; RUN: sycl-post-link -split=auto -symbols -S %s -o %t.files.table
5
+ ; RUN: FileCheck %s -input-file=%t.files_0.ll
6
+ ;
7
+ target triple = "spir64-unknown-unknown"
8
+
9
+ ; CHECK-NOT: llvm.used
10
+ @llvm.used = appending global [2 x ptr ] [ptr @notused , ptr @stillused ], section "llvm.metadata"
11
+
12
+ ; CHECK: declare spir_func void @stillused
13
+ declare spir_func void @stillused () #0
14
+ declare spir_func void @notused () #0
15
+
16
+ define spir_kernel void @entry () #0 {
17
+ call spir_func void @stillused ()
18
+ ret void
19
+ }
20
+
21
+ define spir_kernel void @bar () #0 {
22
+ ret void
23
+ }
24
+
25
+ attributes #0 = { "sycl-module-id" ="erase_used_decl.cpp" }
Original file line number Diff line number Diff line change
1
+ ; This test checks that the post-link tool does not add "llvm.used" global to
2
+ ; the output modules when splitting modules, creating a single row table,
3
+ ; and outputing IR only
4
+ ;
5
+ ; RUN: sycl-post-link -split=kernel -S %s -o %t.files.table
6
+ ; RUN: FileCheck %s -input-file=%t.files_0.ll
7
+ ; RUN: FileCheck %s -input-file=%t.files_1.ll
8
+ ;
9
+ ; RUN: sycl-post-link -S -split=auto -symbols -split-esimd -lower-esimd -O2 -spec-const=default %s -o %t.out.table
10
+ ; RUN: FileCheck %s --input-file=%t.out_0.ll
11
+ ;
12
+ ; RUN: sycl-post-link -S -split=auto -ir-output-only %s -o %t.out_ir_only.ll
13
+ ; RUN: FileCheck %s --input-file %t.out_ir_only.ll
14
+
15
+ target triple = "spir64-unknown-unknown"
16
+
17
+ ; CHECK-NOT: llvm.used
18
+ @llvm.used = appending global [2 x ptr ] [ptr @foo , ptr @bar ], section "llvm.metadata"
19
+
20
+ define weak_odr spir_kernel void @foo () #0 {
21
+ ret void
22
+ }
23
+
24
+ define weak_odr spir_kernel void @bar () #0 {
25
+ ret void
26
+ }
27
+
28
+ attributes #0 = { "sycl-module-id" ="a.cpp" }
Original file line number Diff line number Diff line change @@ -627,11 +627,12 @@ static bool removeSYCLKernelsConstRefArray(Module &M) {
627
627
" Cannot remove initializer of llvm.used global" );
628
628
Initializer->destroyConstant ();
629
629
for (auto It = IOperands.begin (); It != IOperands.end (); It++) {
630
- auto Op = (*It)->getOperand ( 0 );
630
+ auto Op = (*It)->stripPointerCasts ( );
631
631
auto *F = dyn_cast<Function>(Op);
632
632
if (llvm::isSafeToDestroyConstant (*It)) {
633
633
(*It)->destroyConstant ();
634
- } else if (F) {
634
+ } else if (F && F->getCallingConv () == CallingConv::SPIR_KERNEL &&
635
+ !F->use_empty ()) {
635
636
// The element in "llvm.used" array has other users. That is Ok for
636
637
// specialization constants, but is wrong for kernels.
637
638
llvm::report_fatal_error (" Unexpected usage of SYCL kernel" );
You can’t perform that action at this time.
0 commit comments