2014-09-03 23:24:18 +00:00
|
|
|
; Test that coverage instrumentation does not lose debug location.
|
|
|
|
|
2014-11-11 22:14:37 +00:00
|
|
|
; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -S | FileCheck %s
|
2014-09-03 23:24:18 +00:00
|
|
|
|
|
|
|
; C++ source:
|
|
|
|
; 1: void foo(int *a) {
|
|
|
|
; 2: if (a)
|
|
|
|
; 3: *a = 0;
|
|
|
|
; 4: }
|
|
|
|
; clang++ if.cc -O3 -g -S -emit-llvm
|
|
|
|
; and add sanitize_address to @_Z3fooPi
|
|
|
|
|
|
|
|
|
|
|
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
|
|
|
|
; Check that __sanitizer_cov call has !dgb pointing to the beginning
|
|
|
|
; of appropriate basic blocks.
|
|
|
|
; CHECK-LABEL:_Z3fooPi
|
2014-11-24 18:49:53 +00:00
|
|
|
; CHECK: call void @__sanitizer_cov(i8*{{.*}}), !dbg [[A:!.*]]
|
|
|
|
; CHECK: call void @__sanitizer_cov(i8*{{.*}}), !dbg [[B:!.*]]
|
|
|
|
; CHECK: call void @__sanitizer_cov(i8*{{.*}}), !dbg [[C:!.*]]
|
2014-09-03 23:24:18 +00:00
|
|
|
; CHECK: ret void
|
|
|
|
; CHECK: [[A]] = metadata !{i32 1, i32 0, metadata !{{.*}}, null}
|
|
|
|
; CHECK: [[B]] = metadata !{i32 3, i32 5, metadata !{{.*}}, null}
|
|
|
|
; CHECK: [[C]] = metadata !{i32 4, i32 1, metadata !{{.*}}, null}
|
|
|
|
|
|
|
|
define void @_Z3fooPi(i32* %a) #0 {
|
|
|
|
entry:
|
2014-10-03 20:01:09 +00:00
|
|
|
tail call void @llvm.dbg.value(metadata !{i32* %a}, i64 0, metadata !11, metadata !{metadata !"0x102"}), !dbg !15
|
2014-09-03 23:24:18 +00:00
|
|
|
%tobool = icmp eq i32* %a, null, !dbg !16
|
|
|
|
br i1 %tobool, label %if.end, label %if.then, !dbg !16
|
|
|
|
|
|
|
|
if.then: ; preds = %entry
|
|
|
|
store i32 0, i32* %a, align 4, !dbg !18, !tbaa !19
|
|
|
|
br label %if.end, !dbg !18
|
|
|
|
|
|
|
|
if.end: ; preds = %entry, %if.then
|
|
|
|
ret void, !dbg !23
|
|
|
|
}
|
|
|
|
|
|
|
|
; Function Attrs: nounwind readnone
|
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
|
|
|
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
|
2014-09-03 23:24:18 +00:00
|
|
|
|
|
|
|
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" sanitize_address}
|
|
|
|
attributes #1 = { nounwind readnone }
|
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
|
|
!llvm.module.flags = !{!12, !13}
|
|
|
|
!llvm.ident = !{!14}
|
|
|
|
|
2014-10-03 20:01:09 +00:00
|
|
|
!0 = metadata !{metadata !"0x11\004\00clang version 3.6.0 (217079)\001\00\000\00\001", metadata !1, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [FOO/if.cc] [DW_LANG_C_plus_plus]
|
2014-09-03 23:24:18 +00:00
|
|
|
!1 = metadata !{metadata !"if.cc", metadata !"FOO"}
|
|
|
|
!2 = metadata !{}
|
|
|
|
!3 = metadata !{metadata !4}
|
2014-10-03 20:01:09 +00:00
|
|
|
!4 = metadata !{metadata !"0x2e\00foo\00foo\00_Z3fooPi\001\000\001\000\006\00256\001\001", metadata !1, metadata !5, metadata !6, null, void (i32*)* @_Z3fooPi, null, null, metadata !10} ; [ DW_TAG_subprogram ] [line 1] [def] [foo]
|
|
|
|
!5 = metadata !{metadata !"0x29", metadata !1} ; [ DW_TAG_file_type ] [FOO/if.cc]
|
|
|
|
!6 = metadata !{metadata !"0x15\00\000\000\000\000\000\000", i32 0, null, null, metadata !7, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
|
2014-09-03 23:24:18 +00:00
|
|
|
!7 = metadata !{null, metadata !8}
|
2014-10-03 20:01:09 +00:00
|
|
|
!8 = metadata !{metadata !"0xf\00\000\0064\0064\000\000", null, null, metadata !9} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int]
|
|
|
|
!9 = metadata !{metadata !"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]
|
2014-09-03 23:24:18 +00:00
|
|
|
!10 = metadata !{metadata !11}
|
2014-10-03 20:01:09 +00:00
|
|
|
!11 = metadata !{metadata !"0x101\00a\0016777217\000", metadata !4, metadata !5, metadata !8} ; [ DW_TAG_arg_variable ] [a] [line 1]
|
2014-09-03 23:24:18 +00:00
|
|
|
!12 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
|
2014-10-03 20:01:09 +00:00
|
|
|
!13 = metadata !{i32 2, metadata !"Debug Info Version", i32 2}
|
2014-09-03 23:24:18 +00:00
|
|
|
!14 = metadata !{metadata !"clang version 3.6.0 (217079)"}
|
|
|
|
!15 = metadata !{i32 1, i32 15, metadata !4, null}
|
|
|
|
!16 = metadata !{i32 2, i32 7, metadata !17, null}
|
2014-10-03 20:01:09 +00:00
|
|
|
!17 = metadata !{metadata !"0xb\002\007\000", metadata !1, metadata !4} ; [ DW_TAG_lexical_block ] [FOO/if.cc]
|
2014-09-03 23:24:18 +00:00
|
|
|
!18 = metadata !{i32 3, i32 5, metadata !17, null}
|
|
|
|
!19 = metadata !{metadata !20, metadata !20, i64 0}
|
|
|
|
!20 = metadata !{metadata !"int", metadata !21, i64 0}
|
|
|
|
!21 = metadata !{metadata !"omnipotent char", metadata !22, i64 0}
|
|
|
|
!22 = metadata !{metadata !"Simple C/C++ TBAA"}
|
|
|
|
!23 = metadata !{i32 4, i32 1, metadata !4, null}
|