Skip to content

[SYCL][NFC] Optimize getKernelNamesUsingAssert #5196

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 5 commits into from
Dec 27, 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
30 changes: 18 additions & 12 deletions llvm/test/tools/sycl-post-link/assert-indirect-with-split-2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
; marked as using asserts.

; RUN: sycl-post-link -split=auto -symbols -S %s -o %t.table
; RUN: FileCheck %s -input-file=%t_0.prop
; RUN: FileCheck %s -input-file=%t_0.prop -check-prefix=PRESENCE-CHECK
; RUN: FileCheck %s -input-file=%t_0.prop -check-prefix=ABSENCE-CHECK

target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir64-unknown-linux"
Expand All @@ -22,9 +23,9 @@ target triple = "spir64-unknown-linux"
@__spirv_BuiltInLocalInvocationId = external dso_local local_unnamed_addr addrspace(1) constant <3 x i64>, align 32
@_ZL10assert_fmt = internal addrspace(2) constant [85 x i8] c"%s:%d: %s: global id: [%lu,%lu,%lu], local id: [%lu,%lu,%lu] Assertion `%s` failed.\0A\00", align 1

; CHECK: [SYCL/assert used]
; PRESENCE-CHECK: [SYCL/assert used]

; CHECK-DAG: main_TU1_kernel1
; PRESENCE-CHECK-DAG: main_TU1_kernel1
define dso_local spir_kernel void @main_TU1_kernel1() #2 {
entry:
call spir_func void @foo()
Expand All @@ -38,14 +39,20 @@ entry:
ret void
}

; ABSENCE-CHECK-NOT: empty_kernel
define dso_local spir_kernel void @empty_kernel() {
%1 = ptrtoint void ()* @bar to i64
ret void
}

define dso_local spir_func void @bar() #2 {
entry:
call spir_func void @_Z3foov() ; call assert
call spir_func void @_Z4foo2v() ; indirectly called
ret void
}

; CHECK-DAG: main_TU0_kernel0
; PRESENCE-CHECK-DAG: main_TU0_kernel0
define dso_local spir_kernel void @main_TU0_kernel0() #0 {
entry:
call spir_func void @_Z3foov() ; call assert
Expand All @@ -63,13 +70,6 @@ entry:
ret void
}

; CHECK-NOT: main_TU0_kernel1
define dso_local spir_kernel void @main_TU0_kernel1() #0 {
entry:
call spir_func void @_Z4foo1v()
ret void
}

; Function Attrs: nounwind
define dso_local spir_func void @_Z4foo1v() {
entry:
Expand All @@ -78,13 +78,19 @@ entry:
ret void
}

; CHECK-DAG: main_TU1_kernel0
; PRESENCE-CHECK-DAG: main_TU1_kernel0
define dso_local spir_kernel void @main_TU1_kernel0() #2 {
entry:
call spir_func void @_Z3foov() ; call assert
ret void
}

; ABSENCE-CHECK-NOT: main_TU0_kernel1
define dso_local spir_kernel void @main_TU0_kernel1() #0 {
entry:
call spir_func void @_Z4foo1v()
ret void
}

; This function is marked with "referenced-indirectly", but it doesn't call an assert
; Function Attrs: nounwind
Expand Down
11 changes: 6 additions & 5 deletions llvm/test/tools/sycl-post-link/assert-property-1.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
; graph.

; RUN: sycl-post-link -split=auto -symbols -S %s -o %t.table
; RUN: FileCheck %s -input-file=%t_0.prop
; RUN: FileCheck %s -input-file=%t_0.prop -check-prefix=PRESENCE-CHECK
; RUN: FileCheck %s -input-file=%t_0.prop -check-prefix=ABSENCE-CHECK

; SYCL source:
; void foo() {
Expand Down Expand Up @@ -48,7 +49,7 @@ target triple = "spir64_x86_64-unknown-unknown"
@__spirv_BuiltInLocalInvocationId = external dso_local addrspace(1) constant <3 x i64>, align 32
@_ZL10assert_fmt = internal addrspace(2) constant [85 x i8] c"%s:%d: %s: global id: [%lu,%lu,%lu], local id: [%lu,%lu,%lu] Assertion `%s` failed.\0A\00", align 1

; CHECK: [SYCL/assert used]
; PRESENCE-CHECK: [SYCL/assert used]

; Function Attrs: convergent norecurse nounwind mustprogress
define dso_local spir_func void @_Z3foov() {
Expand All @@ -57,7 +58,7 @@ entry:
ret void
}

; CHECK: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE9TheKernel
; PRESENCE-CHECK-DAG: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE9TheKernel
; Function Attrs: convergent norecurse
define weak_odr dso_local spir_kernel void @"_ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE9TheKernel"() #0 {
entry:
Expand All @@ -71,7 +72,7 @@ entry:
ret void
}

