Skip to content

Commit c74a624

Browse files
authored
[sycl-post-link] Don't split module if function pointer has a user that's not CallInst (intel#4657)
1 parent cee76d9 commit c74a624

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
; RUN: sycl-post-link -split=auto -symbols -S %s -o %t.table
2+
; RUN: FileCheck %s -input-file=%t_0.sym
3+
4+
; This test checkes that module is not split if function pointer's user is not
5+
; CallInst.
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-n8:16:32:64"
8+
target triple = "spir64_x86_64-unknown-unknown"
9+
10+
@_Z2f1iTable = weak global [1 x i32 (i32)*] [i32 (i32)* @_Z2f1i], align 8
11+
12+
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
13+
define dso_local spir_func i32 @_Z2f1i(i32 %a) #0 {
14+
entry:
15+
ret i32 %a
16+
}
17+
18+
; Function Attrs: convergent norecurse
19+
define weak_odr dso_local spir_kernel void @kernel1() #1 {
20+
entry:
21+
%0 = call i32 @indirect_call(i32 (i32)* addrspace(4)* addrspacecast (i32 (i32)** getelementptr inbounds ([1 x i32 (i32)*], [1 x i32 (i32)*]* @_Z2f1iTable, i64 0, i64 0) to i32 (i32)* addrspace(4)*), i32 0)
22+
ret void
23+
}
24+
25+
; Function Attrs: convergent norecurse
26+
define dso_local spir_kernel void @kernel2() #2 {
27+
entry:
28+
ret void
29+
}
30+
31+
declare dso_local spir_func i32 @indirect_call(i32 (i32)* addrspace(4)*, i32) local_unnamed_addr
32+
33+
attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone willreturn }
34+
attributes #1 = { convergent norecurse "sycl-module-id"="TU1.cpp" }
35+
attributes #2 = { convergent norecurse "sycl-module-id"="TU2.cpp" }
36+
37+
; CHECK: kernel1
38+
; CHECK: kernel2

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ static KernelMapEntryScope selectDeviceCodeSplitScopeAutomatically(Module &M) {
239239
}
240240
}
241241
}
242+
// Function pointer is used somewhere. Follow the same rule as above.
243+
for (const auto *U : F.users())
244+
if (!isa<CallInst>(U))
245+
return Scope_Global;
242246
}
243247

244248
// At the moment, we assume that per-source split is the best way of splitting

0 commit comments

Comments
 (0)