117 lines · plain
1; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/warm-inline-instance.prof -S | FileCheck %s2 3@.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 14 5; Function Attrs: nounwind uwtable6define i32 @foo(i32 %x, i32 %y) #0 !dbg !4 {7entry:8 %x.addr = alloca i32, align 49 %y.addr = alloca i32, align 410 store i32 %x, ptr %x.addr, align 411 store i32 %y, ptr %y.addr, align 412 %t0 = load i32, ptr %x.addr, align 4, !dbg !1113 %t1 = load i32, ptr %y.addr, align 4, !dbg !1114 %add = add nsw i32 %t0, %t1, !dbg !1115 ret i32 %add, !dbg !1116}17 18define i32 @goo(i32 %x, i32 %y) #0 {19entry:20 %x.addr = alloca i32, align 421 %y.addr = alloca i32, align 422 store i32 %x, ptr %x.addr, align 423 store i32 %y, ptr %y.addr, align 424 %t0 = load i32, ptr %x.addr, align 4, !dbg !1125 %t1 = load i32, ptr %y.addr, align 4, !dbg !1126 %add = add nsw i32 %t0, %t1, !dbg !1127 ret i32 %add, !dbg !1128}29 30; Function Attrs: uwtable31define i32 @main() #0 !dbg !7 {32entry:33 %retval = alloca i32, align 434 %s = alloca i32, align 435 %i = alloca i32, align 436 store i32 0, ptr %retval37 store i32 0, ptr %i, align 4, !dbg !1238 br label %while.cond, !dbg !1339 40while.cond: ; preds = %if.end, %entry41 %t0 = load i32, ptr %i, align 4, !dbg !1442 %inc = add nsw i32 %t0, 1, !dbg !1443 store i32 %inc, ptr %i, align 4, !dbg !1444 %cmp = icmp slt i32 %t0, 400000000, !dbg !1445 br i1 %cmp, label %while.body, label %while.end, !dbg !1446 47while.body: ; preds = %while.cond48 %t1 = load i32, ptr %i, align 4, !dbg !1649 %cmp1 = icmp ne i32 %t1, 100, !dbg !1650 br i1 %cmp1, label %if.then, label %if.else, !dbg !1651 52if.then: ; preds = %while.body53 %t2 = load i32, ptr %i, align 4, !dbg !1854 %t3 = load i32, ptr %s, align 4, !dbg !1855; Although the ratio of total samples of @foo vs total samples of @main is56; small, since the total samples count is larger than hot cutoff computed by57; ProfileSummaryInfo, we will still regard the callsite of foo as hot and58; early inlining will inline it.59; CHECK-LABEL: @main(60; CHECK-NOT: call i32 @foo(i32 %t2, i32 %t3)61 %call1 = call i32 @foo(i32 %t2, i32 %t3), !dbg !1862 store i32 %call1, ptr %s, align 4, !dbg !1863 br label %if.end, !dbg !1864 65if.else: ; preds = %while.body66; call @goo 's basicblock doesn't get any sample, so no profile will be annotated.67; CHECK: call i32 @goo(i32 2, i32 3), !dbg !{{[0-9]+}}68; CHECK-NOT: !prof69; CHECK-SAME: {{$}}70 %call2 = call i32 @goo(i32 2, i32 3), !dbg !2671 store i32 %call2, ptr %s, align 4, !dbg !2072 br label %if.end73 74if.end: ; preds = %if.else, %if.then75 br label %while.cond, !dbg !2276 77while.end: ; preds = %while.cond78 %t4 = load i32, ptr %s, align 4, !dbg !2479 %call3 = call i32 (ptr, ...) @printf(ptr @.str, i32 %t4), !dbg !2480 ret i32 0, !dbg !2581}82 83declare i32 @printf(ptr, ...) #284 85attributes #0 = { "use-sample-profile" }86 87!llvm.dbg.cu = !{!0}88!llvm.module.flags = !{!8, !9}89!llvm.ident = !{!10}90 91!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)92!1 = !DIFile(filename: "calls.cc", directory: ".")93!2 = !{}94!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)95!5 = !DIFile(filename: "calls.cc", directory: ".")96!6 = !DISubroutineType(types: !2)97!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)98!8 = !{i32 2, !"Dwarf Version", i32 4}99!9 = !{i32 1, !"Debug Info Version", i32 3}100!10 = !{!"clang version 3.5 "}101!11 = !DILocation(line: 4, scope: !4)102!12 = !DILocation(line: 8, scope: !7)103!13 = !DILocation(line: 9, scope: !7)104!14 = !DILocation(line: 9, scope: !15)105!15 = !DILexicalBlockFile(discriminator: 2, file: !1, scope: !7)106!16 = !DILocation(line: 10, scope: !17)107!17 = distinct !DILexicalBlock(line: 10, column: 0, file: !1, scope: !7)108!18 = !DILocation(line: 10, scope: !19)109!19 = !DILexicalBlockFile(discriminator: 2, file: !1, scope: !17)110!20 = !DILocation(line: 10, scope: !21)111!21 = !DILexicalBlockFile(discriminator: 4, file: !1, scope: !17)112!22 = !DILocation(line: 10, scope: !23)113!23 = !DILexicalBlockFile(discriminator: 6, file: !1, scope: !17)114!24 = !DILocation(line: 11, scope: !7)115!25 = !DILocation(line: 12, scope: !7)116!26 = !DILocation(line: 11, scope: !19)117