xref: /llvm-project/llvm/test/Transforms/SampleProfile/pseudo-probe-update-2.ll (revision e3cf80c5c1fe55efd8216575ccadea0ab087e79c)
1; RUN: opt < %s -passes='pseudo-probe-update' -S  | FileCheck %s
2
3declare i32 @f1()
4
5declare i32 @f2()
6
7declare void @f3()
8
9define i32 @foo(i1 %cond, i1 %cond2) !dbg !4 !prof !10 {
10  call void @llvm.pseudoprobe(i64 6699318081062747564, i64 1, i32 0, i64 -1)
11  br i1 %cond, label %T1, label %Merge, !prof !11
12
13T1:                                               ; preds = %0
14  %v1 = call i32 @f1(), !prof !12
15  %cond3 = icmp eq i32 %v1, 412
16  call void @llvm.pseudoprobe(i64 6699318081062747564, i64 2, i32 0, i64 -1)
17;; The distribution factor -9223372036854775808 stands for 53.85%, whic is from 7/6+7.
18; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 4, i32 0, i64 -9223372036854775808)
19  call void @llvm.pseudoprobe(i64 6699318081062747564, i64 4, i32 0, i64 -1), !dbg !13
20;; Probe 7 has two copies, since they don't share the same inline context, they are not
21;; considered sharing samples, thus their distribution factors are not fixed up.
22; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 7, i32 0, i64 -1)
23  call void @llvm.pseudoprobe(i64 6699318081062747564, i64 7, i32 0, i64 -1), !dbg !13
24;; Similar to Probe 7, one copy of Probe 8 doesn't have inline context.
25; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 8, i32 0, i64 -1)
26  call void @llvm.pseudoprobe(i64 6699318081062747564, i64 8, i32 0, i64 -1), !dbg !13
27  br i1 %cond3, label %T2, label %F2, !prof !11
28
29Merge:                                            ; preds = %0
30  %v2 = call i32 @f2(), !prof !12
31  call void @llvm.pseudoprobe(i64 6699318081062747564, i64 3, i32 0, i64 -1)
32;; The distribution factor  -9223372036854775808 stands for 46.25%, which is from 6/6+7.
33; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 4, i32 0, i64  -9223372036854775808)
34  call void @llvm.pseudoprobe(i64 6699318081062747564, i64 4, i32 0, i64 8513881922462547968), !dbg !13
35; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 7, i32 0, i64 -1)
36  call void @llvm.pseudoprobe(i64 6699318081062747564, i64 7, i32 0, i64 -1), !dbg !18
37; CHECK: call void @llvm.pseudoprobe(i64 [[#GUID]], i64 8, i32 0, i64 -1)
38  call void @llvm.pseudoprobe(i64 6699318081062747564, i64 8, i32 0, i64 -1), !dbg !19
39  br i1 %cond2, label %T2, label %F2, !prof !11
40
41T2:                                               ; preds = %Merge, %T1
42  %B1 = phi i32 [ %v1, %T1 ], [ %v2, %Merge ]
43  call void @f3(), !prof !12
44  call void @llvm.pseudoprobe(i64 6699318081062747564, i64 5, i32 0, i64 -1)
45  ret i32 %B1
46
47F2:                                               ; preds = %Merge, %T1
48  %B2 = phi i32 [ %v1, %T1 ], [ %v2, %Merge ]
49  call void @llvm.pseudoprobe(i64 6699318081062747564, i64 6, i32 0, i64 -1)
50  ret i32 %B2
51}
52
53; Function Attrs: inaccessiblememonly nounwind willreturn
54declare void @llvm.pseudoprobe(i64, i64, i32, i64) #0
55
56attributes #0 = { inaccessiblememonly nounwind willreturn }
57
58!llvm.module.flags = !{!0, !1}
59!llvm.pseudo_probe_desc = !{!2, !3}
60
61!0 = !{i32 7, !"Dwarf Version", i32 4}
62!1 = !{i32 2, !"Debug Info Version", i32 3}
63!2 = !{i64 6699318081062747564, i64 281479271677951, !"foo", null}
64!3 = !{i64 6468398850841090686, i64 138828622701, !"zen", null}
65!4 = distinct !DISubprogram(name: "foo", scope: !5, file: !5, line: 9, type: !6, scopeLine: 9, spFlags: DISPFlagDefinition, unit: !9)
66!5 = !DIFile(filename: "test.cpp", directory: "test")
67!6 = !DISubroutineType(types: !7)
68!7 = !{!8, !8}
69!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
70!9 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !5, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
71!10 = !{!"function_entry_count", i64 14}
72!11 = !{!"branch_weights", i32 8, i32 7}
73!12 = !{!"branch_weights", i32 7}
74!13 = !DILocation(line: 39, column: 9, scope: !14, inlinedAt: !16)
75!14 = distinct !DILexicalBlock(scope: !15, file: !5, line: 39, column: 7)
76!15 = distinct !DISubprogram(name: "zen", scope: !5, file: !5, line: 37, type: !6, scopeLine: 38, spFlags: DISPFlagDefinition, unit: !9)
77!16 = distinct !DILocation(line: 10, column: 11, scope: !17)
78!17 = !DILexicalBlockFile(scope: !4, file: !5, discriminator: 186646551)
79!18 = !DILocation(line: 53, column: 3, scope: !15, inlinedAt: !19)
80!19 = !DILocation(line: 12, column: 3, scope: !4)
81