1; RUN: llc < %s | FileCheck %s
2
3; Check debug info output for merged global.
4; DW_AT_location
5; DW_OP_addr
6; DW_OP_plus
7; .long __MergedGlobals
8; DW_OP_constu
9; offset
10
11;CHECK:        .ascii   "x2"                   @ DW_AT_name
12;CHECK-NEXT:        .byte   0
13;CHECK-NEXT:        @ DW_AT_type
14;CHECK-NEXT:        @ DW_AT_decl_file
15;CHECK-NEXT:        @ DW_AT_decl_line
16;CHECK-NEXT:        @ DW_AT_location
17;CHECK-NEXT:        .byte   3
18;CHECK-NEXT:        .long   __MergedGlobals
19;CHECK-NEXT:        .byte   16
20; 4 is byte offset of x2 in __MergedGobals
21;CHECK-NEXT:        .byte   4
22;CHECK-NEXT:        .byte   34
23
24
25target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32"
26target triple = "thumbv7-apple-macosx10.7.0"
27
28@x1 = internal unnamed_addr global i32 1, align 4
29@x2 = internal unnamed_addr global i32 2, align 4
30@x3 = internal unnamed_addr global i32 3, align 4
31@x4 = internal unnamed_addr global i32 4, align 4
32@x5 = global i32 0, align 4
33
34define i32 @get1(i32 %a) nounwind optsize ssp {
35  tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !10), !dbg !30
36  %1 = load i32* @x1, align 4, !dbg !31
37  tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !11), !dbg !31
38  store i32 %a, i32* @x1, align 4, !dbg !31
39  ret i32 %1, !dbg !31
40}
41
42define i32 @get2(i32 %a) nounwind optsize ssp {
43  tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !13), !dbg !32
44  %1 = load i32* @x2, align 4, !dbg !33
45  tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !14), !dbg !33
46  store i32 %a, i32* @x2, align 4, !dbg !33
47  ret i32 %1, !dbg !33
48}
49
50define i32 @get3(i32 %a) nounwind optsize ssp {
51  tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !16), !dbg !34
52  %1 = load i32* @x3, align 4, !dbg !35
53  tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !17), !dbg !35
54  store i32 %a, i32* @x3, align 4, !dbg !35
55  ret i32 %1, !dbg !35
56}
57
58define i32 @get4(i32 %a) nounwind optsize ssp {
59  tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !19), !dbg !36
60  %1 = load i32* @x4, align 4, !dbg !37
61  tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !20), !dbg !37
62  store i32 %a, i32* @x4, align 4, !dbg !37
63  ret i32 %1, !dbg !37
64}
65
66define i32 @get5(i32 %a) nounwind optsize ssp {
67  tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !27), !dbg !38
68  %1 = load i32* @x5, align 4, !dbg !39
69  tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !28), !dbg !39
70  store i32 %a, i32* @x5, align 4, !dbg !39
71  ret i32 %1, !dbg !39
72}
73
74declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
75
76!llvm.dbg.cu = !{!0}
77!llvm.dbg.sp = !{!1, !6, !7, !8, !9}
78!llvm.dbg.lv.get1 = !{!10, !11}
79!llvm.dbg.lv.get2 = !{!13, !14}
80!llvm.dbg.lv.get3 = !{!16, !17}
81!llvm.dbg.lv.get4 = !{!19, !20}
82!llvm.dbg.gv = !{!22, !23, !24, !25, !26}
83!llvm.dbg.lv.get5 = !{!27, !28}
84
85!0 = metadata !{i32 589841, i32 0, i32 12, metadata !"ss3.c", metadata !"/private/tmp", metadata !"clang", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
86!1 = metadata !{i32 589870, i32 0, metadata !2, metadata !"get1", metadata !"get1", metadata !"", metadata !2, i32 5, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, i32 (i32)* @get1, null, null} ; [ DW_TAG_subprogram ]
87!2 = metadata !{i32 589865, metadata !"ss3.c", metadata !"/private/tmp", metadata !0} ; [ DW_TAG_file_type ]
88!3 = metadata !{i32 589845, metadata !2, metadata !"", metadata !2, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
89!4 = metadata !{metadata !5}
90!5 = metadata !{i32 589860, metadata !0, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
91!6 = metadata !{i32 589870, i32 0, metadata !2, metadata !"get2", metadata !"get2", metadata !"", metadata !2, i32 8, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, i32 (i32)* @get2, null, null} ; [ DW_TAG_subprogram ]
92!7 = metadata !{i32 589870, i32 0, metadata !2, metadata !"get3", metadata !"get3", metadata !"", metadata !2, i32 11, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, i32 (i32)* @get3, null, null} ; [ DW_TAG_subprogram ]
93!8 = metadata !{i32 589870, i32 0, metadata !2, metadata !"get4", metadata !"get4", metadata !"", metadata !2, i32 14, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, i32 (i32)* @get4, null, null} ; [ DW_TAG_subprogram ]
94!9 = metadata !{i32 589870, i32 0, metadata !2, metadata !"get5", metadata !"get5", metadata !"", metadata !2, i32 17, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, i32 (i32)* @get5, null, null} ; [ DW_TAG_subprogram ]
95!10 = metadata !{i32 590081, metadata !1, metadata !"a", metadata !2, i32 16777221, metadata !5, i32 0} ; [ DW_TAG_arg_variable ]
96!11 = metadata !{i32 590080, metadata !12, metadata !"b", metadata !2, i32 5, metadata !5, i32 0} ; [ DW_TAG_auto_variable ]
97!12 = metadata !{i32 589835, metadata !1, i32 5, i32 19, metadata !2, i32 0} ; [ DW_TAG_lexical_block ]
98!13 = metadata !{i32 590081, metadata !6, metadata !"a", metadata !2, i32 16777224, metadata !5, i32 0} ; [ DW_TAG_arg_variable ]
99!14 = metadata !{i32 590080, metadata !15, metadata !"b", metadata !2, i32 8, metadata !5, i32 0} ; [ DW_TAG_auto_variable ]
100!15 = metadata !{i32 589835, metadata !6, i32 8, i32 17, metadata !2, i32 1} ; [ DW_TAG_lexical_block ]
101!16 = metadata !{i32 590081, metadata !7, metadata !"a", metadata !2, i32 16777227, metadata !5, i32 0} ; [ DW_TAG_arg_variable ]
102!17 = metadata !{i32 590080, metadata !18, metadata !"b", metadata !2, i32 11, metadata !5, i32 0} ; [ DW_TAG_auto_variable ]
103!18 = metadata !{i32 589835, metadata !7, i32 11, i32 19, metadata !2, i32 2} ; [ DW_TAG_lexical_block ]
104!19 = metadata !{i32 590081, metadata !8, metadata !"a", metadata !2, i32 16777230, metadata !5, i32 0} ; [ DW_TAG_arg_variable ]
105!20 = metadata !{i32 590080, metadata !21, metadata !"b", metadata !2, i32 14, metadata !5, i32 0} ; [ DW_TAG_auto_variable ]
106!21 = metadata !{i32 589835, metadata !8, i32 14, i32 19, metadata !2, i32 3} ; [ DW_TAG_lexical_block ]
107!22 = metadata !{i32 589876, i32 0, metadata !0, metadata !"x5", metadata !"x5", metadata !"", metadata !2, i32 16, metadata !5, i32 0, i32 1, i32* @x5} ; [ DW_TAG_variable ]
108!23 = metadata !{i32 589876, i32 0, metadata !0, metadata !"x4", metadata !"x4", metadata !"", metadata !2, i32 13, metadata !5, i32 1, i32 1, i32* @x4} ; [ DW_TAG_variable ]
109!24 = metadata !{i32 589876, i32 0, metadata !0, metadata !"x3", metadata !"x3", metadata !"", metadata !2, i32 10, metadata !5, i32 1, i32 1, i32* @x3} ; [ DW_TAG_variable ]
110!25 = metadata !{i32 589876, i32 0, metadata !0, metadata !"x2", metadata !"x2", metadata !"", metadata !2, i32 7, metadata !5, i32 1, i32 1, i32* @x2} ; [ DW_TAG_variable ]
111!26 = metadata !{i32 589876, i32 0, metadata !0, metadata !"x1", metadata !"x1", metadata !"", metadata !2, i32 4, metadata !5, i32 1, i32 1, i32* @x1} ; [ DW_TAG_variable ]
112!27 = metadata !{i32 590081, metadata !9, metadata !"a", metadata !2, i32 16777233, metadata !5, i32 0} ; [ DW_TAG_arg_variable ]
113!28 = metadata !{i32 590080, metadata !29, metadata !"b", metadata !2, i32 17, metadata !5, i32 0} ; [ DW_TAG_auto_variable ]
114!29 = metadata !{i32 589835, metadata !9, i32 17, i32 19, metadata !2, i32 4} ; [ DW_TAG_lexical_block ]
115!30 = metadata !{i32 5, i32 16, metadata !1, null}
116!31 = metadata !{i32 5, i32 32, metadata !12, null}
117!32 = metadata !{i32 8, i32 14, metadata !6, null}
118!33 = metadata !{i32 8, i32 29, metadata !15, null}
119!34 = metadata !{i32 11, i32 16, metadata !7, null}
120!35 = metadata !{i32 11, i32 32, metadata !18, null}
121!36 = metadata !{i32 14, i32 16, metadata !8, null}
122!37 = metadata !{i32 14, i32 32, metadata !21, null}
123!38 = metadata !{i32 17, i32 16, metadata !9, null}
124!39 = metadata !{i32 17, i32 32, metadata !29, null}
125