| 1 |
// Check for 2 things: |
| 2 |
// - After round trip translation function definition has !dbg metadata attached |
| 3 |
// specifically if -gline-tables-only was used for Clang |
| 4 |
// - Parent operand of DebugFunction is DebugCompilationUnit, not an OpString, |
| 5 |
// even if in LLVM IR it points to a DIFile instead of DICompileUnit. |
| 6 |
|
| 7 |
// RUN: %clang_cc1 %s -cl-std=clc++ -emit-llvm-bc -triple spir -debug-info-kind=line-tables-only -O0 -o %t.bc |
| 8 |
// RUN: llvm-spirv %t.bc --spirv-debug-info-version=nonsemantic-shader-100 -o %t.spv |
| 9 |
// RUN: llvm-spirv %t.spv -to-text -o %t.spt |
| 10 |
// RUN: FileCheck %s --input-file %t.spt --check-prefix=CHECK-SPIRV |
| 11 |
|
| 12 |
// RUN: llvm-spirv %t.bc --spirv-debug-info-version=nonsemantic-shader-200 -o %t.spv |
| 13 |
// RUN: llvm-spirv %t.spv -to-text -o %t.spt |
| 14 |
// RUN: FileCheck %s --input-file %t.spt --check-prefix=CHECK-SPIRV |
| 15 |
|
| 16 |
// RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-LLVM |
| 17 |
|
| 18 |
float foo(int i) { |
| 19 |
return i * 3.14; |
| 20 |
} |
| 21 |
void kernel k() { |
| 22 |
float a = foo(2); |
| 23 |
} |
| 24 |
|
| 25 |
// CHECK-SPIRV-DAG: String [[foo:[0-9]+]] "foo" |
| 26 |
// CHECK-SPIRV-DAG: String [[#EmptyStr:]] "" |
| 27 |
// CHECK-SPIRV-DAG: String [[k:[0-9]+]] "k" |
| 28 |
// CHECK-SPIRV-DAG: String [[#CV:]] {{.*}}clang version [[#]].[[#]].[[#]] |
| 29 |
// CHECK-SPIRV: [[#CU:]] [[#]] DebugCompilationUnit |
| 30 |
// CHECK-SPIRV: [[#FuncFoo:]] [[#]] DebugFunction [[foo]] {{.*}} [[#CU]] |
| 31 |
// CHECK-SPIRV: [[#FuncK:]] [[#]] DebugFunction [[k]] {{.*}} [[#CU]] |
| 32 |
// CHECK-SPIRV: DebugEntryPoint [[#FuncK]] [[#CU]] [[#CV]] [[#EmptyStr]] {{$}} |
| 33 |
// CHECK-SPIRV-NOT: DebugEntryPoint |
| 34 |
// CHECK-SPIRV-NOT: DebugFunctionDefinition |
| 35 |
|
| 36 |
// CHECK-SPIRV: Function {{[0-9]+}} [[#foo_id:]] |
| 37 |
// CHECK-SPIRV: DebugFunctionDefinition [[#FuncFoo]] [[#foo_id]] |
| 38 |
// CHECK-LLVM: define spir_func float @_Z3fooi(i32 %i) #{{[0-9]+}} !dbg ![[#foo_id:]] { |
| 39 |
|
| 40 |
// CHECK-SPIRV: Function {{[0-9]+}} [[#k_id:]] |
| 41 |
// CHECK-SPIRV: DebugFunctionDefinition [[#FuncK]] [[#k_id]] |
| 42 |
// CHECK-LLVM: define spir_kernel void @k() #{{[0-9]+}} !dbg ![[#k_id:]] |
| 43 |
|
| 44 |
// CHECK-LLVM: ![[#foo_id]] = distinct !DISubprogram(name: "foo" |
| 45 |
// CHECK-LLVM-SAME: spFlags: DISPFlagDefinition, |
| 46 |
// CHECK-LLVM: ![[#k_id]] = distinct !DISubprogram(name: "k" |
| 47 |
// CHECK-LLVM-SAME: spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, |