| 1 |
; RUN: llc -O0 %s -o - -filetype=obj \ |
| 2 |
; RUN: | llvm-dwarfdump -statistics - | FileCheck %s |
| 3 |
|
| 4 |
; Test checks that statistics accounts two and more out-of-line instances |
| 5 |
; of a function and reports the correct number of variables. |
| 6 |
|
| 7 |
; $ cat test.h |
| 8 |
; |
| 9 |
; int foo(int a) { return a; } |
| 10 |
; |
| 11 |
; $ cat test1.cpp |
| 12 |
; |
| 13 |
; #include "test.h" |
| 14 |
; int bar() { return foo(42); } |
| 15 |
; |
| 16 |
; $ cat test2.cpp |
| 17 |
; |
| 18 |
; #include "test.h" |
| 19 |
; int far() { return foo(42); } |
| 20 |
|
| 21 |
; CHECK: "#functions": 3, |
| 22 |
; CHECK-NEXT: "#functions with location": 3, |
| 23 |
; CHECK-NEXT: "#out-of-line functions": 4, |
| 24 |
; CHECK-NEXT: "#inlined functions": 0, |
| 25 |
; CHECK-NEXT: "#inlined functions with abstract origins": 0, |
| 26 |
; CHECK-NEXT: "#unique source variables": 1, |
| 27 |
; CHECK-NEXT: "#source variables": 2, |
| 28 |
; CHECK-NEXT: "#source variables with location": 2, |
| 29 |
|
| 30 |
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 31 |
target triple = "x86_64-unknown-linux-gnu" |
| 32 |
|
| 33 |
; Function Attrs: noinline nounwind optnone uwtable |
| 34 |
define dso_local i32 @_Z3fooi.1(i32 %a) !dbg !9 { |
| 35 |
entry: |
| 36 |
%a.addr = alloca i32, align 4 |
| 37 |
store i32 %a, ptr %a.addr, align 4 |
| 38 |
call void @llvm.dbg.declare(metadata ptr %a.addr, metadata !14, metadata !DIExpression()), !dbg !15 |
| 39 |
%0 = load i32, ptr %a.addr, align 4, !dbg !15 |
| 40 |
ret i32 %0, !dbg !15 |
| 41 |
} |
| 42 |
; Function Attrs: nounwind readnone speculatable willreturn |
| 43 |
declare void @llvm.dbg.declare(metadata, metadata, metadata) |
| 44 |
; Function Attrs: noinline nounwind optnone uwtable |
| 45 |
define dso_local i32 @_Z3barv() !dbg !18 { |
| 46 |
entry: |
| 47 |
%call = call i32 @_Z3fooi.1(i32 42), !dbg !21 |
| 48 |
ret i32 %call, !dbg !21 |
| 49 |
} |
| 50 |
; Function Attrs: noinline nounwind optnone uwtable |
| 51 |
define dso_local i32 @_Z3fooi(i32 %a) !dbg !23 { |
| 52 |
entry: |
| 53 |
%a.addr = alloca i32, align 4 |
| 54 |
store i32 %a, ptr %a.addr, align 4 |
| 55 |
call void @llvm.dbg.declare(metadata ptr %a.addr, metadata !24, metadata !DIExpression()), !dbg !25 |
| 56 |
%0 = load i32, ptr %a.addr, align 4, !dbg !25 |
| 57 |
ret i32 %0, !dbg !25 |
| 58 |
} |
| 59 |
; Function Attrs: noinline nounwind optnone uwtable |
| 60 |
define dso_local i32 @_Z3farv() !dbg !28 { |
| 61 |
entry: |
| 62 |
%call = call i32 @_Z3fooi(i32 42), !dbg !29 |
| 63 |
ret i32 %call, !dbg !29 |
| 64 |
} |
| 65 |
|
| 66 |
!llvm.dbg.cu = !{!0, !3} |
| 67 |
!llvm.ident = !{!5, !5} |
| 68 |
!llvm.module.flags = !{!6, !7, !8} |
| 69 |
|
| 70 |
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) |
| 71 |
!1 = !DIFile(filename: "test1.cpp", directory: "/") |
| 72 |
!2 = !{} |
| 73 |
!3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !4, producer: "clang version 11.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) |
| 74 |
!4 = !DIFile(filename: "test2.cpp", directory: "/") |
| 75 |
!5 = !{!"clang version 11.0.0"} |
| 76 |
!6 = !{i32 7, !"Dwarf Version", i32 4} |
| 77 |
!7 = !{i32 2, !"Debug Info Version", i32 3} |
| 78 |
!8 = !{i32 1, !"wchar_size", i32 4} |
| 79 |
!9 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !10, file: !10, line: 1, type: !11, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) |
| 80 |
!10 = !DIFile(filename: "./test.h", directory: "/") |
| 81 |
!11 = !DISubroutineType(types: !12) |
| 82 |
!12 = !{!13, !13} |
| 83 |
!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 84 |
!14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !10, line: 1, type: !13) |
| 85 |
!15 = !DILocation(line: 1, column: 13, scope: !9) |
| 86 |
!18 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !1, file: !1, line: 3, type: !19, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) |
| 87 |
!19 = !DISubroutineType(types: !20) |
| 88 |
!20 = !{!13} |
| 89 |
!21 = !DILocation(line: 3, column: 20, scope: !18) |
| 90 |
!23 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !10, file: !10, line: 1, type: !11, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !3, retainedNodes: !2) |
| 91 |
!24 = !DILocalVariable(name: "a", arg: 1, scope: !23, file: !10, line: 1, type: !13) |
| 92 |
!25 = !DILocation(line: 1, column: 13, scope: !23) |
| 93 |
!28 = distinct !DISubprogram(name: "far", linkageName: "_Z3farv", scope: !4, file: !4, line: 3, type: !19, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !3, retainedNodes: !2) |
| 94 |
!29 = !DILocation(line: 3, column: 20, scope: !28) |