Debian Codegraph @

llvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll

raw
1 ; REQUIRES: x86-registered-target
2 ; RUN: opt < %s -passes='pseudo-probe,cgscc(inline)' -function-sections -S -o %t
3 ; RUN: FileCheck %s < %t --check-prefix=CHECK-IL
4 ; For ELF.
5 ; RUN: llc -function-sections -mtriple=x86_64-unknown-linux-gnu <%t -filetype=asm -o %t1
6 ; RUN: FileCheck %s < %t1 --check-prefixes=CHECK-ASM,CHECK-ASM-ELF
7 ; RUN: llc -function-sections -mtriple=x86_64-unknown-linux-gnu <%t -filetype=obj -o %t2
8 ; RUN: llvm-objdump --section-headers %t2 | FileCheck %s --check-prefix=CHECK-OBJ
9 ; RUN: llvm-mc -triple=x86_64-unknown-linux-gnu -filetype=asm <%t1 -o %t3
10 ; RUN: FileCheck %s < %t3 --check-prefixes=CHECK-ASM,CHECK-ASM-ELF
11 ; RUN: llvm-mc -triple=x86_64-unknown-linux-gnu -filetype=obj <%t1 -o %t4
12 ; RUN: llvm-objdump --section-headers %t4 | FileCheck %s --check-prefix=CHECK-OBJ
13 ; For COFF.
14 ; RUN: llc -function-sections -mtriple=x86_64-unknown-windows-msvc <%t -filetype=asm -o %t1
15 ; RUN: FileCheck %s < %t1 --check-prefixes=CHECK-ASM,CHECK-ASM-COFF
16 ; RUN: llc -function-sections -mtriple=x86_64-unknown-windows-msvc <%t -filetype=obj -o %t2
17 ; RUN: llvm-objdump --section-headers %t2 | FileCheck %s --check-prefixes=CHECK-OBJ
18 ; RUN: llvm-mc -triple=x86_64-unknown-windows-msvc -filetype=asm <%t1 -o %t3
19 ; RUN: FileCheck %s < %t3 --check-prefixes=CHECK-ASM,CHECK-ASM-COFF
20 ; RUN: llvm-mc -triple=x86_64-unknown-windows-msvc -filetype=obj <%t1 -o %t4
21 ; RUN: llvm-objdump --section-headers %t4 | FileCheck %s --check-prefixes=CHECK-OBJ
22
23
24 define dso_local void @foo2() !dbg !7 {
25 ; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID1:]], i64 1, i32 0, i64 -1), !dbg ![[#]]
26 ; CHECK-ASM: .pseudoprobe [[#GUID1:]] 1 0 0 foo2
27 ret void, !dbg !10
28 }
29
30 define dso_local void @foo() #0 !dbg !11 {
31 ; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID2:]], i64 1, i32 0, i64 -1), !dbg ![[#]]
32 ; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID1]], i64 1, i32 0, i64 -1), !dbg ![[#DL1:]]
33 ; CHECK-ASM: .pseudoprobe [[#GUID2:]] 1 0 0 foo
34 ; CHECK-ASM: .pseudoprobe [[#GUID1]] 1 0 0 @ [[#GUID2]]:2 foo
35 call void @foo2(), !dbg !12
36 ret void, !dbg !13
37 }
38
39 define dso_local i32 @entry() !dbg !14 {
40 ; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID3:]], i64 1, i32 0, i64 -1), !dbg ![[#]]
41 ; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID2]], i64 1, i32 0, i64 -1), !dbg ![[#DL2:]]
42 ; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID1]], i64 1, i32 0, i64 -1), !dbg ![[#DL3:]]
43 ; CHECK-ASM: .pseudoprobe [[#GUID3:]] 1 0 0 entry
44 ; CHECK-ASM: .pseudoprobe [[#GUID2]] 1 0 0 @ [[#GUID3]]:2 entry
45 ; CHECK-ASM: .pseudoprobe [[#GUID1]] 1 0 0 @ [[#GUID3]]:2 @ [[#GUID2]]:2 entry
46 call void @foo(), !dbg !18
47 ret i32 0, !dbg !19
48 }
49
50
51 ; CHECK-IL: ![[#SCOPE1:]] = distinct !DISubprogram(name: "foo2"
52 ; CHECK-IL: ![[#SCOPE2:]] = distinct !DISubprogram(name: "foo"
53 ; CHECK-IL: ![[#DL1]] = !DILocation(line: 3, column: 1, scope: ![[#SCOPE1]], inlinedAt: ![[#INL1:]])
54 ; CHECK-IL: ![[#INL1]] = distinct !DILocation(line: 7, column: 3, scope: ![[#BL1:]])
55 ;; A discriminator of 455082007 which is 0x1b200017 in hexdecimal, stands for a direct call probe
56 ;; with an index of 2 and a scale of 100%.
57 ; CHECK-IL: ![[#BL1]] = !DILexicalBlockFile(scope: ![[#SCOPE2]], file: !1, discriminator: 455082007)
58 ; CHECK-IL: ![[#SCOPE3:]] = distinct !DISubprogram(name: "entry"
59 ; CHECK-IL: ![[#DL2]] = !DILocation(line: 7, column: 3, scope: ![[#SCOPE2]], inlinedAt: ![[#INL2:]])
60 ; CHECK-IL: ![[#INL2]] = distinct !DILocation(line: 11, column: 3, scope: ![[#BL2:]])
61 ; CHECK-IL: ![[#BL2]] = !DILexicalBlockFile(scope: ![[#SCOPE3]], file: !1, discriminator: 455082007)
62 ; CHECK-IL: ![[#DL3]] = !DILocation(line: 3, column: 1, scope: ![[#SCOPE1]], inlinedAt: ![[#INL3:]])
63 ; CHECK-IL: ![[#INL3]] = distinct !DILocation(line: 7, column: 3, scope: ![[#BL1]], inlinedAt: ![[#INL2]])
64
65
66 ; Check the generation of .pseudo_probe_desc section
67 ; CHECK-ASM-ELF: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_foo2,comdat
68 ; CHECK-ASM-ELF-NEXT: .quad [[#GUID1]]
69 ; CHECK-ASM-ELF-NEXT: .quad [[#HASH1:]]
70 ; CHECK-ASM-ELF-NEXT: .byte 4
71 ; CHECK-ASM-ELF-NEXT: .ascii "foo2"
72 ; CHECK-ASM-ELF-NEXT: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_foo,comdat
73 ; CHECK-ASM-ELF-NEXT: .quad [[#GUID2]]
74 ; CHECK-ASM-ELF-NEXT: .quad [[#HASH2:]]
75 ; CHECK-ASM-ELF-NEXT: .byte 3
76 ; CHECK-ASM-ELF-NEXT: .ascii "foo"
77 ; CHECK-ASM-ELF-NEXT: .section .pseudo_probe_desc,"G",@progbits,.pseudo_probe_desc_entry,comdat
78 ; CHECK-ASM-ELF-NEXT: .quad [[#GUID3]]
79 ; CHECK-ASM-ELF-NEXT: .quad [[#HASH3:]]
80 ; CHECK-ASM-ELF-NEXT: .byte 5
81 ; CHECK-ASM-ELF-NEXT: .ascii "entry"
82 ; CHECK-ASM-COFF: .section .pseudo_probe_desc,"drD",same_contents,.pseudo_probe_desc_foo2
83 ; CHECK-ASM-COFF-NEXT: .pseudo_probe_desc_foo2:
84 ; CHECK-ASM-COFF-NEXT: .quad [[#GUID1]]
85 ; CHECK-ASM-COFF-NEXT: .quad [[#HASH1:]]
86 ; CHECK-ASM-COFF-NEXT: .byte 4
87 ; CHECK-ASM-COFF-NEXT: .ascii "foo2"
88 ; CHECK-ASM-COFF-NEXT: .section .pseudo_probe_desc,"drD",same_contents,.pseudo_probe_desc_foo
89 ; CHECK-ASM-COFF: .pseudo_probe_desc_foo:
90 ; CHECK-ASM-COFF-NEXT: .quad [[#GUID2]]
91 ; CHECK-ASM-COFF-NEXT: .quad [[#HASH2:]]
92 ; CHECK-ASM-COFF-NEXT: .byte 3
93 ; CHECK-ASM-COFF-NEXT: .ascii "foo"
94 ; CHECK-ASM-COFF-NEXT: .section .pseudo_probe_desc,"drD",same_contents,.pseudo_probe_desc_entry
95 ; CHECK-ASM-COFF: .pseudo_probe_desc_entry:
96 ; CHECK-ASM-COFF-NEXT: .quad [[#GUID3]]
97 ; CHECK-ASM-COFF-NEXT: .quad [[#HASH3:]]
98 ; CHECK-ASM-COFF-NEXT: .byte 5
99 ; CHECK-ASM-COFF-NEXT: .ascii "entry"
100
101 ; CHECK-OBJ: .pseudo_probe_desc
102 ; CHECK-OBJ: .pseudo_probe
103 ; CHECK-OBJ-NOT: .rela.pseudo_probe
104
105 !llvm.dbg.cu = !{!0}
106 !llvm.module.flags = !{!3, !4}
107
108 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
109 !1 = !DIFile(filename: "foo.c", directory: "any")
110 !2 = !{}
111 !3 = !{i32 2, !"Dwarf Version", i32 4}
112 !4 = !{i32 2, !"Debug Info Version", i32 3}
113 !7 = distinct !DISubprogram(name: "foo2", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
114 !8 = !DISubroutineType(types: !9)
115 !9 = !{null}
116 !10 = !DILocation(line: 3, column: 1, scope: !7)
117 !11 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 6, type: !8, scopeLine: 6, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
118 !12 = !DILocation(line: 7, column: 3, scope: !11)
119 !13 = !DILocation(line: 8, column: 1, scope: !11)
120 !14 = distinct !DISubprogram(name: "entry", scope: !1, file: !1, line: 10, type: !15, scopeLine: 10, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
121 !15 = !DISubroutineType(types: !16)
122 !16 = !{!17}
123 !17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
124 !18 = !DILocation(line: 11, column: 3, scope: !14)
125 !19 = !DILocation(line: 12, column: 3, scope: !14)