Skip to content

Commit

Permalink
[sycl-post-link] Don't split module if function pointer has a user th…
Browse files Browse the repository at this point in the history
…at's not CallInst (intel#4657)
  • Loading branch information
wenju-he authored Sep 30, 2021
1 parent cee76d9 commit c74a624
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
38 changes: 38 additions & 0 deletions llvm/test/tools/sycl-post-link/auto-module-split-func-ptr.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
; RUN: sycl-post-link -split=auto -symbols -S %s -o %t.table
; RUN: FileCheck %s -input-file=%t_0.sym

; This test checkes that module is not split if function pointer's user is not
; CallInst.

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"
target triple = "spir64_x86_64-unknown-unknown"

@_Z2f1iTable = weak global [1 x i32 (i32)*] [i32 (i32)* @_Z2f1i], align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
define dso_local spir_func i32 @_Z2f1i(i32 %a) #0 {
entry:
ret i32 %a
}

; Function Attrs: convergent norecurse
define weak_odr dso_local spir_kernel void @kernel1() #1 {
entry:
%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)
ret void
}

; Function Attrs: convergent norecurse
define dso_local spir_kernel void @kernel2() #2 {
entry:
ret void
}

declare dso_local spir_func i32 @indirect_call(i32 (i32)* addrspace(4)*, i32) local_unnamed_addr

attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone willreturn }
attributes #1 = { convergent norecurse "sycl-module-id"="TU1.cpp" }
attributes #2 = { convergent norecurse "sycl-module-id"="TU2.cpp" }

; CHECK: kernel1
; CHECK: kernel2
4 changes: 4 additions & 0 deletions llvm/tools/sycl-post-link/sycl-post-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ static KernelMapEntryScope selectDeviceCodeSplitScopeAutomatically(Module &M) {
}
}
}
// Function pointer is used somewhere. Follow the same rule as above.
for (const auto *U : F.users())
if (!isa<CallInst>(U))
return Scope_Global;
}

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

0 comments on commit c74a624

Please sign in to comment.