Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/DebugInfo/DebugControlFlow.cl

raw
1 // RUN: %clang_cc1 -triple spir64-unknown-unknown -cl-std=CL2.0 -O0 -debug-info-kind=standalone -gno-column-info -emit-llvm %s -o %t.ll
2 // RUN: llvm-as %t.ll -o %t.bc
3 // RUN: llvm-spirv %t.bc -spirv-text -o %t.spt
4 // RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
5 // RUN: llvm-spirv %t.bc -o %t.spv
6 // RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.bc
7 // RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-LLVM
8
9 // Test that no debug info instruction is inserted
10 // between LoopMerge and Branch/BranchConditional instructions.
11 // Otherwise, debug info interferes with SPIRVToLLVM translation
12 // of structured flow control
13
14 kernel
15 void sample() {
16 int arr[10];
17 #pragma clang loop unroll(enable)
18 for (int i = 0; i < 10; i++)
19 arr[i] = 0;
20 int j = 0;
21 #pragma clang loop unroll(enable)
22 do {
23 arr[j] = 0;
24 } while (j++ < 10);
25 }
26
27 // Check that all Line items are retained
28 // CHECK-SPIRV: Line [[File:[0-9]+]] 18 0
29 // Control flow
30 // CHECK-SPIRV: {{[0-9]+}} LoopMerge [[MergeBlock:[0-9]+]] [[ContinueTarget:[0-9]+]] 1
31 // CHECK-SPIRV-NEXT: BranchConditional
32
33 // Check that all Line items are retained
34 // CHECK-SPIRV: Line [[File]] 23 0
35 // CHECK-SPIRV: Line [[File]] 24 0
36 // Control flow
37 // CHECK-SPIRV: {{[0-9]+}} LoopMerge [[MergeBlock:[0-9]+]] [[ContinueTarget:[0-9]+]] 1
38 // CHECK-SPIRV-NEXT: Branch
39
40 // CHECK-LLVM: br label %{{.*}}, !dbg !{{[0-9]+}}, !llvm.loop ![[MD:[0-9]+]]
41 // CHECK-LLVM: ![[MD]] = distinct !{![[MD]], ![[MD_unroll:[0-9]+]]}
42 // CHECK-LLVM: ![[MD_unroll]] = !{!"llvm.loop.unroll.enable"}