1; Test that GCOV instrumentation numbers functions correctly when some
2; functions aren't emitted.
3
4; Inject metadata to set the .gcno file location
5; RUN: rm -rf %t && mkdir -p %t
6; RUN: echo '!14 = !{!"%/t/function-numbering.ll", !0}' > %t/1
7; RUN: cat %s %t/1 > %t/2
8
9; RUN: opt -insert-gcov-profiling -S < %t/2 | FileCheck --check-prefix GCDA %s
10; RUN: llvm-cov gcov -n -dump %t/function-numbering.gcno 2>&1 | FileCheck --check-prefix GCNO %s
11; RUNN: rm %t/function-numbering.gcno
12
13; RUN: opt -passes=insert-gcov-profiling -S < %t/2 | FileCheck --check-prefix GCDA %s
14; RUN: llvm-cov gcov -n -dump %t/function-numbering.gcno 2>&1 | FileCheck --check-prefix GCNO %s
15
16target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
17target triple = "x86_64-apple-macosx10.10.0"
18
19; GCDA: @[[FOO:[0-9]+]] = private unnamed_addr constant [4 x i8] c"foo\00"
20; GCDA-NOT: @{{[0-9]+}} = private unnamed_addr constant .* c"bar\00"
21; GCDA: @[[BAZ:[0-9]+]] = private unnamed_addr constant [4 x i8] c"baz\00"
22; GCDA: define internal void @__llvm_gcov_writeout()
23; GCDA: call void @llvm_gcda_emit_function(i32 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[FOO]]
24; GCDA: call void @llvm_gcda_emit_function(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[BAZ]]
25
26; GCNO: == foo (0) @
27; GCNO-NOT: == bar ({{[0-9]+}}) @
28; GCNO: == baz (1) @
29
30define void @foo() !dbg !4 {
31  ret void, !dbg !12
32}
33
34define void @bar() !dbg !7 {
35  ; This function is referenced by the debug info, but no lines have locations.
36  ret void
37}
38
39define void @baz() !dbg !8 {
40  ret void, !dbg !13
41}
42
43!llvm.gcov = !{!14}
44!llvm.dbg.cu = !{!0}
45!llvm.module.flags = !{!9, !10}
46!llvm.ident = !{!11}
47
48!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.6.0 ", isOptimized: false, emissionKind: LineTablesOnly, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
49!1 = !DIFile(filename: ".../llvm/test/Transforms/GCOVProfiling/function-numbering.ll", directory: "")
50!2 = !{}
51!4 = distinct !DISubprogram(name: "foo", line: 1, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, variables: !2)
52!5 = !DIFile(filename: ".../llvm/test/Transforms/GCOVProfiling/function-numbering.ll", directory: "")
53!6 = !DISubroutineType(types: !2)
54!7 = distinct !DISubprogram(name: "bar", line: 2, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, scopeLine: 2, file: !1, scope: !5, type: !6, variables: !2)
55!8 = distinct !DISubprogram(name: "baz", line: 3, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, scopeLine: 3, file: !1, scope: !5, type: !6, variables: !2)
56!9 = !{i32 2, !"Dwarf Version", i32 2}
57!10 = !{i32 2, !"Debug Info Version", i32 3}
58!11 = !{!"clang version 3.6.0 "}
59!12 = !DILocation(line: 1, column: 13, scope: !4)
60!13 = !DILocation(line: 3, column: 13, scope: !8)
61