Evgeniy Stepanov | aaf4bb2 | 2014-05-14 10:30:15 +0000 | [diff] [blame] | 1 | ; Test that coverage instrumentation does not lose debug location. |
| 2 | |
Kostya Serebryany | 29a18dc | 2014-11-11 22:14:37 +0000 | [diff] [blame] | 3 | ; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -S | FileCheck %s |
Evgeniy Stepanov | aaf4bb2 | 2014-05-14 10:30:15 +0000 | [diff] [blame] | 4 | |
Evgeniy Stepanov | 493df13 | 2014-06-05 14:34:45 +0000 | [diff] [blame] | 5 | ; C++ source: |
| 6 | ; 1: struct A { |
| 7 | ; 2: int f(); |
| 8 | ; 3: int x; |
| 9 | ; 4: }; |
| 10 | ; 5: |
| 11 | ; 6: int A::f() { |
| 12 | ; 7: return x; |
| 13 | ; 8: } |
| 14 | ; clang++ ../1.cc -O3 -g -S -emit-llvm -fno-strict-aliasing |
| 15 | ; and add sanitize_address to @_ZN1A1fEv |
| 16 | |
| 17 | ; Test that __sanitizer_cov call has !dbg pointing to the opening { of A::f(). |
Kostya Serebryany | 9fdeb37 | 2014-12-23 22:32:17 +0000 | [diff] [blame^] | 18 | ; CHECK: call void @__sanitizer_cov(i32*{{.*}}), !dbg [[A:!.*]] |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 19 | ; CHECK: [[A]] = !{i32 6, i32 0, !{{.*}}, null} |
Evgeniy Stepanov | 493df13 | 2014-06-05 14:34:45 +0000 | [diff] [blame] | 20 | |
| 21 | |
Evgeniy Stepanov | aaf4bb2 | 2014-05-14 10:30:15 +0000 | [diff] [blame] | 22 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 23 | target triple = "x86_64-unknown-linux-gnu" |
| 24 | |
Evgeniy Stepanov | 493df13 | 2014-06-05 14:34:45 +0000 | [diff] [blame] | 25 | %struct.A = type { i32 } |
| 26 | |
| 27 | ; Function Attrs: nounwind readonly uwtable |
| 28 | define i32 @_ZN1A1fEv(%struct.A* nocapture readonly %this) #0 align 2 { |
Evgeniy Stepanov | aaf4bb2 | 2014-05-14 10:30:15 +0000 | [diff] [blame] | 29 | entry: |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 30 | tail call void @llvm.dbg.value(metadata %struct.A* %this, i64 0, metadata !15, metadata !{!"0x102"}), !dbg !20 |
Evgeniy Stepanov | 493df13 | 2014-06-05 14:34:45 +0000 | [diff] [blame] | 31 | %x = getelementptr inbounds %struct.A* %this, i64 0, i32 0, !dbg !21 |
| 32 | %0 = load i32* %x, align 4, !dbg !21 |
| 33 | ret i32 %0, !dbg !21 |
Evgeniy Stepanov | aaf4bb2 | 2014-05-14 10:30:15 +0000 | [diff] [blame] | 34 | } |
| 35 | |
Evgeniy Stepanov | 493df13 | 2014-06-05 14:34:45 +0000 | [diff] [blame] | 36 | ; Function Attrs: nounwind readnone |
Adrian Prantl | 87b7eb9 | 2014-10-01 18:55:02 +0000 | [diff] [blame] | 37 | declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 |
Evgeniy Stepanov | aaf4bb2 | 2014-05-14 10:30:15 +0000 | [diff] [blame] | 38 | |
Evgeniy Stepanov | 493df13 | 2014-06-05 14:34:45 +0000 | [diff] [blame] | 39 | attributes #0 = { sanitize_address nounwind readonly 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" } |
| 40 | attributes #1 = { nounwind readnone } |
Evgeniy Stepanov | aaf4bb2 | 2014-05-14 10:30:15 +0000 | [diff] [blame] | 41 | |
| 42 | !llvm.dbg.cu = !{!0} |
Evgeniy Stepanov | 493df13 | 2014-06-05 14:34:45 +0000 | [diff] [blame] | 43 | !llvm.module.flags = !{!17, !18} |
| 44 | !llvm.ident = !{!19} |
Evgeniy Stepanov | aaf4bb2 | 2014-05-14 10:30:15 +0000 | [diff] [blame] | 45 | |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 46 | !0 = !{!"0x11\004\00clang version 3.5.0 (210251)\001\00\000\00\001", !1, !2, !3, !12, !2, !2} ; [ DW_TAG_compile_unit ] [/code/llvm/build0/../1.cc] [DW_LANG_C_plus_plus] |
| 47 | !1 = !{!"../1.cc", !"/code/llvm/build0"} |
| 48 | !2 = !{} |
| 49 | !3 = !{!4} |
| 50 | !4 = !{!"0x13\00A\001\0032\0032\000\000\000", !1, null, null, !5, null, null, !"_ZTS1A"} ; [ DW_TAG_structure_type ] [A] [line 1, size 32, align 32, offset 0] [def] [from ] |
| 51 | !5 = !{!6, !8} |
| 52 | !6 = !{!"0xd\00x\003\0032\0032\000\000", !1, !"_ZTS1A", !7} ; [ DW_TAG_member ] [x] [line 3, size 32, align 32, offset 0] [from int] |
| 53 | !7 = !{!"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] |
| 54 | !8 = !{!"0x2e\00f\00f\00_ZN1A1fEv\002\000\000\000\006\00256\001\002", !1, !"_ZTS1A", !9, null, null, null, i32 0, null} ; [ DW_TAG_subprogram ] [line 2] [f] |
| 55 | !9 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !10, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] |
| 56 | !10 = !{!7, !11} |
| 57 | !11 = !{!"0xf\00\000\0064\0064\000\001088", null, null, !"_ZTS1A"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1A] |
| 58 | !12 = !{!13} |
| 59 | !13 = !{!"0x2e\00f\00f\00_ZN1A1fEv\006\000\001\000\006\00256\001\006", !1, !"_ZTS1A", !9, null, i32 (%struct.A*)* @_ZN1A1fEv, null, !8, !14} ; [ DW_TAG_subprogram ] [line 6] [def] [f] |
| 60 | !14 = !{!15} |
| 61 | !15 = !{!"0x101\00this\0016777216\001088", !13, null, !16} ; [ DW_TAG_arg_variable ] [this] [line 0] |
| 62 | !16 = !{!"0xf\00\000\0064\0064\000\000", null, null, !"_ZTS1A"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from _ZTS1A] |
| 63 | !17 = !{i32 2, !"Dwarf Version", i32 4} |
| 64 | !18 = !{i32 2, !"Debug Info Version", i32 2} |
| 65 | !19 = !{!"clang version 3.5.0 (210251)"} |
| 66 | !20 = !{i32 0, i32 0, !13, null} |
| 67 | !21 = !{i32 7, i32 0, !13, null} |