Debian Codegraph @

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

raw
1 ;; compiled from (null added manually):
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
21 ; RUN: llc -mtriple=x86_64-linux -O0 -filetype=obj < %t.ll | llvm-dwarfdump -v -debug-info - | FileCheck %s --check-prefix=CHECK-DWARF
22
23 ; CHECK-LLVM: ![[#]] = !DITemplateValueParameter(name: "Func", type: ![[#Type:]], value: ptr null)
24 ; CHECK-LLVM: ![[#Type]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[#]], size: 64)
25
26 ; CHECK-DWARF: DW_TAG_subprogram
27 ; CHECK-DWARF: DW_AT_name{{.*}}"foo<&get>"
28
29 ; CHECK-DWARF: DW_TAG_template_value_parameter
30 ; CHECK-DWARF: DW_AT_type {{.*}} "int (*)()"
31 ; CHECK-DWARF: DW_AT_name {{.*}} "Func"
32
33 ; ModuleID = '/app/example.cpp'
34 source_filename = "/app/example.cpp"
35 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
36 target triple = "spir64-unknown-unknown"
37
38 $_Z3fooIXadL_Z3getvEEEiv = comdat any
39
40 ; Function Attrs: mustprogress noinline nounwind optnone uwtable
41 define dso_local noundef i32 @_Z3getv() #0 !dbg !10 {
42 ret i32 42, !dbg !16
43 }
44
45 ; Function Attrs: mustprogress noinline optnone uwtable
46 define dso_local void @_Z3boov() #1 !dbg !17 {
47 %1 = alloca i32, align 4
48 call void @llvm.dbg.declare(metadata ptr %1, metadata !20, metadata !DIExpression()), !dbg !21
49 %2 = call noundef i32 @_Z3fooIXadL_Z3getvEEEiv(), !dbg !22
50 store i32 %2, ptr %1, align 4, !dbg !21
51 ret void, !dbg !23
52 }
53
54 ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn
55 declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
56
57 ; Function Attrs: mustprogress noinline nounwind optnone uwtable
58 define linkonce_odr dso_local noundef i32 @_Z3fooIXadL_Z3getvEEEiv() #0 comdat !dbg !24 {
59 %1 = alloca i32, align 4
60 call void @llvm.dbg.declare(metadata ptr %1, metadata !28, metadata !DIExpression()), !dbg !29
61 %2 = call noundef i32 @_Z3getv(), !dbg !30
62 store i32 %2, ptr %1, align 4, !dbg !29
63 %3 = load i32, ptr %1, align 4, !dbg !31
64 ret i32 %3, !dbg !32
65 }
66
67 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" }
68 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" }
69 attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn }
70
71 !llvm.dbg.cu = !{!0}
72 !llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
73 !llvm.ident = !{!9}
74
75 !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)
76 !1 = !DIFile(filename: "/app/example.cpp", directory: "/app")
77 !2 = !{i32 7, !"Dwarf Version", i32 4}
78 !3 = !{i32 2, !"Debug Info Version", i32 3}
79 !4 = !{i32 1, !"wchar_size", i32 4}
80 !5 = !{i32 8, !"PIC Level", i32 2}
81 !6 = !{i32 7, !"PIE Level", i32 2}
82 !7 = !{i32 7, !"uwtable", i32 2}
83 !8 = !{i32 7, !"frame-pointer", i32 2}
84 !9 = !{!"clang version 17.0.0 (https://github.com/llvm/llvm-project.git ef38880ce03bc1f1fb3606c5a629151f3d0e975e)"}
85 !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)
86 !11 = !DIFile(filename: "example.cpp", directory: "/app")
87 !12 = !DISubroutineType(types: !13)
88 !13 = !{!14}
89 !14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
90 !15 = !{}
91 !16 = !DILocation(line: 7, column: 13, scope: !10)
92 !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)
93 !18 = !DISubroutineType(types: !19)
94 !19 = !{null}
95 !20 = !DILocalVariable(name: "val", scope: !17, file: !11, line: 10, type: !14)
96 !21 = !DILocation(line: 10, column: 9, scope: !17)
97 !22 = !DILocation(line: 10, column: 15, scope: !17)
98 !23 = !DILocation(line: 11, column: 1, scope: !17)
99 !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)
100 !25 = !{!26}
101 !26 = !DITemplateValueParameter(name: "Func", type: !27, value: null)
102 !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
103 !28 = !DILocalVariable(name: "result", scope: !24, file: !11, line: 3, type: !14)
104 !29 = !DILocation(line: 3, column: 9, scope: !24)
105 !30 = !DILocation(line: 3, column: 18, scope: !24)
106 !31 = !DILocation(line: 4, column: 12, scope: !24)
107 !32 = !DILocation(line: 4, column: 5, scope: !24)