1 ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/offset.prof | opt -analyze -branch-prob | FileCheck %s
2 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/offset.prof | opt -analyze -branch-prob | FileCheck %s
4 ; Original C++ code for this test case:
22 ; Function Attrs: nounwind uwtable
23 define i32 @_Z3fooi(i32 %a) #0 !dbg !4 {
25 %retval = alloca i32, align 4
26 %a.addr = alloca i32, align 4
27 store i32 %a, i32* %a.addr, align 4
28 call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !11, metadata !12), !dbg !13
29 %0 = load i32, i32* %a.addr, align 4, !dbg !14
30 %cmp = icmp sgt i32 %0, 0, !dbg !18
31 br i1 %cmp, label %if.then, label %if.else, !dbg !19
32 ; CHECK: edge entry -> if.then probability is 0x0167ba82 / 0x80000000 = 1.10%
33 ; CHECK: edge entry -> if.else probability is 0x7e98457e / 0x80000000 = 98.90% [HOT edge]
35 if.then: ; preds = %entry
36 store i32 10, i32* %retval, align 4, !dbg !20
37 br label %return, !dbg !20
39 if.else: ; preds = %entry
40 store i32 20, i32* %retval, align 4, !dbg !22
41 br label %return, !dbg !22
43 return: ; preds = %if.else, %if.then
44 %1 = load i32, i32* %retval, align 4, !dbg !24
48 ; Function Attrs: nounwind readnone
49 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
51 attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
52 attributes #1 = { nounwind readnone }
55 !llvm.module.flags = !{!8, !9}
58 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 250750)", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2)
59 !1 = !DIFile(filename: "a.cc", directory: "/tmp")
61 !4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 5, type: !5, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
62 !5 = !DISubroutineType(types: !6)
64 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
65 !8 = !{i32 2, !"Dwarf Version", i32 4}
66 !9 = !{i32 2, !"Debug Info Version", i32 3}
67 !10 = !{!"clang version 3.8.0 (trunk 250750)"}
68 !11 = !DILocalVariable(name: "a", arg: 1, scope: !4, file: !1, line: 5, type: !7)
70 !13 = !DILocation(line: 5, column: 13, scope: !4)
71 !14 = !DILocation(line: 1, column: 5, scope: !15)
72 !15 = distinct !DILexicalBlock(scope: !17, file: !16, line: 1, column: 5)
73 !16 = !DIFile(filename: "./a.b", directory: "/tmp")
74 !17 = !DILexicalBlockFile(scope: !4, file: !16, discriminator: 0)
75 !18 = !DILocation(line: 1, column: 7, scope: !15)
76 !19 = !DILocation(line: 1, column: 5, scope: !17)
77 !20 = !DILocation(line: 2, column: 3, scope: !21)
78 !21 = distinct !DILexicalBlock(scope: !15, file: !16, line: 1, column: 12)
79 !22 = !DILocation(line: 4, column: 3, scope: !23)
80 !23 = distinct !DILexicalBlock(scope: !15, file: !16, line: 3, column: 8)
81 !24 = !DILocation(line: 7, column: 1, scope: !25)
82 !25 = !DILexicalBlockFile(scope: !4, file: !1, discriminator: 0)