1 ; RUN: opt < %s -asan -asan-module -S | FileCheck %s
3 ; Checks that llvm.dbg.declare instructions are updated
4 ; accordingly as we merge allocas.
6 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
7 target triple = "x86_64-unknown-linux-gnu"
9 define i32 @_Z3zzzi(i32 %p) nounwind uwtable address_safety {
11 %p.addr = alloca i32, align 4
12 %r = alloca i32, align 4
13 store i32 %p, i32* %p.addr, align 4
14 call void @llvm.dbg.declare(metadata !{i32* %p.addr}, metadata !10), !dbg !11
15 call void @llvm.dbg.declare(metadata !{i32* %r}, metadata !12), !dbg !14
16 %0 = load i32* %p.addr, align 4, !dbg !14
17 %add = add nsw i32 %0, 1, !dbg !14
18 store i32 %add, i32* %r, align 4, !dbg !14
19 %1 = load i32* %r, align 4, !dbg !15
23 ; CHECK: define i32 @_Z3zzzi
25 ; Verify that llvm.dbg.declare calls are in the entry basic block.
27 ; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[ARG_ID:[0-9]+]])
29 ; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[VAR_ID:[0-9]+]])
31 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
35 !0 = metadata !{i32 786449, i32 0, i32 4, metadata !"a.cc", metadata !"/usr/local/google/llvm_cmake_clang/tmp/debuginfo", metadata !"clang version 3.3 (trunk 169314)", i1 true, i1 false, metadata !"", i32 0, metadata !1, metadata !1, metadata !3, metadata !1} ; [ DW_TAG_compile_unit ] [/usr/local/google/llvm_cmake_clang/tmp/debuginfo/a.cc] [DW_LANG_C_plus_plus]
36 !1 = metadata !{metadata !2}
37 !2 = metadata !{i32 0}
38 !3 = metadata !{metadata !4}
39 !4 = metadata !{metadata !5}
40 !5 = metadata !{i32 786478, i32 0, metadata !6, metadata !"zzz", metadata !"zzz", metadata !"_Z3zzzi", metadata !6, i32 1, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z3zzzi, null, null, metadata !1, i32 1} ; [ DW_TAG_subprogram ] [line 1] [def] [zzz]
41 !6 = metadata !{i32 786473, metadata !"a.cc", metadata !"/usr/local/google/llvm_cmake_clang/tmp/debuginfo", null} ; [ DW_TAG_file_type ]
42 !7 = metadata !{i32 786453, i32 0, metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
43 !8 = metadata !{metadata !9, metadata !9}
44 !9 = metadata !{i32 786468, null, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
45 !10 = metadata !{i32 786689, metadata !5, metadata !"p", metadata !6, i32 16777217, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [p] [line 1]
46 !11 = metadata !{i32 1, i32 0, metadata !5, null}
47 !12 = metadata !{i32 786688, metadata !13, metadata !"r", metadata !6, i32 2, metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [r] [line 2]
49 ; Verify that debug descriptors for argument and local variable will be replaced
50 ; with descriptors that end with OpDeref (encoded as 2).
51 ; CHECK: ![[ARG_ID]] = metadata {{.*}} i64 2} ; [ DW_TAG_arg_variable ] [p] [line 1]
52 ; CHECK: ![[VAR_ID]] = metadata {{.*}} i64 2} ; [ DW_TAG_auto_variable ] [r] [line 2]
53 ; Verify that there are no more variable descriptors.
54 ; CHECK-NOT: DW_TAG_arg_variable
55 ; CHECK-NOT: DW_TAG_auto_variable
58 !13 = metadata !{i32 786443, metadata !5, i32 1, i32 0, metadata !6, i32 0} ; [ DW_TAG_lexical_block ] [/usr/local/google/llvm_cmake_clang/tmp/debuginfo/a.cc]
59 !14 = metadata !{i32 2, i32 0, metadata !13, null}
60 !15 = metadata !{i32 3, i32 0, metadata !13, null}