Skip to content

[sycl-post-link] Don't split module if function pointer has a user th… #4657

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2021
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
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 @@ -231,6 +231,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