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