Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/DebugInfo/translate_sampler_initializer.ll

raw
1 ; Check that translator doesn't crash when translating debug info for
2 ; __translate_sampler_initializer() call with a constant argument;
3 ; LLVMToSPIRVDbgTran::transLocationInfo() method assumes that LLVM instructions
4 ; in the basic block are mapped to SPIR-V instructions in the corresponding
5 ; basic block. That's not true for __translate_sampler_initializer() call with
6 ; constant argument. Such call is being translated to an OpConstantSampler in
7 ; global scope.
8
9 ; Original .cl source:
10 ; void foo() {
11 ; const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;
12 ; }
13
14 ; Command line:
15 ; clang -cc1 -triple spir constant_sampler.cl -cl-std=cl2.0 -emit-llvm -o llvm-spirv/test/DebugInfo/translate_sampler_initializer.ll -finclude-default-header -debug-info-kind=standalone
16
17 ; RUN: llvm-as < %s -o %t.bc
18 ; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s
19
20 ; CHECK: TypeSampler [[#SamplerTy:]]
21 ; CHECK: ConstantSampler [[#SamplerTy]] [[#ConstSampler:]] 2 0 0
22
23 ; CHECK: ExtInst [[#]] [[#Func:]] [[#]] DebugFunction
24 ; CHECK: ExtInst [[#]] [[#SamplerVar:]] [[#]] DebugLocalVariable
25
26 ; CHECK: Label
27 ; CHECK-NEXT: ExtInst [[#]] [[#]] [[#]] DebugScope [[#Func]]
28 ; CHECK-NEXT: Line [[#]] 0 0
29 ; CHECK-NEXT: ExtInst [[#]] [[#]] [[#]] DebugValue [[#SamplerVar]] [[#ConstSampler]]
30 ; CHECK-NEXT: Line [[#]] 4 0
31 ; CHECK-NEXT: Return
32
33 source_filename = "constant_sampler.cl"
34 target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
35 target triple = "spir"
36
37 %opencl.sampler_t = type opaque
38
39 ; Function Attrs: norecurse nounwind
40 define spir_func void @foo() local_unnamed_addr #0 !dbg !7 {
41 entry:
42 %0 = tail call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 20) #2, !dbg !17
43 call void @llvm.dbg.value(metadata %opencl.sampler_t addrspace(2)* %0, metadata !12, metadata !DIExpression()), !dbg !18
44 ret void, !dbg !19
45 }
46
47 declare %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32) local_unnamed_addr
48
49 ; Function Attrs: nounwind readnone speculatable willreturn
50 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
51
52 attributes #0 = { norecurse nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
53 attributes #1 = { nounwind readnone speculatable willreturn }
54 attributes #2 = { nounwind }
55
56 !llvm.dbg.cu = !{!0}
57 !llvm.module.flags = !{!3, !4}
58 !opencl.ocl.version = !{!5}
59 !opencl.spir.version = !{!5}
60 !llvm.ident = !{!6}
61
62 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 21caba599e6ce806abc492b7ed1653a1aed8b63c)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
63 !1 = !DIFile(filename: "<stdin>", directory: "/tmp")
64 !2 = !{}
65 !3 = !{i32 2, !"Debug Info Version", i32 3}
66 !4 = !{i32 1, !"wchar_size", i32 4}
67 !5 = !{i32 2, i32 0}
68 !6 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 21caba599e6ce806abc492b7ed1653a1aed8b63c)"}
69 !7 = distinct !DISubprogram(name: "foo", scope: !8, file: !8, line: 1, type: !9, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
70 !8 = !DIFile(filename: "constant_sampler.cl", directory: "/tmp")
71 !9 = !DISubroutineType(cc: DW_CC_LLVM_SpirFunction, types: !10)
72 !10 = !{null}
73 !11 = !{!12}
74 !12 = !DILocalVariable(name: "sampler", scope: !7, file: !8, line: 3, type: !13)
75 !13 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !14)
76 !14 = !DIDerivedType(tag: DW_TAG_typedef, name: "sampler_t", file: !1, line: 3, baseType: !15)
77 !15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 32)
78 !16 = !DICompositeType(tag: DW_TAG_structure_type, name: "opencl_sampler_t", file: !1, flags: DIFlagFwdDecl)
79 !17 = !DILocation(line: 3, scope: !7)
80 !18 = !DILocation(line: 0, scope: !7)
81 !19 = !DILocation(line: 4, scope: !7)