; CHECK-NOT: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE10TheKernel2
; ABSENCE-CHECK-NOT: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE10TheKernel2
; Function Attrs: norecurse
define weak_odr dso_local spir_kernel void @"_ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE10TheKernel2"() #1 {
entry:
Expand All @@ -94,7 +95,7 @@ entry:
ret void
}

; CHECK: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE10TheKernel3
; PRESENCE-CHECK-DAG: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE10TheKernel3
; Function Attrs: convergent norecurse
define weak_odr dso_local spir_kernel void @"_ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE10TheKernel3"() #0 {
entry:
Expand Down
41 changes: 21 additions & 20 deletions llvm/test/tools/sycl-post-link/assert-property-2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
; graph.

; RUN: sycl-post-link -split=auto -symbols -S %s -o %t.table
; RUN: FileCheck %s -input-file=%t_0.prop
; RUN: FileCheck %s -input-file=%t_0.prop -check-prefix=PRESENCE-CHECK
; RUN: FileCheck %s -input-file=%t_0.prop -check-prefix=ABSENCE-CHECK

; SYCL source:
; void assert_func() {
Expand Down Expand Up @@ -105,7 +106,7 @@ target triple = "spir64_x86_64-unknown-unknown"
@__PRETTY_FUNCTION__._Z11assert_funcv = private unnamed_addr addrspace(1) constant [19 x i8] c"void assert_func()\00", align 1
@_ZL10assert_fmt = internal addrspace(2) constant [85 x i8] c"%s:%d: %s: global id: [%lu,%lu,%lu], local id: [%lu,%lu,%lu] Assertion `%s` failed.\0A\00", align 1

; CHECK: [SYCL/assert used]
; PRESENCE-CHECK: [SYCL/assert used]

; Function Attrs: convergent noinline norecurse optnone mustprogress
define dso_local spir_func void @_Z1Jv() #3 {
Expand All @@ -122,15 +123,15 @@ entry:
ret void
}

; CHECK: _ZTSZZ4mainENKUlRN2cl4sycl7handlerEE_clES2_E7Kernel9
; PRESENCE-CHECK-DAG: _ZTSZZ4mainENKUlRN2cl4sycl7handlerEE_clES2_E7Kernel9
; Function Attrs: convergent noinline norecurse mustprogress
define weak_odr dso_local spir_kernel void @_ZTSZZ4mainENKUlRN2cl4sycl7handlerEE_clES2_E7Kernel9() #0 {
entry:
call spir_func void @_Z1Jv()
ret void
}

; CHECK: _ZTSZZ4mainENKUlRN2cl4sycl7handlerEE_clES2_E8Kernel10
; PRESENCE-CHECK-DAG: _ZTSZZ4mainENKUlRN2cl4sycl7handlerEE_clES2_E8Kernel10
; Function Attrs: convergent noinline norecurse optnone mustprogress
define weak_odr dso_local spir_kernel void @_ZTSZZ4mainENKUlRN2cl4sycl7handlerEE_clES2_E8Kernel10() #0 {
entry:
Expand Down Expand Up @@ -164,7 +165,7 @@ entry:
ret void
}

; CHECK: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE6Kernel
; PRESENCE-CHECK-DAG: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE6Kernel
; Function Attrs: convergent norecurse mustprogress
define weak_odr dso_local spir_kernel void @"_ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE6Kernel"() local_unnamed_addr #0 {
entry:
Expand All @@ -186,7 +187,7 @@ entry:
ret void
}

; CHECK: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel2
; PRESENCE-CHECK-DAG: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel2
; Function Attrs: convergent norecurse mustprogress
define weak_odr dso_local spir_kernel void @"_ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel2"() local_unnamed_addr #0 {
entry:
Expand Down Expand Up @@ -216,7 +217,7 @@ entry:
ret void
}

; CHECK: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel3
; PRESENCE-CHECK-DAG: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel3
; Function Attrs: convergent norecurse mustprogress
define weak_odr dso_local spir_kernel void @"_ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel3"() local_unnamed_addr #0 {
entry:
Expand Down Expand Up @@ -244,15 +245,15 @@ entry:
ret void
}

; CHECK: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel4
; PRESENCE-CHECK-DAG: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel4
; Function Attrs: convergent norecurse mustprogress
define weak_odr dso_local spir_kernel void @"_ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel4"() local_unnamed_addr #0 {
entry:
call spir_func void @_Z7common2v()
ret void
}

