1; Test we lose details of not inlined profile without '-sample-profile-merge-inlinee' 2; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-mergeprof.prof -sample-profile-merge-inlinee=false -use-profiled-call-graph=0 -S | FileCheck -check-prefix=SCALE %s 3 4; Test we properly merge not inlined profile with '-sample-profile-merge-inlinee' 5; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-mergeprof.prof -sample-profile-merge-inlinee=true -use-profiled-call-graph=0 -S | FileCheck -check-prefix=MERGE %s 6; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-mergeprof.prof -sample-profile-merge-inlinee=true -use-profiled-call-graph=0 -sample-profile-prioritized-inline=1 -S | FileCheck -check-prefix=MERGE %s 7 8; Test we properly merge not inlined profile with '-sample-profile-merge-inlinee' 9; when the profile uses md5. 10; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-mergeprof.md5.prof -sample-profile-merge-inlinee=true -use-profiled-call-graph=0 -S | FileCheck -check-prefix=MERGE %s 11 12; Test we properly merge not inlined profile with '--sample-profile-merge-inlinee' even if '--disable-sample-loader-inlining' is true 13; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-mergeprof.md5.prof -sample-profile-merge-inlinee=true --disable-sample-loader-inlining -use-profiled-call-graph=0 -S | FileCheck -check-prefix=MERGE %s 14 15@.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 1 16 17define i32 @main() #0 !dbg !6 { 18entry: 19 %retval = alloca i32, align 4 20 %s = alloca i32, align 4 21 %i = alloca i32, align 4 22 %tmp = load i32, ptr %i, align 4, !dbg !8 23 %tmp1 = load i32, ptr %s, align 4, !dbg !8 24 %call = call i32 @_Z3sumii(i32 %tmp, i32 %tmp1), !dbg !8 25; SCALE: call i32 @_Z3sumii 26; MERGE: call i32 @_Z3sumii 27 store i32 %call, ptr %s, align 4, !dbg !8 28 ret i32 0, !dbg !11 29} 30 31define i32 @_Z3sumii(i32 %x, i32 %y) #0 !dbg !12 { 32entry: 33 %x.addr = alloca i32, align 4 34 %y.addr = alloca i32, align 4 35 store i32 %x, ptr %x.addr, align 4 36 store i32 %y, ptr %y.addr, align 4 37 %tmp = load i32, ptr %x.addr, align 4, !dbg !13 38 %tmp1 = load i32, ptr %y.addr, align 4, !dbg !13 39 %add = add nsw i32 %tmp, %tmp1, !dbg !13 40 %tmp2 = load i32, ptr %x.addr, align 4, !dbg !13 41 %tmp3 = load i32, ptr %y.addr, align 4, !dbg !13 42 %cmp1 = icmp ne i32 %tmp3, 100, !dbg !13 43 br i1 %cmp1, label %if.then, label %if.else, !dbg !13 44 45if.then: ; preds = %entry 46 %call = call i32 @_Z3subii(i32 %tmp2, i32 %tmp3), !dbg !14 47 ret i32 %add, !dbg !14 48 49if.else: ; preds = %entry 50 ret i32 %add, !dbg !15 51} 52 53define i32 @_Z3subii(i32 %x, i32 %y) #0 !dbg !16 { 54entry: 55 %x.addr = alloca i32, align 4 56 %y.addr = alloca i32, align 4 57 store i32 %x, ptr %x.addr, align 4 58 store i32 %y, ptr %y.addr, align 4 59 %tmp = load i32, ptr %x.addr, align 4, !dbg !17 60 %tmp1 = load i32, ptr %y.addr, align 4, !dbg !17 61 %add = sub nsw i32 %tmp, %tmp1, !dbg !17 62 ret i32 %add, !dbg !18 63} 64 65attributes #0 = { "use-sample-profile" } 66 67declare i32 @printf(ptr, ...) 68 69!llvm.dbg.cu = !{!0} 70!llvm.module.flags = !{!3, !4} 71!llvm.ident = !{!5} 72 73!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.5 ", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2) 74!1 = !DIFile(filename: "calls.cc", directory: ".") 75!2 = !{} 76!3 = !{i32 2, !"Dwarf Version", i32 4} 77!4 = !{i32 1, !"Debug Info Version", i32 3} 78!5 = !{!"clang version 3.5 "} 79!6 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 7, type: !7, scopeLine: 7, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 80!7 = !DISubroutineType(types: !2) 81!8 = !DILocation(line: 10, scope: !9) 82!9 = !DILexicalBlockFile(scope: !10, file: !1, discriminator: 2) 83!10 = distinct !DILexicalBlock(scope: !6, file: !1, line: 10) 84!11 = !DILocation(line: 12, scope: !6) 85!12 = distinct !DISubprogram(name: "sum", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 86!13 = !DILocation(line: 4, scope: !12) 87!14 = !DILocation(line: 5, scope: !12) 88!15 = !DILocation(line: 6, scope: !12) 89!16 = distinct !DISubprogram(name: "sub", scope: !1, file: !1, line: 20, type: !7, scopeLine: 20, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 90!17 = !DILocation(line: 20, scope: !16) 91!18 = !DILocation(line: 21, scope: !16) 92 93; SCALE: name: "sum" 94; SCALE-NEXT: {!"function_entry_count", i64 46} 95; SCALE: !{!"branch_weights", i32 11, i32 2} 96; SCALE: !{!"branch_weights", i32 20} 97; SCALE: name: "sub" 98; SCALE-NEXT: {!"function_entry_count", i64 -1} 99 100; MERGE: name: "sum" 101; MERGE-NEXT: {!"function_entry_count", i64 46} 102; MERGE: !{!"branch_weights", i32 11, i32 23} 103; MERGE: !{!"branch_weights", i32 10} 104; MERGE: name: "sub" 105; MERGE-NEXT: {!"function_entry_count", i64 3} 106