xref: /llvm-project/llvm/test/Transforms/SampleProfile/profile-inference-noprobes.ll (revision 0271ae65a66367d802fa6866599d11e35f68450f)
1; RUN: opt < %s -passes=sample-profile -sample-profile-use-profi -sample-profile-file=%S/Inputs/profile-inference-noprobes.prof -S | FileCheck %s
2; RUN: opt < %s -passes=sample-profile -sample-profile-use-profi -sample-profile-file=%S/Inputs/profile-inference-noprobes.prof | opt -passes='print<block-freq>' -disable-output 2>&1 | FileCheck %s --check-prefix=CHECK2
3
4
5; The test verifies that profile inference can be applied for non-probe-based
6; profiles.
7;
8; +---------+     +----------+
9; | b3 [40] | <-- | b1 [100] |
10; +---------+     +----------+
11;                   |
12;                   |
13;                   v
14;                 +----------+
15;                 | b2 [0]   |
16;                 +----------+
17
18@yydebug = dso_local global i32 0, align 4
19
20define void @test_4() #0 !dbg !4 {
21;entry:
22;  ret void, !dbg !9
23b1:
24  %0 = load i32, ptr @yydebug, align 4
25  %cmp = icmp ne i32 %0, 0, !dbg !9
26  br i1 %cmp, label %b2, label %b3, !dbg !9
27; CHECK2: - b1: float = {{.*}}, int = {{.*}}, count = 100
28
29b2:
30  ret void
31; CHECK2: - b2: float = {{.*}}, int = {{.*}}, count = 60
32
33b3:
34  ret void, !dbg !10
35; CHECK2: - b3: float = {{.*}}, int = {{.*}}, count = 40
36}
37
38; CHECK: {{.*}} = !{!"function_entry_count", i64 100}
39; CHECK: {{.*}} = !{!"branch_weights", i32 60, i32 40}
40
41attributes #0 = { noinline nounwind uwtable "use-sample-profile"}
42
43!llvm.module.flags = !{!6, !7}
44
45!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 237249) (llvm/trunk 237261)", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
46!1 = !DIFile(filename: "entry_counts.c", directory: ".")
47!2 = !{}
48!4 = distinct !DISubprogram(name: "test_4", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !0, retainedNodes: !2)
49!5 = !DISubroutineType(types: !2)
50!6 = !{i32 2, !"Dwarf Version", i32 4}
51!7 = !{i32 2, !"Debug Info Version", i32 3}
52!8 = !{!"clang version 3.7.0 (trunk 237249) (llvm/trunk 237261)"}
53!9 = !DILocation(line: 1, column: 15, scope: !4)
54!10 = !DILocation(line: 3, column: 15, scope: !4)
55