1; RUN: llc -O0 %s -o - -filetype=obj \ 2; RUN: | llvm-dwarfdump -statistics - | FileCheck %s 3 4; This test serves as a baseline / sanity-check for stats-inlining-multi-cu.ll 5; The results for both tests should be identical. 6 7; CHECK: "#functions": 4, 8; CHECK: "#inlined functions": 2, 9; CHECK: "#unique source variables": 4, 10; CHECK-NEXT: "#source variables": 6, 11; CHECK-NEXT: "#source variables with location": 6, 12 13;header.h: 14;extern "C" int getchar(); 15;template<typename T> T __attribute__((always_inline)) inlined() { 16; if (getchar()=='a') { 17; int i = getchar(); 18; return i; 19; } else { 20; int i = 'a'; 21; return i; 22; } 23;} 24;ab.cpp 25;#include <header.h> 26;int b(); 27;int a() { 28; int a = inlined<int>(); 29; return a+1; 30;} 31; 32;int b() { 33; int b = inlined<int>(); 34; return b+1; 35;} 36;int main() { 37; return a() + b(); 38;} 39 40 41; ModuleID = 'a.cpp' 42source_filename = "a.cpp" 43target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 44target triple = "x86_64-apple-macosx10.14.0" 45 46; Function Attrs: noinline optnone ssp uwtable 47define i32 @_Z1av() #0 !dbg !8 { 48entry: 49 %retval.i = alloca i32, align 4 50 %i.i = alloca i32, align 4 51 call void @llvm.dbg.declare(metadata i32* %i.i, metadata !12, metadata !DIExpression()), !dbg !19 52 %i2.i = alloca i32, align 4 53 call void @llvm.dbg.declare(metadata i32* %i2.i, metadata !21, metadata !DIExpression()), !dbg !23 54 %a = alloca i32, align 4 55 call void @llvm.dbg.declare(metadata i32* %a, metadata !24, metadata !DIExpression()), !dbg !25 56 %call.i = call i32 @getchar(), !dbg !26 57 %cmp.i = icmp eq i32 %call.i, 97, !dbg !26 58 br i1 %cmp.i, label %if.then.i, label %if.else.i, !dbg !27 59 60if.then.i: ; preds = %entry 61 %call1.i = call i32 @getchar(), !dbg !19 62 store i32 %call1.i, i32* %i.i, align 4, !dbg !19 63 %0 = load i32, i32* %i.i, align 4, !dbg !28 64 store i32 %0, i32* %retval.i, align 4, !dbg !28 65 br label %_Z7inlinedIiET_v.exit, !dbg !28 66 67if.else.i: ; preds = %entry 68 store i32 97, i32* %i2.i, align 4, !dbg !23 69 %1 = load i32, i32* %i2.i, align 4, !dbg !29 70 store i32 %1, i32* %retval.i, align 4, !dbg !29 71 br label %_Z7inlinedIiET_v.exit, !dbg !29 72 73_Z7inlinedIiET_v.exit: ; preds = %if.then.i, %if.else.i 74 %2 = load i32, i32* %retval.i, align 4, !dbg !30 75 store i32 %2, i32* %a, align 4, !dbg !25 76 %3 = load i32, i32* %a, align 4, !dbg !31 77 %add = add nsw i32 %3, 1, !dbg !31 78 ret i32 %add, !dbg !31 79} 80 81; Function Attrs: nounwind readnone speculatable 82declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 83 84; Function Attrs: noinline optnone ssp uwtable 85define i32 @_Z1bv() #0 !dbg !32 { 86entry: 87 %retval.i = alloca i32, align 4 88 %i.i = alloca i32, align 4 89 call void @llvm.dbg.declare(metadata i32* %i.i, metadata !12, metadata !DIExpression()), !dbg !33 90 %i2.i = alloca i32, align 4 91 call void @llvm.dbg.declare(metadata i32* %i2.i, metadata !21, metadata !DIExpression()), !dbg !35 92 %b = alloca i32, align 4 93 call void @llvm.dbg.declare(metadata i32* %b, metadata !36, metadata !DIExpression()), !dbg !37 94 %call.i = call i32 @getchar(), !dbg !38 95 %cmp.i = icmp eq i32 %call.i, 97, !dbg !38 96 br i1 %cmp.i, label %if.then.i, label %if.else.i, !dbg !39 97 98if.then.i: ; preds = %entry 99 %call1.i = call i32 @getchar(), !dbg !33 100 store i32 %call1.i, i32* %i.i, align 4, !dbg !33 101 %0 = load i32, i32* %i.i, align 4, !dbg !40 102 store i32 %0, i32* %retval.i, align 4, !dbg !40 103 br label %_Z7inlinedIiET_v.exit, !dbg !40 104 105if.else.i: ; preds = %entry 106 store i32 97, i32* %i2.i, align 4, !dbg !35 107 %1 = load i32, i32* %i2.i, align 4, !dbg !41 108 store i32 %1, i32* %retval.i, align 4, !dbg !41 109 br label %_Z7inlinedIiET_v.exit, !dbg !41 110 111_Z7inlinedIiET_v.exit: ; preds = %if.then.i, %if.else.i 112 %2 = load i32, i32* %retval.i, align 4, !dbg !42 113 store i32 %2, i32* %b, align 4, !dbg !37 114 %3 = load i32, i32* %b, align 4, !dbg !43 115 %add = add nsw i32 %3, 1, !dbg !43 116 ret i32 %add, !dbg !43 117} 118 119; Function Attrs: noinline norecurse optnone ssp uwtable 120define i32 @main() #2 !dbg !44 { 121entry: 122 %retval = alloca i32, align 4 123 store i32 0, i32* %retval, align 4 124 %call = call i32 @_Z1av(), !dbg !45 125 %call1 = call i32 @_Z1bv(), !dbg !45 126 %add = add nsw i32 %call, %call1, !dbg !45 127 ret i32 %add, !dbg !45 128} 129 130declare i32 @getchar() 131 132attributes #0 = { noinline optnone ssp uwtable } 133attributes #1 = { nounwind readnone speculatable } 134attributes #2 = { noinline norecurse optnone ssp uwtable } 135 136!llvm.dbg.cu = !{!0} 137!llvm.module.flags = !{!3, !4, !5, !6} 138!llvm.ident = !{!7} 139 140!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0 (trunk 340541) (llvm/trunk 340540)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) 141!1 = !DIFile(filename: "a.cpp", directory: "/tmp") 142!2 = !{} 143!3 = !{i32 2, !"Dwarf Version", i32 4} 144!4 = !{i32 2, !"Debug Info Version", i32 3} 145!5 = !{i32 1, !"wchar_size", i32 4} 146!6 = !{i32 7, !"PIC Level", i32 2} 147!7 = !{!"clang version 8.0.0 (trunk 340541) (llvm/trunk 340540)"} 148!8 = distinct !DISubprogram(name: "a", linkageName: "_Z1av", scope: !1, file: !1, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 149!9 = !DISubroutineType(types: !10) 150!10 = !{!11} 151!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 152!12 = !DILocalVariable(name: "i", scope: !13, file: !14, line: 4, type: !11) 153!13 = distinct !DILexicalBlock(scope: !15, file: !14, line: 3) 154!14 = !DIFile(filename: "./header.h", directory: "/tmp") 155!15 = distinct !DILexicalBlock(scope: !16, file: !14, line: 3) 156!16 = distinct !DISubprogram(name: "inlined<int>", linkageName: "_Z7inlinedIiET_v", scope: !14, file: !14, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, templateParams: !17, retainedNodes: !2) 157!17 = !{!18} 158!18 = !DITemplateTypeParameter(name: "T", type: !11) 159!19 = !DILocation(line: 4, scope: !13, inlinedAt: !20) 160!20 = distinct !DILocation(line: 4, scope: !8) 161!21 = !DILocalVariable(name: "i", scope: !22, file: !14, line: 7, type: !11) 162!22 = distinct !DILexicalBlock(scope: !15, file: !14, line: 6) 163!23 = !DILocation(line: 7, scope: !22, inlinedAt: !20) 164!24 = !DILocalVariable(name: "a", scope: !8, file: !1, line: 4, type: !11) 165!25 = !DILocation(line: 4, scope: !8) 166!26 = !DILocation(line: 3, scope: !15, inlinedAt: !20) 167!27 = !DILocation(line: 3, scope: !16, inlinedAt: !20) 168!28 = !DILocation(line: 5, scope: !13, inlinedAt: !20) 169!29 = !DILocation(line: 8, scope: !22, inlinedAt: !20) 170!30 = !DILocation(line: 10, scope: !16, inlinedAt: !20) 171!31 = !DILocation(line: 5, scope: !8) 172!32 = distinct !DISubprogram(name: "b", linkageName: "_Z1bv", scope: !1, file: !1, line: 8, type: !9, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 173!33 = !DILocation(line: 4, scope: !13, inlinedAt: !34) 174!34 = distinct !DILocation(line: 9, scope: !32) 175!35 = !DILocation(line: 7, scope: !22, inlinedAt: !34) 176!36 = !DILocalVariable(name: "b", scope: !32, file: !1, line: 9, type: !11) 177!37 = !DILocation(line: 9, scope: !32) 178!38 = !DILocation(line: 3, scope: !15, inlinedAt: !34) 179!39 = !DILocation(line: 3, scope: !16, inlinedAt: !34) 180!40 = !DILocation(line: 5, scope: !13, inlinedAt: !34) 181!41 = !DILocation(line: 8, scope: !22, inlinedAt: !34) 182!42 = !DILocation(line: 10, scope: !16, inlinedAt: !34) 183!43 = !DILocation(line: 10, scope: !32) 184!44 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 12, type: !9, isLocal: false, isDefinition: true, scopeLine: 12, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 185!45 = !DILocation(line: 13, scope: !44) 186