IR: Make metadata typeless in assembly
[oota-llvm.git] / test / Instrumentation / SanitizerCoverage / coverage2-dbg.ll
1 ; Test that coverage instrumentation does not lose debug location.
2
3 ; RUN: opt < %s -sancov  -sanitizer-coverage-level=2 -S | FileCheck %s
4
5 ; C++ source:
6 ; 1: void foo(int *a) {
7 ; 2:     if (a)
8 ; 3:         *a = 0;
9 ; 4: }
10 ; clang++ if.cc -O3 -g -S -emit-llvm
11 ; and add sanitize_address to @_Z3fooPi
12
13
14 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
15 target triple = "x86_64-unknown-linux-gnu"
16
17 ; Check that __sanitizer_cov call has !dgb pointing to the beginning
18 ; of appropriate basic blocks.
19 ; CHECK-LABEL:_Z3fooPi
20 ; CHECK: call void @__sanitizer_cov(i8*{{.*}}), !dbg [[A:!.*]]
21 ; CHECK: call void @__sanitizer_cov(i8*{{.*}}), !dbg [[B:!.*]]
22 ; CHECK: call void @__sanitizer_cov(i8*{{.*}}), !dbg [[C:!.*]]
23 ; CHECK: ret void
24 ; CHECK: [[A]] = !{i32 1, i32 0, !{{.*}}, null}
25 ; CHECK: [[B]] = !{i32 3, i32 5, !{{.*}}, null}
26 ; CHECK: [[C]] = !{i32 4, i32 1, !{{.*}}, null}
27
28 define void @_Z3fooPi(i32* %a) #0 {
29 entry:
30   tail call void @llvm.dbg.value(metadata i32* %a, i64 0, metadata !11, metadata !{!"0x102"}), !dbg !15
31   %tobool = icmp eq i32* %a, null, !dbg !16
32   br i1 %tobool, label %if.end, label %if.then, !dbg !16
33
34 if.then:                                          ; preds = %entry
35   store i32 0, i32* %a, align 4, !dbg !18, !tbaa !19
36   br label %if.end, !dbg !18
37
38 if.end:                                           ; preds = %entry, %if.then
39   ret void, !dbg !23
40 }
41
42 ; Function Attrs: nounwind readnone
43 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
44
45 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}
46 attributes #1 = { nounwind readnone }
47
48 !llvm.dbg.cu = !{!0}
49 !llvm.module.flags = !{!12, !13}
50 !llvm.ident = !{!14}
51
52 !0 = !{!"0x11\004\00clang version 3.6.0 (217079)\001\00\000\00\001", !1, !2, !2, !3, !2, !2} ; [ DW_TAG_compile_unit ] [FOO/if.cc] [DW_LANG_C_plus_plus]
53 !1 = !{!"if.cc", !"FOO"}
54 !2 = !{}
55 !3 = !{!4}
56 !4 = !{!"0x2e\00foo\00foo\00_Z3fooPi\001\000\001\000\006\00256\001\001", !1, !5, !6, null, void (i32*)* @_Z3fooPi, null, null, !10} ; [ DW_TAG_subprogram ] [line 1] [def] [foo]
57 !5 = !{!"0x29", !1}          ; [ DW_TAG_file_type ] [FOO/if.cc]
58 !6 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !7, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
59 !7 = !{null, !8}
60 !8 = !{!"0xf\00\000\0064\0064\000\000", null, null, !9} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int]
61 !9 = !{!"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]
62 !10 = !{!11}
63 !11 = !{!"0x101\00a\0016777217\000", !4, !5, !8} ; [ DW_TAG_arg_variable ] [a] [line 1]
64 !12 = !{i32 2, !"Dwarf Version", i32 4}
65 !13 = !{i32 2, !"Debug Info Version", i32 2}
66 !14 = !{!"clang version 3.6.0 (217079)"}
67 !15 = !{i32 1, i32 15, !4, null}
68 !16 = !{i32 2, i32 7, !17, null}
69 !17 = !{!"0xb\002\007\000", !1, !4} ; [ DW_TAG_lexical_block ] [FOO/if.cc]
70 !18 = !{i32 3, i32 5, !17, null}
71 !19 = !{!20, !20, i64 0}
72 !20 = !{!"int", !21, i64 0}
73 !21 = !{!"omnipotent char", !22, i64 0}
74 !22 = !{!"Simple C/C++ TBAA"}
75 !23 = !{i32 4, i32 1, !4, null}