1 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/offset.prof | opt -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s
3 ; Original C++ code for this test case:
21 ; Function Attrs: nounwind uwtable
22 define i32 @_Z3fooi(i32 %a) #0 !dbg !4 {
24 %retval = alloca i32, align 4
25 %a.addr = alloca i32, align 4
26 store i32 %a, ptr %a.addr, align 4
27 call void @llvm.dbg.declare(metadata ptr %a.addr, metadata !11, metadata !12), !dbg !13
28 %0 = load i32, ptr %a.addr, align 4, !dbg !14
29 %cmp = icmp sgt i32 %0, 0, !dbg !18
30 br i1 %cmp, label %if.then, label %if.else, !dbg !19
31 ; CHECK: edge %entry -> %if.then probability is 0x0167ba82 / 0x80000000 = 1.10%
32 ; CHECK: edge %entry -> %if.else probability is 0x7e98457e / 0x80000000 = 98.90% [HOT edge]
34 if.then: ; preds = %entry
35 store i32 10, ptr %retval, align 4, !dbg !20
36 br label %return, !dbg !20
38 if.else: ; preds = %entry
39 store i32 20, ptr %retval, align 4, !dbg !22
40 br label %return, !dbg !22
42 return: ; preds = %if.else, %if.then
43 %1 = load i32, ptr %retval, align 4, !dbg !24
47 ; Function Attrs: nounwind readnone
48 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
50 attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "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" "use-sample-profile" }
51 attributes #1 = { nounwind readnone }
54 !llvm.module.flags = !{!8, !9}
57 !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)
58 !1 = !DIFile(filename: "a.cc", directory: "/tmp")
60 !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)
61 !5 = !DISubroutineType(types: !6)
63 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
64 !8 = !{i32 2, !"Dwarf Version", i32 4}
65 !9 = !{i32 2, !"Debug Info Version", i32 3}
66 !10 = !{!"clang version 3.8.0 (trunk 250750)"}
67 !11 = !DILocalVariable(name: "a", arg: 1, scope: !4, file: !1, line: 5, type: !7)
69 !13 = !DILocation(line: 5, column: 13, scope: !4)
70 !14 = !DILocation(line: 1, column: 5, scope: !15)
71 !15 = distinct !DILexicalBlock(scope: !17, file: !16, line: 1, column: 5)
72 !16 = !DIFile(filename: "./a.b", directory: "/tmp")
73 !17 = !DILexicalBlockFile(scope: !4, file: !16, discriminator: 0)
74 !18 = !DILocation(line: 1, column: 7, scope: !15)
75 !19 = !DILocation(line: 1, column: 5, scope: !17)
76 !20 = !DILocation(line: 2, column: 3, scope: !21)
77 !21 = distinct !DILexicalBlock(scope: !15, file: !16, line: 1, column: 12)
78 !22 = !DILocation(line: 4, column: 3, scope: !23)
79 !23 = distinct !DILexicalBlock(scope: !15, file: !16, line: 3, column: 8)
80 !24 = !DILocation(line: 7, column: 1, scope: !25)
81 !25 = !DILexicalBlockFile(scope: !4, file: !1, discriminator: 0)