1;; Note that this needs new pass manager for now. Passing `-sample-profile-inline-replay` to legacy pass manager is a no-op. 2 3;; Check baseline inline decisions 4; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline -S 2>&1 | FileCheck -check-prefix=DEFAULT %s 5 6;; Check replay inline decisions 7; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-inline-replay=%S/Inputs/inline-replay.txt -sample-profile-merge-inlinee -sample-profile-top-down-load -pass-remarks=inline -S 2>&1 | FileCheck -check-prefix=REPLAY %s 8 9@.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 1 10 11define i32 @_Z3sumii(i32 %x, i32 %y) #0 !dbg !6 { 12entry: 13 %x.addr = alloca i32, align 4 14 %y.addr = alloca i32, align 4 15 store i32 %x, i32* %x.addr, align 4 16 store i32 %y, i32* %y.addr, align 4 17 %tmp = load i32, i32* %x.addr, align 4, !dbg !8 18 %tmp1 = load i32, i32* %y.addr, align 4, !dbg !8 19 %add = add nsw i32 %tmp, %tmp1, !dbg !8 20 %tmp2 = load i32, i32* %x.addr, align 4, !dbg !8 21 %tmp3 = load i32, i32* %y.addr, align 4, !dbg !8 22 %call = call i32 @_Z3subii(i32 %tmp2, i32 %tmp3), !dbg !8 23 ret i32 %add, !dbg !8 24} 25 26define i32 @_Z3subii(i32 %x, i32 %y) #0 !dbg !9 { 27entry: 28 %x.addr = alloca i32, align 4 29 %y.addr = alloca i32, align 4 30 store i32 %x, i32* %x.addr, align 4 31 store i32 %y, i32* %y.addr, align 4 32 %tmp = load i32, i32* %x.addr, align 4, !dbg !10 33 %tmp1 = load i32, i32* %y.addr, align 4, !dbg !10 34 %add = sub nsw i32 %tmp, %tmp1, !dbg !10 35 ret i32 %add, !dbg !11 36} 37 38define i32 @main() #0 !dbg !12 { 39entry: 40 %retval = alloca i32, align 4 41 %s = alloca i32, align 4 42 %i = alloca i32, align 4 43 store i32 0, i32* %retval 44 store i32 0, i32* %i, align 4, !dbg !13 45 br label %while.cond, !dbg !14 46 47while.cond: ; preds = %if.end, %entry 48 %tmp = load i32, i32* %i, align 4, !dbg !15 49 %inc = add nsw i32 %tmp, 1, !dbg !15 50 store i32 %inc, i32* %i, align 4, !dbg !15 51 %cmp = icmp slt i32 %tmp, 400000000, !dbg !15 52 br i1 %cmp, label %while.body, label %while.end, !dbg !15 53 54while.body: ; preds = %while.cond 55 %tmp1 = load i32, i32* %i, align 4, !dbg !17 56 %cmp1 = icmp ne i32 %tmp1, 100, !dbg !17 57 br i1 %cmp1, label %if.then, label %if.else, !dbg !17 58 59if.then: ; preds = %while.body 60 %tmp2 = load i32, i32* %i, align 4, !dbg !19 61 %tmp3 = load i32, i32* %s, align 4, !dbg !19 62 %call = call i32 @_Z3sumii(i32 %tmp2, i32 %tmp3), !dbg !19 63 store i32 %call, i32* %s, align 4, !dbg !19 64 br label %if.end, !dbg !19 65 66if.else: ; preds = %while.body 67 store i32 30, i32* %s, align 4, !dbg !21 68 br label %if.end 69 70if.end: ; preds = %if.else, %if.then 71 br label %while.cond, !dbg !23 72 73while.end: ; preds = %while.cond 74 %tmp4 = load i32, i32* %s, align 4, !dbg !25 75 %call2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i32 0, i32 0), i32 %tmp4), !dbg !25 76 ret i32 0, !dbg !26 77} 78 79declare i32 @printf(i8*, ...) 80 81attributes #0 = { "use-sample-profile" } 82 83!llvm.dbg.cu = !{!0} 84!llvm.module.flags = !{!3, !4} 85!llvm.ident = !{!5} 86 87!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) 88!1 = !DIFile(filename: "calls.cc", directory: ".") 89!2 = !{} 90!3 = !{i32 2, !"Dwarf Version", i32 4} 91!4 = !{i32 1, !"Debug Info Version", i32 3} 92!5 = !{!"clang version 3.5 "} 93!6 = distinct !DISubprogram(name: "sum", linkageName: "_Z3sumii", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 94!7 = !DISubroutineType(types: !2) 95!8 = !DILocation(line: 4, scope: !6) 96!9 = distinct !DISubprogram(name: "sub", linkageName: "_Z3subii", scope: !1, file: !1, line: 20, type: !7, scopeLine: 20, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 97!10 = !DILocation(line: 20, scope: !9) 98!11 = !DILocation(line: 21, scope: !9) 99!12 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 7, type: !7, scopeLine: 7, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 100!13 = !DILocation(line: 8, scope: !12) 101!14 = !DILocation(line: 9, scope: !12) 102!15 = !DILocation(line: 9, scope: !16) 103!16 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 2) 104!17 = !DILocation(line: 10, scope: !18) 105!18 = distinct !DILexicalBlock(scope: !12, file: !1, line: 10) 106!19 = !DILocation(line: 10, scope: !20) 107!20 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 2) 108!21 = !DILocation(line: 10, scope: !22) 109!22 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 4) 110!23 = !DILocation(line: 10, scope: !24) 111!24 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 6) 112!25 = !DILocation(line: 11, scope: !12) 113!26 = !DILocation(line: 12, scope: !12) 114 115 116; DEFAULT: _Z3sumii inlined into main 117; DEFAULT: _Z3subii inlined into _Z3sumii 118; DEFAULT-NOT: _Z3subii inlined into main 119 120; REPLAY: _Z3sumii inlined into main 121; REPLAY: _Z3subii inlined into main 122; REPLA-NOT: _Z3subii inlined into _Z3sumii 123