; CHECK: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel5
; PRESENCE-CHECK-DAG: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel5
; Function Attrs: convergent norecurse mustprogress
define weak_odr dso_local spir_kernel void @"_ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel5"() local_unnamed_addr #0 {
entry:
Expand All @@ -267,23 +268,14 @@ entry:
ret void
}

; CHECK-NOT: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel
; Function Attrs: convergent norecurse mustprogress
define weak_odr dso_local spir_kernel void @"_ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel6"() local_unnamed_addr #0 {
entry:
call spir_func void @_Z6E_exclv()
call spir_func void @_Z6E_exclv()
ret void
}

; Function Attrs: convergent norecurse nounwind mustprogress
define dso_local spir_func void @_Z6F_inclv() local_unnamed_addr {
entry:
call spir_func void @_Z11assert_funcv()
ret void
}

; CHECK: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel7
; PRESENCE-CHECK-DAG: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel7
; Function Attrs: convergent norecurse mustprogress
define weak_odr dso_local spir_kernel void @"_ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel7"() local_unnamed_addr #0 {
entry:
Expand Down Expand Up @@ -328,14 +320,23 @@ entry:
ret void
}

; CHECK: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel8
; PRESENCE-CHECK-DAG: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel8
; Function Attrs: convergent norecurse mustprogress
define weak_odr dso_local spir_kernel void @"_ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel8"() local_unnamed_addr #0 {
call spir_func void @_Z1Gv()
call spir_func void @_Z1Hv()
ret void
}

; ABSENCE-CHECK-NOT: _ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel6
; Function Attrs: convergent norecurse mustprogress
define weak_odr dso_local spir_kernel void @"_ZTSZZ4mainENK3$_0clERN2cl4sycl7handlerEE7Kernel6"() local_unnamed_addr #0 {
entry:
call spir_func void @_Z6E_exclv()
call spir_func void @_Z6E_exclv()
ret void
}

; Function Attrs: convergent norecurse mustprogress
define weak dso_local spir_func void @__assert_fail(i8 addrspace(4)* %expr, i8 addrspace(4)* %file, i32 %line, i8 addrspace(4)* %func) local_unnamed_addr {
entry:
Expand Down
23 changes: 12 additions & 11 deletions llvm/test/tools/sycl-post-link/assert-property-with-split.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
; in their call graph.

; RUN: sycl-post-link -split=auto -symbols -S %s -o %t.table
; RUN: FileCheck %s -input-file=%t_0.prop
; RUN: FileCheck %s -input-file=%t_0.prop -check-prefix=PRESENCE-CHECK
; RUN: FileCheck %s -input-file=%t_0.prop -check-prefix=ABSENCE-CHECK

target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir64-unknown-linux"
Expand All @@ -16,9 +17,9 @@ target triple = "spir64-unknown-linux"
@__spirv_BuiltInLocalInvocationId = external dso_local local_unnamed_addr addrspace(1) constant <3 x i64>, align 32
@_ZL10assert_fmt = internal addrspace(2) constant [85 x i8] c"%s:%d: %s: global id: [%lu,%lu,%lu], local id: [%lu,%lu,%lu] Assertion `%s` failed.\0A\00", align 1

; CHECK: [SYCL/assert used]
; PRESENCE-CHECK: [SYCL/assert used]

; CHECK: _ZTSZ4mainE11TU0_kernel0
; PRESENCE-CHECK-DAG: _ZTSZ4mainE11TU0_kernel0
define dso_local spir_kernel void @_ZTSZ4mainE11TU0_kernel0() #0 {
entry:
call spir_func void @_Z3foov()
Expand All @@ -36,7 +37,14 @@ entry:
ret void
}

; CHECK-NOT: _ZTSZ4mainE11TU0_kernel1
; PRESENCE-CHECK-DAG: _ZTSZ4mainE10TU1_kernel
define dso_local spir_kernel void @_ZTSZ4mainE10TU1_kernel() #1 {
entry:
call spir_func void @_Z4foo2v()
ret void
}

; ABSENCE-CHECK-NOT: _ZTSZ4mainE11TU0_kernel1
define dso_local spir_kernel void @_ZTSZ4mainE11TU0_kernel1() #0 {
entry:
call spir_func void @_Z4foo1v()
Expand All @@ -51,13 +59,6 @@ entry:
ret void
}

; CHECK: _ZTSZ4mainE10TU1_kernel
define dso_local spir_kernel void @_ZTSZ4mainE10TU1_kernel() #1 {
entry:
call spir_func void @_Z4foo2v()
ret void
}

; Function Attrs: nounwind
define dso_local spir_func void @_Z4foo2v() {
entry:
Expand Down
Loading