diff options
| author | Eric Christopher <echristo@gmail.com> | 2019-04-17 04:52:47 +0000 |
|---|---|---|
| committer | Eric Christopher <echristo@gmail.com> | 2019-04-17 04:52:47 +0000 |
| commit | cee313d288a4faf0355d76fb6e0e927e211d08a5 (patch) | |
| tree | d386075318d761197779a96e5d8fc0dc7b06342b /llvm/test/Transforms/GCOVProfiling | |
| parent | c3d6a929fdd92fd06d4304675ade8d7210ee711a (diff) | |
| download | bcm5719-llvm-cee313d288a4faf0355d76fb6e0e927e211d08a5.tar.gz bcm5719-llvm-cee313d288a4faf0355d76fb6e0e927e211d08a5.zip | |
Revert "Temporarily Revert "Add basic loop fusion pass.""
The reversion apparently deleted the test/Transforms directory.
Will be re-reverting again.
llvm-svn: 358552
Diffstat (limited to 'llvm/test/Transforms/GCOVProfiling')
| -rw-r--r-- | llvm/test/Transforms/GCOVProfiling/function-numbering.ll | 123 | ||||
| -rw-r--r-- | llvm/test/Transforms/GCOVProfiling/global-ctor.ll | 60 | ||||
| -rw-r--r-- | llvm/test/Transforms/GCOVProfiling/linezero.ll | 145 | ||||
| -rw-r--r-- | llvm/test/Transforms/GCOVProfiling/linkagename.ll | 31 | ||||
| -rw-r--r-- | llvm/test/Transforms/GCOVProfiling/modules.ll | 13 | ||||
| -rw-r--r-- | llvm/test/Transforms/GCOVProfiling/return-block.ll | 84 | ||||
| -rw-r--r-- | llvm/test/Transforms/GCOVProfiling/three-element-mdnode.ll | 28 | ||||
| -rw-r--r-- | llvm/test/Transforms/GCOVProfiling/version.ll | 38 |
8 files changed, 522 insertions, 0 deletions
diff --git a/llvm/test/Transforms/GCOVProfiling/function-numbering.ll b/llvm/test/Transforms/GCOVProfiling/function-numbering.ll new file mode 100644 index 00000000000..f9a95fd1c25 --- /dev/null +++ b/llvm/test/Transforms/GCOVProfiling/function-numbering.ll @@ -0,0 +1,123 @@ +; Test that GCOV instrumentation numbers functions correctly when some +; functions aren't emitted. + +; Inject metadata to set the .gcno file location +; RUN: rm -rf %t && mkdir -p %t +; RUN: echo '!14 = !{!"%/t/function-numbering.ll", !0}' > %t/1 +; RUN: cat %s %t/1 > %t/2 + +; RUN: opt -insert-gcov-profiling -S < %t/2 | FileCheck --check-prefix GCDA %s +; RUN: llvm-cov gcov -n -dump %t/function-numbering.gcno 2>&1 | FileCheck --check-prefix GCNO %s +; RUNN: rm %t/function-numbering.gcno + +; RUN: opt -passes=insert-gcov-profiling -S < %t/2 | FileCheck --check-prefix GCDA %s +; RUN: llvm-cov gcov -n -dump %t/function-numbering.gcno 2>&1 | FileCheck --check-prefix GCNO %s + +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.10.0" + +; GCDA: @[[FOO:[0-9]+]] = private unnamed_addr constant [4 x i8] c"foo\00" +; GCDA-NOT: @{{[0-9]+}} = private unnamed_addr constant .* c"bar\00" +; GCDA: @[[BAZ:[0-9]+]] = private unnamed_addr constant [4 x i8] c"baz\00" +; GCDA: @__llvm_internal_gcov_emit_function_args.0 = internal unnamed_addr constant +; GCDA-SAME: { i32 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[FOO]] +; GCDA-SAME: { i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[BAZ]] +; +; GCDA-LABEL: define internal void @__llvm_gcov_writeout() {{.*}} { +; GCDA-NEXT: entry: +; GCDA-NEXT: br label %[[FILE_LOOP_HEADER:.*]] +; +; GCDA: [[FILE_LOOP_HEADER]]: +; GCDA-NEXT: %[[IV:.*]] = phi i32 [ 0, %entry ], [ %[[NEXT_IV:.*]], %[[FILE_LOOP_LATCH:.*]] ] +; GCDA-NEXT: %[[FILE_INFO:.*]] = getelementptr inbounds {{.*}}, {{.*}}* @__llvm_internal_gcov_emit_file_info, i32 0, i32 %[[IV]] +; GCDA-NEXT: %[[START_FILE_ARGS:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[FILE_INFO]], i32 0, i32 0 +; GCDA-NEXT: %[[START_FILE_ARG_0_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[START_FILE_ARGS]], i32 0, i32 0 +; GCDA-NEXT: %[[START_FILE_ARG_0:.*]] = load i8*, i8** %[[START_FILE_ARG_0_PTR]] +; GCDA-NEXT: %[[START_FILE_ARG_1_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[START_FILE_ARGS]], i32 0, i32 1 +; GCDA-NEXT: %[[START_FILE_ARG_1:.*]] = load i8*, i8** %[[START_FILE_ARG_1_PTR]] +; GCDA-NEXT: %[[START_FILE_ARG_2_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[START_FILE_ARGS]], i32 0, i32 2 +; GCDA-NEXT: %[[START_FILE_ARG_2:.*]] = load i32, i32* %[[START_FILE_ARG_2_PTR]] +; GCDA-NEXT: call void @llvm_gcda_start_file(i8* %[[START_FILE_ARG_0]], i8* %[[START_FILE_ARG_1]], i32 %[[START_FILE_ARG_2]]) +; GCDA-NEXT: %[[NUM_COUNTERS_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[FILE_INFO]], i32 0, i32 1 +; GCDA-NEXT: %[[NUM_COUNTERS:.*]] = load i32, i32* %[[NUM_COUNTERS_PTR]] +; GCDA-NEXT: %[[EMIT_FUN_ARGS_ARRAY_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[FILE_INFO]], i32 0, i32 2 +; GCDA-NEXT: %[[EMIT_FUN_ARGS_ARRAY:.*]] = load {{.*}}*, {{.*}}** %[[EMIT_FUN_ARGS_ARRAY_PTR]] +; GCDA-NEXT: %[[EMIT_ARCS_ARGS_ARRAY_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[FILE_INFO]], i32 0, i32 3 +; GCDA-NEXT: %[[EMIT_ARCS_ARGS_ARRAY:.*]] = load {{.*}}*, {{.*}}** %[[EMIT_ARCS_ARGS_ARRAY_PTR]] +; GCDA-NEXT: %[[ENTER_COUNTER_LOOP_COND:.*]] = icmp slt i32 0, %[[NUM_COUNTERS]] +; GCDA-NEXT: br i1 %[[ENTER_COUNTER_LOOP_COND]], label %[[COUNTER_LOOP:.*]], label %[[FILE_LOOP_LATCH]] +; +; GCDA: [[COUNTER_LOOP]]: +; GCDA-NEXT: %[[JV:.*]] = phi i32 [ 0, %[[FILE_LOOP_HEADER]] ], [ %[[NEXT_JV:.*]], %[[COUNTER_LOOP]] ] +; GCDA-NEXT: %[[EMIT_FUN_ARGS:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[EMIT_FUN_ARGS_ARRAY]], i32 %[[JV]] +; GCDA-NEXT: %[[EMIT_FUN_ARG_0_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[EMIT_FUN_ARGS]], i32 0, i32 0 +; GCDA-NEXT: %[[EMIT_FUN_ARG_0:.*]] = load i32, i32* %[[EMIT_FUN_ARG_0_PTR]] +; GCDA-NEXT: %[[EMIT_FUN_ARG_1_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[EMIT_FUN_ARGS]], i32 0, i32 1 +; GCDA-NEXT: %[[EMIT_FUN_ARG_1:.*]] = load i8*, i8** %[[EMIT_FUN_ARG_1_PTR]] +; GCDA-NEXT: %[[EMIT_FUN_ARG_2_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[EMIT_FUN_ARGS]], i32 0, i32 2 +; GCDA-NEXT: %[[EMIT_FUN_ARG_2:.*]] = load i32, i32* %[[EMIT_FUN_ARG_2_PTR]] +; GCDA-NEXT: %[[EMIT_FUN_ARG_3_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[EMIT_FUN_ARGS]], i32 0, i32 3 +; GCDA-NEXT: %[[EMIT_FUN_ARG_3:.*]] = load i8, i8* %[[EMIT_FUN_ARG_3_PTR]] +; GCDA-NEXT: %[[EMIT_FUN_ARG_4_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[EMIT_FUN_ARGS]], i32 0, i32 4 +; GCDA-NEXT: %[[EMIT_FUN_ARG_4:.*]] = load i32, i32* %[[EMIT_FUN_ARG_4_PTR]] +; GCDA-NEXT: call void @llvm_gcda_emit_function(i32 %[[EMIT_FUN_ARG_0]], +; GCDA-SAME: i8* %[[EMIT_FUN_ARG_1]], +; GCDA-SAME: i32 %[[EMIT_FUN_ARG_2]], +; GCDA-SAME: i8 %[[EMIT_FUN_ARG_3]], +; GCDA-SAME: i32 %[[EMIT_FUN_ARG_4]]) +; GCDA-NEXT: %[[EMIT_ARCS_ARGS:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[EMIT_ARCS_ARGS_ARRAY]], i32 %[[JV]] +; GCDA-NEXT: %[[EMIT_ARCS_ARG_0_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[EMIT_ARCS_ARGS]], i32 0, i32 0 +; GCDA-NEXT: %[[EMIT_ARCS_ARG_0:.*]] = load i32, i32* %[[EMIT_ARCS_ARG_0_PTR]] +; GCDA-NEXT: %[[EMIT_ARCS_ARG_1_PTR:.*]] = getelementptr inbounds {{.*}}, {{.*}}* %[[EMIT_ARCS_ARGS]], i32 0, i32 1 +; GCDA-NEXT: %[[EMIT_ARCS_ARG_1:.*]] = load i64*, i64** %[[EMIT_ARCS_ARG_1_PTR]] +; GCDA-NEXT: call void @llvm_gcda_emit_arcs(i32 %[[EMIT_ARCS_ARG_0]], +; GCDA-SAME: i64* %[[EMIT_ARCS_ARG_1]]) +; GCDA-NEXT: %[[NEXT_JV]] = add i32 %[[JV]], 1 +; GCDA-NEXT: %[[COUNTER_LOOP_COND:.*]] = icmp slt i32 %[[NEXT_JV]], %[[NUM_COUNTERS]] +; GCDA-NEXT: br i1 %[[COUNTER_LOOP_COND]], label %[[COUNTER_LOOP]], label %[[FILE_LOOP_LATCH]] +; +; GCDA: [[FILE_LOOP_LATCH]]: +; GCDA-NEXT: call void @llvm_gcda_summary_info() +; GCDA-NEXT: call void @llvm_gcda_end_file() +; GCDA-NEXT: %[[NEXT_IV]] = add i32 %[[IV]], 1 +; GCDA-NEXT: %[[FILE_LOOP_COND:.*]] = icmp slt i32 %[[NEXT_IV]], 1 +; GCDA-NEXT: br i1 %[[FILE_LOOP_COND]], label %[[FILE_LOOP_HEADER]], label %[[EXIT:.*]] +; +; GCDA: [[EXIT]]: +; GCDA-NEXT: ret void + +; GCNO: == foo (0) @ +; GCNO-NOT: == bar ({{[0-9]+}}) @ +; GCNO: == baz (1) @ + +define void @foo() !dbg !4 { + ret void, !dbg !12 +} + +define void @bar() !dbg !7 { + ; This function is referenced by the debug info, but no lines have locations. + ret void +} + +define void @baz() !dbg !8 { + ret void, !dbg !13 +} + +!llvm.gcov = !{!14} +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!9, !10} +!llvm.ident = !{!11} + +!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) +!1 = !DIFile(filename: ".../llvm/test/Transforms/GCOVProfiling/function-numbering.ll", directory: "") +!2 = !{} +!4 = distinct !DISubprogram(name: "foo", line: 1, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, retainedNodes: !2) +!5 = !DIFile(filename: ".../llvm/test/Transforms/GCOVProfiling/function-numbering.ll", directory: "") +!6 = !DISubroutineType(types: !2) +!7 = distinct !DISubprogram(name: "bar", line: 2, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, scopeLine: 2, file: !1, scope: !5, type: !6, retainedNodes: !2) +!8 = distinct !DISubprogram(name: "baz", line: 3, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, scopeLine: 3, file: !1, scope: !5, type: !6, retainedNodes: !2) +!9 = !{i32 2, !"Dwarf Version", i32 2} +!10 = !{i32 2, !"Debug Info Version", i32 3} +!11 = !{!"clang version 3.6.0 "} +!12 = !DILocation(line: 1, column: 13, scope: !4) +!13 = !DILocation(line: 3, column: 13, scope: !8) diff --git a/llvm/test/Transforms/GCOVProfiling/global-ctor.ll b/llvm/test/Transforms/GCOVProfiling/global-ctor.ll new file mode 100644 index 00000000000..4f9d2e89457 --- /dev/null +++ b/llvm/test/Transforms/GCOVProfiling/global-ctor.ll @@ -0,0 +1,60 @@ +; RUN: rm -rf %t && mkdir -p %t +; RUN: echo '!16 = !{!"%/t/global-ctor.ll", !0}' > %t/1 +; RUN: cat %s %t/1 > %t/2 +; RUN: opt -insert-gcov-profiling -disable-output < %t/2 +; RUN: not grep '_GLOBAL__sub_I_global-ctor' %t/global-ctor.gcno +; RUN: rm %t/global-ctor.gcno + +; RUN: opt -passes=insert-gcov-profiling -disable-output < %t/2 +; RUN: not grep '_GLOBAL__sub_I_global-ctor' %t/global-ctor.gcno +; RUN: rm %t/global-ctor.gcno + +@x = global i32 0, align 4 +@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_global-ctor.ll, i8* null }] + +; Function Attrs: nounwind +define internal void @__cxx_global_var_init() #0 section ".text.startup" !dbg !4 { +entry: + br label %0 + +; <label>:0 ; preds = %entry + %call = call i32 @_Z1fv(), !dbg !13 + store i32 %call, i32* @x, align 4, !dbg !13 + ret void, !dbg !13 +} + +declare i32 @_Z1fv() #1 + +; Function Attrs: nounwind +define internal void @_GLOBAL__sub_I_global-ctor.ll() #0 section ".text.startup" { +entry: + br label %0 + +; <label>:0 ; preds = %entry + call void @__cxx_global_var_init(), !dbg !14 + ret void, !dbg !14 +} + +attributes #0 = { nounwind } +attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!10, !11} +!llvm.gcov = !{!16} +!llvm.ident = !{!12} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 (trunk 210217)", isOptimized: false, emissionKind: LineTablesOnly, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) +!1 = !DIFile(filename: "<stdin>", directory: "/home/nlewycky") +!2 = !{} +!4 = distinct !DISubprogram(name: "__cxx_global_var_init", line: 2, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 2, file: !5, scope: !6, type: !7, retainedNodes: !2) +!5 = !DIFile(filename: "global-ctor.ll", directory: "/home/nlewycky") +!6 = !DIFile(filename: "global-ctor.ll", directory: "/home/nlewycky") +!7 = !DISubroutineType(types: !2) +!8 = distinct !DISubprogram(name: "", linkageName: "_GLOBAL__sub_I_global-ctor.ll", isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagArtificial, isOptimized: false, unit: !0, file: !1, scope: !9, type: !7, retainedNodes: !2) +!9 = !DIFile(filename: "<stdin>", directory: "/home/nlewycky") +!10 = !{i32 2, !"Dwarf Version", i32 4} +!11 = !{i32 2, !"Debug Info Version", i32 3} +!12 = !{!"clang version 3.5.0 (trunk 210217)"} +!13 = !DILocation(line: 2, scope: !4) +!14 = !DILocation(line: 0, scope: !15) +!15 = !DILexicalBlockFile(discriminator: 0, file: !5, scope: !8) diff --git a/llvm/test/Transforms/GCOVProfiling/linezero.ll b/llvm/test/Transforms/GCOVProfiling/linezero.ll new file mode 100644 index 00000000000..7c084a3ec18 --- /dev/null +++ b/llvm/test/Transforms/GCOVProfiling/linezero.ll @@ -0,0 +1,145 @@ +; RUN: rm -rf %t && mkdir -p %t + +; RUN: sed -e 's|PATTERN|%/t|g' %s | opt -insert-gcov-profiling -disable-output +; RUN: rm %t/linezero.gcno + +; RUN: sed -e 's|PATTERN|%/t|g' %s | opt -passes=insert-gcov-profiling -disable-output +; RUN: rm %t/linezero.gcno + +; This is a crash test. + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%struct.vector = type { i8 } + +; Function Attrs: nounwind +define i32 @_Z4testv() #0 !dbg !15 { +entry: + %retval = alloca i32, align 4 + %__range = alloca %struct.vector*, align 8 + %ref.tmp = alloca %struct.vector, align 1 + %undef.agg.tmp = alloca %struct.vector, align 1 + %__begin = alloca i8*, align 8 + %__end = alloca i8*, align 8 + %spec = alloca i8, align 1 + call void @llvm.dbg.declare(metadata %struct.vector** %__range, metadata !27, metadata !DIExpression()), !dbg !30 + br label %0 + +; <label>:0 ; preds = %entry + call void @_Z13TagFieldSpecsv(), !dbg !31 + store %struct.vector* %ref.tmp, %struct.vector** %__range, align 8, !dbg !31 + call void @llvm.dbg.declare(metadata i8** %__begin, metadata !32, metadata !DIExpression()), !dbg !30 + %1 = load %struct.vector*, %struct.vector** %__range, align 8, !dbg !31 + %call = call i8* @_ZN6vector5beginEv(%struct.vector* %1), !dbg !31 + store i8* %call, i8** %__begin, align 8, !dbg !31 + call void @llvm.dbg.declare(metadata i8** %__end, metadata !33, metadata !DIExpression()), !dbg !30 + %2 = load %struct.vector*, %struct.vector** %__range, align 8, !dbg !31 + %call1 = call i8* @_ZN6vector3endEv(%struct.vector* %2), !dbg !31 + store i8* %call1, i8** %__end, align 8, !dbg !31 + br label %for.cond, !dbg !31 + +for.cond: ; preds = %for.inc, %0 + %3 = load i8*, i8** %__begin, align 8, !dbg !34 + %4 = load i8*, i8** %__end, align 8, !dbg !34 + %cmp = icmp ne i8* %3, %4, !dbg !34 + br i1 %cmp, label %for.body, label %for.end, !dbg !34 + +for.body: ; preds = %for.cond + call void @llvm.dbg.declare(metadata i8* %spec, metadata !37, metadata !DIExpression()), !dbg !31 + %5 = load i8*, i8** %__begin, align 8, !dbg !38 + %6 = load i8, i8* %5, align 1, !dbg !38 + store i8 %6, i8* %spec, align 1, !dbg !38 + br label %for.inc, !dbg !38 + +for.inc: ; preds = %for.body + %7 = load i8*, i8** %__begin, align 8, !dbg !40 + %incdec.ptr = getelementptr inbounds i8, i8* %7, i32 1, !dbg !40 + store i8* %incdec.ptr, i8** %__begin, align 8, !dbg !40 + br label %for.cond, !dbg !40 + +for.end: ; preds = %for.cond + call void @llvm.trap(), !dbg !42 + unreachable, !dbg !42 + +return: ; No predecessors! + %8 = load i32, i32* %retval, !dbg !44 + ret i32 %8, !dbg !44 +} + +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +declare void @_Z13TagFieldSpecsv() #2 + +declare i8* @_ZN6vector5beginEv(%struct.vector*) #2 + +declare i8* @_ZN6vector3endEv(%struct.vector*) #2 + +; Function Attrs: noreturn nounwind +declare void @llvm.trap() #3 + +; Function Attrs: nounwind +define void @_Z2f1v() #0 !dbg !20 { +entry: + br label %0 + +; <label>:0 ; preds = %entry + ret void, !dbg !45 +} + +attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } +attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #3 = { noreturn nounwind } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!23, !24} +!llvm.gcov = !{!25} +!llvm.ident = !{!26} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 (trunk 209871)", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !2, imports: !2) +!1 = !DIFile(filename: "<stdin>", directory: "PATTERN") +!2 = !{} +!3 = !{!4} +!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "vector", line: 21, size: 8, align: 8, file: !5, elements: !6, identifier: "_ZTS6vector") +!5 = !DIFile(filename: "linezero.cc", directory: "PATTERN") +!6 = !{!7, !13} +!7 = !DISubprogram(name: "begin", linkageName: "_ZN6vector5beginEv", line: 25, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 25, file: !5, scope: !4, type: !8) +!8 = !DISubroutineType(types: !9) +!9 = !{!10, !12} +!10 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !11) +!11 = !DIBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) +!12 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !4) +!13 = !DISubprogram(name: "end", linkageName: "_ZN6vector3endEv", line: 26, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 26, file: !5, scope: !4, type: !8) +!15 = distinct !DISubprogram(name: "test", linkageName: "_Z4testv", line: 50, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 50, file: !5, scope: !16, type: !17, retainedNodes: !2) +!16 = !DIFile(filename: "linezero.cc", directory: "PATTERN") +!17 = !DISubroutineType(types: !18) +!18 = !{!19} +!19 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!20 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", line: 54, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 54, file: !5, scope: !16, type: !21, retainedNodes: !2) +!21 = !DISubroutineType(types: !22) +!22 = !{null} +!23 = !{i32 2, !"Dwarf Version", i32 4} +!24 = !{i32 2, !"Debug Info Version", i32 3} +!25 = !{!"PATTERN/linezero.o", !0} +!26 = !{!"clang version 3.5.0 (trunk 209871)"} +!27 = !DILocalVariable(name: "__range", flags: DIFlagArtificial, scope: !28, type: !29) +!28 = distinct !DILexicalBlock(line: 51, column: 0, file: !5, scope: !15) +!29 = !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: !4) +!30 = !DILocation(line: 0, scope: !28) +!31 = !DILocation(line: 51, scope: !28) +!32 = !DILocalVariable(name: "__begin", flags: DIFlagArtificial, scope: !28, type: !10) +!33 = !DILocalVariable(name: "__end", flags: DIFlagArtificial, scope: !28, type: !10) +!34 = !DILocation(line: 51, scope: !35) +!35 = distinct !DILexicalBlock(line: 51, column: 0, file: !5, scope: !36) +!36 = distinct !DILexicalBlock(line: 51, column: 0, file: !5, scope: !28) +!37 = !DILocalVariable(name: "spec", line: 51, scope: !28, file: !16, type: !11) +!38 = !DILocation(line: 51, scope: !39) +!39 = distinct !DILexicalBlock(line: 51, column: 0, file: !5, scope: !28) +!40 = !DILocation(line: 51, scope: !41) +!41 = distinct !DILexicalBlock(line: 51, column: 0, file: !5, scope: !28) +!42 = !DILocation(line: 51, scope: !43) +!43 = distinct !DILexicalBlock(line: 51, column: 0, file: !5, scope: !28) +!44 = !DILocation(line: 52, scope: !15) +!45 = !DILocation(line: 54, scope: !20) diff --git a/llvm/test/Transforms/GCOVProfiling/linkagename.ll b/llvm/test/Transforms/GCOVProfiling/linkagename.ll new file mode 100644 index 00000000000..195d3a0f219 --- /dev/null +++ b/llvm/test/Transforms/GCOVProfiling/linkagename.ll @@ -0,0 +1,31 @@ +; RUN: rm -rf %t && mkdir -p %t +; RUN: echo '!9 = !{!"%/t/linkagename.ll", !0}' > %t/1 +; RUN: cat %s %t/1 > %t/2 +; RUN: opt -insert-gcov-profiling -disable-output < %t/2 +; RUN: grep _Z3foov %t/linkagename.gcno +; RUN: rm %t/linkagename.gcno + +; RUN: opt -passes=insert-gcov-profiling -disable-output < %t/2 +; RUN: grep _Z3foov %t/linkagename.gcno +; RUN: rm %t/linkagename.gcno + +define void @_Z3foov() !dbg !5 { +entry: + ret void, !dbg !8 +} + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!10} +!llvm.gcov = !{!9} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.3 (trunk 177323)", isOptimized: false, emissionKind: FullDebug, file: !2, enums: !3, retainedTypes: !3, globals: !3, imports: !3) +!1 = !DIFile(filename: "hello.cc", directory: "/home/nlewycky") +!2 = !DIFile(filename: "hello.cc", directory: "/home/nlewycky") +!3 = !{} +!5 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !1, type: !6, retainedNodes: !3) +!6 = !DISubroutineType(types: !7) +!7 = !{null} +!8 = !DILocation(line: 1, scope: !5) + + +!10 = !{i32 1, !"Debug Info Version", i32 3} diff --git a/llvm/test/Transforms/GCOVProfiling/modules.ll b/llvm/test/Transforms/GCOVProfiling/modules.ll new file mode 100644 index 00000000000..460d4dfdfa1 --- /dev/null +++ b/llvm/test/Transforms/GCOVProfiling/modules.ll @@ -0,0 +1,13 @@ +; RUN: opt -insert-gcov-profiling -o - < %s | llvm-dis | FileCheck -check-prefix=EMIT-ARCS %s +; RUN: opt -passes=insert-gcov-profiling -o - < %s | llvm-dis | FileCheck -check-prefix=EMIT-ARCS %s + +; EMIT-ARCS-NOT: call void @llvm_gcda_start_file + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "LLVM", isOptimized: false, runtimeVersion: 2, splitDebugFilename: "my.dwo", emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2, dwoId: 43981) +!1 = !DIFile(filename: "<stdin>", directory: "/") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} diff --git a/llvm/test/Transforms/GCOVProfiling/return-block.ll b/llvm/test/Transforms/GCOVProfiling/return-block.ll new file mode 100644 index 00000000000..74812d14c64 --- /dev/null +++ b/llvm/test/Transforms/GCOVProfiling/return-block.ll @@ -0,0 +1,84 @@ +; Inject metadata to set the .gcno file location +; RUN: rm -rf %t && mkdir -p %t +; RUN: echo '!19 = !{!"%/t/return-block.ll", !0}' > %t/1 +; RUN: cat %s %t/1 > %t/2 + +; By default, the return block is last. +; RUN: opt -insert-gcov-profiling -disable-output %t/2 +; RUN: llvm-cov gcov -n -dump %t/return-block.gcno 2>&1 | FileCheck -check-prefix=CHECK -check-prefix=RETURN-LAST %s + +; But we can optionally emit it second, to match newer gcc versions. +; RUN: opt -insert-gcov-profiling -gcov-exit-block-before-body -disable-output %t/2 +; RUN: llvm-cov gcov -n -dump %t/return-block.gcno 2>&1 | FileCheck -check-prefix=CHECK -check-prefix=RETURN-SECOND %s +; RUN: rm %t/return-block.gcno + +; By default, the return block is last. +; RUN: opt -passes=insert-gcov-profiling -disable-output %t/2 +; RUN: llvm-cov gcov -n -dump %t/return-block.gcno 2>&1 | FileCheck -check-prefix=CHECK -check-prefix=RETURN-LAST %s + +; But we can optionally emit it second, to match newer gcc versions. +; RUN: opt -passes=insert-gcov-profiling -gcov-exit-block-before-body -disable-output %t/2 +; RUN: llvm-cov gcov -n -dump %t/return-block.gcno 2>&1 | FileCheck -check-prefix=CHECK -check-prefix=RETURN-SECOND %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@A = common global i32 0, align 4, !dbg !9 + +; Function Attrs: nounwind uwtable +define void @test() #0 !dbg !4 { +entry: + tail call void (...) @f() #2, !dbg !14 + %0 = load i32, i32* @A, align 4, !dbg !15 + %tobool = icmp eq i32 %0, 0, !dbg !15 + br i1 %tobool, label %if.end, label %if.then, !dbg !15 + +if.then: ; preds = %entry + tail call void (...) @g() #2, !dbg !16 + br label %if.end, !dbg !16 + +if.end: ; preds = %entry, %if.then + ret void, !dbg !18 +} + +declare void @f(...) #1 + +declare void @g(...) #1 + +attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind } + +!llvm.gcov = !{!19} +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!11, !12} +!llvm.ident = !{!13} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.6.0 (trunk 223182)", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !8, imports: !2) +!1 = !DIFile(filename: ".../llvm/test/Transforms/GCOVProfiling/return-block.ll", directory: "") +!2 = !{} +!4 = distinct !DISubprogram(name: "test", line: 5, isLocal: false, isDefinition: true, isOptimized: true, unit: !0, scopeLine: 5, file: !1, scope: !5, type: !6, retainedNodes: !2) +!5 = !DIFile(filename: ".../llvm/test/Transforms/GCOVProfiling/return-block.ll", directory: "") +!6 = !DISubroutineType(types: !7) +!7 = !{null} +!8 = !{!9} +!9 = !DIGlobalVariableExpression(var: !DIGlobalVariable(name: "A", line: 3, isLocal: false, isDefinition: true, scope: null, file: !5, type: !10), expr: !DIExpression()) +!10 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!11 = !{i32 2, !"Dwarf Version", i32 4} +!12 = !{i32 2, !"Debug Info Version", i32 3} +!13 = !{!"clang version 3.6.0 (trunk 223182)"} +!14 = !DILocation(line: 6, column: 3, scope: !4) +!15 = !DILocation(line: 7, column: 7, scope: !4) +!16 = !DILocation(line: 8, column: 5, scope: !17) +!17 = distinct !DILexicalBlock(line: 7, column: 7, file: !1, scope: !4) +!18 = !DILocation(line: 9, column: 1, scope: !4) + +; There should be no destination edges for the exit block. +; CHECK: Block : 1 Counter : 0 +; RETURN-LAST: Destination Edges +; RETURN-SECOND-NOT: Destination Edges +; CHECK: Block : 2 Counter : 0 +; CHECK: Block : 4 Counter : 0 +; RETURN-LAST-NOT: Destination Edges +; RETURN-SECOND: Destination Edges +; CHECK-NOT: Block : diff --git a/llvm/test/Transforms/GCOVProfiling/three-element-mdnode.ll b/llvm/test/Transforms/GCOVProfiling/three-element-mdnode.ll new file mode 100644 index 00000000000..0af01188986 --- /dev/null +++ b/llvm/test/Transforms/GCOVProfiling/three-element-mdnode.ll @@ -0,0 +1,28 @@ +; RUN: rm -rf %t && mkdir -p %t +; RUN: echo '!10 = !{!"%/t/aaa.gcno", !"%/t/bbb.gcda", !0}' > %t/1 +; RUN: cat %s %t/1 > %t/2 +; RUN: opt -insert-gcov-profiling -S -o %t/3 < %t/2 +; RUN: grep _Z3foov %t/aaa.gcno +; RUN: grep bbb.gcda %t/3 +; RUN: rm %t/aaa.gcno + +define void @_Z3foov() !dbg !5 { +entry: + ret void, !dbg !8 +} + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!9} +!llvm.gcov = !{!10} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.3 (trunk 177323)", isOptimized: false, emissionKind: FullDebug, file: !2, enums: !3, retainedTypes: !3, globals: !3, imports: !3) +!1 = !DIFile(filename: "hello.cc", directory: "/home/nlewycky") +!2 = !DIFile(filename: "hello.cc", directory: "/home/nlewycky") +!3 = !{} +!5 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", line: 1, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, scopeLine: 1, file: !1, scope: !1, type: !6, retainedNodes: !3) +!6 = !DISubroutineType(types: !7) +!7 = !{null} +!8 = !DILocation(line: 1, scope: !5) + + +!9 = !{i32 1, !"Debug Info Version", i32 3} diff --git a/llvm/test/Transforms/GCOVProfiling/version.ll b/llvm/test/Transforms/GCOVProfiling/version.ll new file mode 100644 index 00000000000..239c62f4a6b --- /dev/null +++ b/llvm/test/Transforms/GCOVProfiling/version.ll @@ -0,0 +1,38 @@ +; RUN: rm -rf %t && mkdir -p %t +; RUN: echo '!9 = !{!"%/t/version.ll", !0}' > %t/1 +; RUN: cat %s %t/1 > %t/2 +; RUN: opt -insert-gcov-profiling -disable-output < %t/2 +; RUN: head -c8 %t/version.gcno | grep '^oncg.204' +; RUN: rm %t/version.gcno +; RUN: not opt -insert-gcov-profiling -default-gcov-version=asdfasdf -disable-output < %t/2 +; RUN: opt -insert-gcov-profiling -default-gcov-version=407* -disable-output < %t/2 +; RUN: head -c8 %t/version.gcno | grep '^oncg.704' +; RUN: rm %t/version.gcno + +; RUN: opt -passes=insert-gcov-profiling -disable-output < %t/2 +; RUN: head -c8 %t/version.gcno | grep '^oncg.204' +; RUN: rm %t/version.gcno +; RUN: not opt -passes=insert-gcov-profiling -default-gcov-version=asdfasdf -disable-output < %t/2 +; RUN: opt -passes=insert-gcov-profiling -default-gcov-version=407* -disable-output < %t/2 +; RUN: head -c8 %t/version.gcno | grep '^oncg.704' +; RUN: rm %t/version.gcno + +define void @test() !dbg !5 { + ret void, !dbg !8 +} + +!llvm.gcov = !{!9} +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!12} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.3 (trunk 176994)", isOptimized: false, emissionKind: FullDebug, file: !11, enums: !3, retainedTypes: !3, globals: !3) +!2 = !DIFile(filename: "version", directory: "/usr/local/google/home/nlewycky") +!3 = !{} +!5 = distinct !DISubprogram(name: "test", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !10, scope: !6, type: !7, retainedNodes: !3) +!6 = !DIFile(filename: "<stdin>", directory: ".") +!7 = !DISubroutineType(types: !{null}) +!8 = !DILocation(line: 1, scope: !5) +;; !9 is added through the echo line at the top. +!10 = !DIFile(filename: "<stdin>", directory: ".") +!11 = !DIFile(filename: "version", directory: "/usr/local/google/home/nlewycky") +!12 = !{i32 1, !"Debug Info Version", i32 3} |

