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