Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/DebugInfo/Generic/function-ptr-templ.ll

raw
1 ;; compiled from:
2 ;; template <auto Func>
3 ;; int foo() {
4 ;; int result = Func();
5 ;; return result;
6 ;; };
7 ;;
8 ;; long get() { return 42; }
9 ;;
10 ;; void boo() {
11 ;; int val = foo<get>();
12 ;; }
13
14 ; REQUIRES: object-emission
15
16 ; RUN: llvm-as < %s -o %t.bc
17 ; RUN: llvm-spirv %t.bc -o %t.spv
18 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o - | llvm-dis -o %t.ll
19 ; RUN: FileCheck < %t.ll %s --check-prefix=CHECK-LLVM
20 ; RUN: llc -mtriple=x86_64-linux -O0 -filetype=obj < %t.ll | llvm-dwarfdump -v -debug-info - | FileCheck %s --check-prefix=CHECK-DWARF
21
22 ; CHECK-LLVM: ![[#]] = !DITemplateValueParameter(name: "Func", type: ![[#Type:]], value: ptr @_Z3getv)
23 ; CHECK-LLVM: ![[#Type]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[#]], size: 64)
24
25 ; CHECK-DWARF: DW_TAG_subprogram
26 ; CHECK-DWARF: DW_AT_name{{.*}}"foo<&get>"
27
28 ; CHECK-DWARF: DW_TAG_template_value_parameter
29 ; CHECK-DWARF: DW_AT_type {{.*}} "int (*)()"
30 ; CHECK-DWARF: DW_AT_name {{.*}} "Func"
31
32 ; ModuleID = '/app/example.cpp'
33 source_filename = "/app/example.cpp"
34 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
35 target triple = "spir64-unknown-unknown"
36
37 $_Z3fooIXadL_Z3getvEEEiv = comdat any
38
39 ; Function Attrs: mustprogress noinline nounwind optnone uwtable
40 define dso_local noundef i32 @_Z3getv() #0 !dbg !10 {
41 ret i32 42, !dbg !16
42 }
43
44 ; Function Attrs: mustprogress noinline optnone uwtable
45 define dso_local void @_Z3boov() #1 !dbg !17 {
46 %1 = alloca i32, align 4
47 call void @llvm.dbg.declare(metadata ptr %1, metadata !20, metadata !DIExpression()), !dbg !21
48 %2 = call noundef i32 @_Z3fooIXadL_Z3getvEEEiv(), !dbg !22
49 store i32 %2, ptr %1, align 4, !dbg !21
50 ret void, !dbg !23
51 }
52
53 ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn
54 declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
55
56 ; Function Attrs: mustprogress noinline nounwind optnone uwtable
57 define linkonce_odr dso_local noundef i32 @_Z3fooIXadL_Z3getvEEEiv() #0 comdat !dbg !24 {
58 %1 = alloca i32, align 4
59 call void @llvm.dbg.declare(metadata ptr %1, metadata !28, metadata !DIExpression()), !dbg !29
60 %2 = call noundef i32 @_Z3getv(), !dbg !30
61 store i32 %2, ptr %1, align 4, !dbg !29
62 %3 = load i32, ptr %1, align 4, !dbg !31
63 ret i32 %3, !dbg !32
64 }
65
66 attributes #0 = { mustprogress noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
67 attributes #1 = { mustprogress noinline optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
68 attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn }
69
70 !llvm.dbg.cu = !{!0}
71 !llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
72 !llvm.ident = !{!9}
73
74 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 17.0.0 (https://github.com/llvm/llvm-project.git ef38880ce03bc1f1fb3606c5a629151f3d0e975e)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
75 !1 = !DIFile(filename: "/app/example.cpp", directory: "/app")
76 !2 = !{i32 7, !"Dwarf Version", i32 4}
77 !3 = !{i32 2, !"Debug Info Version", i32 3}
78 !4 = !{i32 1, !"wchar_size", i32 4}
79 !5 = !{i32 8, !"PIC Level", i32 2}
80 !6 = !{i32 7, !"PIE Level", i32 2}
81 !7 = !{i32 7, !"uwtable", i32 2}
82 !8 = !{i32 7, !"frame-pointer", i32 2}
83 !9 = !{!"clang version 17.0.0 (https://github.com/llvm/llvm-project.git ef38880ce03bc1f1fb3606c5a629151f3d0e975e)"}
84 !10 = distinct !DISubprogram(name: "get", linkageName: "_Z3getv", scope: !11, file: !11, line: 7, type: !12, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !15)
85 !11 = !DIFile(filename: "example.cpp", directory: "/app")
86 !12 = !DISubroutineType(types: !13)
87 !13 = !{!14}
88 !14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
89 !15 = !{}
90 !16 = !DILocation(line: 7, column: 13, scope: !10)
91 !17 = distinct !DISubprogram(name: "boo", linkageName: "_Z3boov", scope: !11, file: !11, line: 9, type: !18, scopeLine: 9, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !15)
92 !18 = !DISubroutineType(types: !19)
93 !19 = !{null}
94 !20 = !DILocalVariable(name: "val", scope: !17, file: !11, line: 10, type: !14)
95 !21 = !DILocation(line: 10, column: 9, scope: !17)
96 !22 = !DILocation(line: 10, column: 15, scope: !17)
97 !23 = !DILocation(line: 11, column: 1, scope: !17)
98 !24 = distinct !DISubprogram(name: "foo<&get>", linkageName: "_Z3fooIXadL_Z3getvEEEiv", scope: !11, file: !11, line: 2, type: !12, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, templateParams: !25, retainedNodes: !15)
99 !25 = !{!26}
100 !26 = !DITemplateValueParameter(name: "Func", type: !27, value: ptr @_Z3getv)
101 !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
102 !28 = !DILocalVariable(name: "result", scope: !24, file: !11, line: 3, type: !14)
103 !29 = !DILocation(line: 3, column: 9, scope: !24)
104 !30 = !DILocation(line: 3, column: 18, scope: !24)
105 !31 = !DILocation(line: 4, column: 12, scope: !24)
106 !32 = !DILocation(line: 4, column: 5, scope: !24)