1; RUN: opt %s -passes=sample-profile -sample-profile-file=%S/Inputs/remap.prof -sample-profile-remapping-file=%S/Inputs/remap.map | opt -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s 2; 3; Check whether profile remapping work with loading profile on demand used by extbinary format profile. 4; RUN: llvm-profdata merge -sample -extbinary %S/Inputs/remap.prof -o %t.extbinary.afdo 5; RUN: opt %s -passes=sample-profile -sample-profile-file=%t.extbinary.afdo -sample-profile-remapping-file=%S/Inputs/remap.map | opt -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s 6; 7; Reduced from branch.ll 8 9declare i1 @foo() 10 11define void @_ZN3foo3barERKN1M1XINS_6detail3quxEEE() #0 !dbg !2 { 12; CHECK: Printing analysis {{.*}} for function '_ZN3foo3barERKN1M1XINS_6detail3quxEEE': 13 14entry: 15 %cmp = call i1 @foo(), !dbg !6 16 br i1 %cmp, label %if.then, label %if.end 17; CHECK: edge entry -> if.then probability is 0x4ccf6b16 / 0x80000000 = 60.01% 18; CHECK: edge entry -> if.end probability is 0x333094ea / 0x80000000 = 39.99% 19 20if.then: 21 br label %return 22 23if.end: 24 %cmp1 = call i1 @foo(), !dbg !7 25 br i1 %cmp1, label %if.then.2, label %if.else 26; CHECK: edge if.end -> if.then.2 probability is 0x6652c748 / 0x80000000 = 79.94% 27; CHECK: edge if.end -> if.else probability is 0x19ad38b8 / 0x80000000 = 20.06% 28 29if.then.2: 30 call i1 @foo(), !dbg !8 31 br label %for.cond 32 33for.cond: 34 %cmp5 = call i1 @foo() 35 br i1 %cmp5, label %for.body, label %for.end, !prof !9 36; CHECK: edge for.cond -> for.body probability is 0x73333333 / 0x80000000 = 90.00% 37; CHECK: edge for.cond -> for.end probability is 0x0ccccccd / 0x80000000 = 10.00% 38 39for.body: 40 br label %for.cond 41 42for.end: 43 br label %return 44 45if.else: 46 br label %return 47 48return: 49 ret void 50} 51 52attributes #0 = { "use-sample-profile" } 53 54!llvm.dbg.cu = !{!0} 55!llvm.module.flags = !{!4, !5} 56 57!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "foo++", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !{}, retainedTypes: !{}) 58!1 = !DIFile(filename: "test.cc", directory: "/foo/bar") 59!2 = distinct !DISubprogram(name: "_ZN3foo3barERKN1M1XINS_6detail3quxEEE", scope: !1, file: !1, line: 4, type: !3, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !{}) 60!3 = !DISubroutineType(types: !{}) 61!4 = !{i32 2, !"Dwarf Version", i32 4} 62!5 = !{i32 2, !"Debug Info Version", i32 3} 63!6 = !DILocation(line: 5, column: 8, scope: !2) 64!7 = !DILocation(line: 8, column: 6, scope: !2) 65!8 = !DILocation(line: 10, column: 11, scope: !2) 66!9 = !{!"branch_weights", i32 90, i32 10} 67