1cee313d2SEric Christopher; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/warm-inline-instance.prof -S | FileCheck %s 2cee313d2SEric Christopher 3cee313d2SEric Christopher@.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 1 4cee313d2SEric Christopher 5cee313d2SEric Christopher; Function Attrs: nounwind uwtable 67a6c8942SWei Midefine i32 @foo(i32 %x, i32 %y) #0 !dbg !4 { 7cee313d2SEric Christopherentry: 8cee313d2SEric Christopher %x.addr = alloca i32, align 4 9cee313d2SEric Christopher %y.addr = alloca i32, align 4 10*0271ae65SFangrui Song store i32 %x, ptr %x.addr, align 4 11*0271ae65SFangrui Song store i32 %y, ptr %y.addr, align 4 12*0271ae65SFangrui Song %t0 = load i32, ptr %x.addr, align 4, !dbg !11 13*0271ae65SFangrui Song %t1 = load i32, ptr %y.addr, align 4, !dbg !11 14cee313d2SEric Christopher %add = add nsw i32 %t0, %t1, !dbg !11 15cee313d2SEric Christopher ret i32 %add, !dbg !11 16cee313d2SEric Christopher} 17cee313d2SEric Christopher 187a6c8942SWei Midefine i32 @goo(i32 %x, i32 %y) #0 { 19cee313d2SEric Christopherentry: 20cee313d2SEric Christopher %x.addr = alloca i32, align 4 21cee313d2SEric Christopher %y.addr = alloca i32, align 4 22*0271ae65SFangrui Song store i32 %x, ptr %x.addr, align 4 23*0271ae65SFangrui Song store i32 %y, ptr %y.addr, align 4 24*0271ae65SFangrui Song %t0 = load i32, ptr %x.addr, align 4, !dbg !11 25*0271ae65SFangrui Song %t1 = load i32, ptr %y.addr, align 4, !dbg !11 26cee313d2SEric Christopher %add = add nsw i32 %t0, %t1, !dbg !11 27cee313d2SEric Christopher ret i32 %add, !dbg !11 28cee313d2SEric Christopher} 29cee313d2SEric Christopher 30cee313d2SEric Christopher; Function Attrs: uwtable 317a6c8942SWei Midefine i32 @main() #0 !dbg !7 { 32cee313d2SEric Christopherentry: 33cee313d2SEric Christopher %retval = alloca i32, align 4 34cee313d2SEric Christopher %s = alloca i32, align 4 35cee313d2SEric Christopher %i = alloca i32, align 4 36*0271ae65SFangrui Song store i32 0, ptr %retval 37*0271ae65SFangrui Song store i32 0, ptr %i, align 4, !dbg !12 38cee313d2SEric Christopher br label %while.cond, !dbg !13 39cee313d2SEric Christopher 40cee313d2SEric Christopherwhile.cond: ; preds = %if.end, %entry 41*0271ae65SFangrui Song %t0 = load i32, ptr %i, align 4, !dbg !14 42cee313d2SEric Christopher %inc = add nsw i32 %t0, 1, !dbg !14 43*0271ae65SFangrui Song store i32 %inc, ptr %i, align 4, !dbg !14 44cee313d2SEric Christopher %cmp = icmp slt i32 %t0, 400000000, !dbg !14 45cee313d2SEric Christopher br i1 %cmp, label %while.body, label %while.end, !dbg !14 46cee313d2SEric Christopher 47cee313d2SEric Christopherwhile.body: ; preds = %while.cond 48*0271ae65SFangrui Song %t1 = load i32, ptr %i, align 4, !dbg !16 49cee313d2SEric Christopher %cmp1 = icmp ne i32 %t1, 100, !dbg !16 50cee313d2SEric Christopher br i1 %cmp1, label %if.then, label %if.else, !dbg !16 51cee313d2SEric Christopher 52cee313d2SEric Christopherif.then: ; preds = %while.body 53*0271ae65SFangrui Song %t2 = load i32, ptr %i, align 4, !dbg !18 54*0271ae65SFangrui Song %t3 = load i32, ptr %s, align 4, !dbg !18 55cee313d2SEric Christopher; Although the ratio of total samples of @foo vs total samples of @main is 56cee313d2SEric Christopher; small, since the total samples count is larger than hot cutoff computed by 57cee313d2SEric Christopher; ProfileSummaryInfo, we will still regard the callsite of foo as hot and 58cee313d2SEric Christopher; early inlining will inline it. 59cee313d2SEric Christopher; CHECK-LABEL: @main( 60cee313d2SEric Christopher; CHECK-NOT: call i32 @foo(i32 %t2, i32 %t3) 61cee313d2SEric Christopher %call1 = call i32 @foo(i32 %t2, i32 %t3), !dbg !18 62*0271ae65SFangrui Song store i32 %call1, ptr %s, align 4, !dbg !18 63cee313d2SEric Christopher br label %if.end, !dbg !18 64cee313d2SEric Christopher 65cee313d2SEric Christopherif.else: ; preds = %while.body 66cee313d2SEric Christopher; call @goo 's basicblock doesn't get any sample, so no profile will be annotated. 67cee313d2SEric Christopher; CHECK: call i32 @goo(i32 2, i32 3), !dbg !{{[0-9]+}} 68cee313d2SEric Christopher; CHECK-NOT: !prof 69cee313d2SEric Christopher; CHECK-SAME: {{$}} 70cee313d2SEric Christopher %call2 = call i32 @goo(i32 2, i32 3), !dbg !26 71*0271ae65SFangrui Song store i32 %call2, ptr %s, align 4, !dbg !20 72cee313d2SEric Christopher br label %if.end 73cee313d2SEric Christopher 74cee313d2SEric Christopherif.end: ; preds = %if.else, %if.then 75cee313d2SEric Christopher br label %while.cond, !dbg !22 76cee313d2SEric Christopher 77cee313d2SEric Christopherwhile.end: ; preds = %while.cond 78*0271ae65SFangrui Song %t4 = load i32, ptr %s, align 4, !dbg !24 79*0271ae65SFangrui Song %call3 = call i32 (ptr, ...) @printf(ptr @.str, i32 %t4), !dbg !24 80cee313d2SEric Christopher ret i32 0, !dbg !25 81cee313d2SEric Christopher} 82cee313d2SEric Christopher 83*0271ae65SFangrui Songdeclare i32 @printf(ptr, ...) #2 84cee313d2SEric Christopher 857a6c8942SWei Miattributes #0 = { "use-sample-profile" } 867a6c8942SWei Mi 87cee313d2SEric Christopher!llvm.dbg.cu = !{!0} 88cee313d2SEric Christopher!llvm.module.flags = !{!8, !9} 89cee313d2SEric Christopher!llvm.ident = !{!10} 90cee313d2SEric Christopher 91cee313d2SEric Christopher!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5 ", isOptimized: false, emissionKind: NoDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) 92cee313d2SEric Christopher!1 = !DIFile(filename: "calls.cc", directory: ".") 93cee313d2SEric Christopher!2 = !{} 94cee313d2SEric Christopher!4 = distinct !DISubprogram(name: "foo", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !1, scope: !5, type: !6, retainedNodes: !2) 95cee313d2SEric Christopher!5 = !DIFile(filename: "calls.cc", directory: ".") 96cee313d2SEric Christopher!6 = !DISubroutineType(types: !2) 97cee313d2SEric Christopher!7 = distinct !DISubprogram(name: "main", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !1, scope: !5, type: !6, retainedNodes: !2) 98cee313d2SEric Christopher!8 = !{i32 2, !"Dwarf Version", i32 4} 99cee313d2SEric Christopher!9 = !{i32 1, !"Debug Info Version", i32 3} 100cee313d2SEric Christopher!10 = !{!"clang version 3.5 "} 101cee313d2SEric Christopher!11 = !DILocation(line: 4, scope: !4) 102cee313d2SEric Christopher!12 = !DILocation(line: 8, scope: !7) 103cee313d2SEric Christopher!13 = !DILocation(line: 9, scope: !7) 104cee313d2SEric Christopher!14 = !DILocation(line: 9, scope: !15) 105cee313d2SEric Christopher!15 = !DILexicalBlockFile(discriminator: 2, file: !1, scope: !7) 106cee313d2SEric Christopher!16 = !DILocation(line: 10, scope: !17) 107cee313d2SEric Christopher!17 = distinct !DILexicalBlock(line: 10, column: 0, file: !1, scope: !7) 108cee313d2SEric Christopher!18 = !DILocation(line: 10, scope: !19) 109cee313d2SEric Christopher!19 = !DILexicalBlockFile(discriminator: 2, file: !1, scope: !17) 110cee313d2SEric Christopher!20 = !DILocation(line: 10, scope: !21) 111cee313d2SEric Christopher!21 = !DILexicalBlockFile(discriminator: 4, file: !1, scope: !17) 112cee313d2SEric Christopher!22 = !DILocation(line: 10, scope: !23) 113cee313d2SEric Christopher!23 = !DILexicalBlockFile(discriminator: 6, file: !1, scope: !17) 114cee313d2SEric Christopher!24 = !DILocation(line: 11, scope: !7) 115cee313d2SEric Christopher!25 = !DILocation(line: 12, scope: !7) 116cee313d2SEric Christopher!26 = !DILocation(line: 11, scope: !19) 117