1; RUN: llc -O3 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
2
3target 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"
4target triple = "thumbv7-apple-darwin10"
5
6@x1 = internal global i8 1, align 1
7@x2 = internal global i8 1, align 1
8@x3 = internal global i8 1, align 1
9@x4 = internal global i8 1, align 1
10@x5 = global i8 1, align 1
11
12; Check debug info output for merged global.
13; DW_AT_location
14; 0x03 DW_OP_addr
15; 0x.. .long __MergedGlobals
16; 0x10 DW_OP_constu
17; 0x.. offset
18; 0x22 DW_OP_plus
19
20; CHECK: DW_TAG_variable
21; CHECK-NOT: DW_TAG
22; CHECK:    DW_AT_name {{.*}} "x1"
23; CHECK-NOT: {{DW_TAG|NULL}}
24; CHECK:    DW_AT_location [DW_FORM_exprloc]        (<0x8> 03 [[ADDR:.. .. .. ..]] 10 00 22  )
25; CHECK: DW_TAG_variable
26; CHECK-NOT: DW_TAG
27; CHECK:    DW_AT_name {{.*}} "x2"
28; CHECK-NOT: {{DW_TAG|NULL}}
29; CHECK:    DW_AT_location [DW_FORM_exprloc]        (<0x8> 03 [[ADDR]] 10 01 22  )
30
31define zeroext i8 @get1(i8 zeroext %a) nounwind optsize {
32entry:
33  tail call void @llvm.dbg.value(metadata i8 %a, i64 0, metadata !10, metadata !MDExpression()), !dbg !30
34  %0 = load i8, i8* @x1, align 4, !dbg !30
35  tail call void @llvm.dbg.value(metadata i8 %0, i64 0, metadata !11, metadata !MDExpression()), !dbg !30
36  store i8 %a, i8* @x1, align 4, !dbg !30
37  ret i8 %0, !dbg !31
38}
39
40declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
41
42define zeroext i8 @get2(i8 zeroext %a) nounwind optsize {
43entry:
44  tail call void @llvm.dbg.value(metadata i8 %a, i64 0, metadata !18, metadata !MDExpression()), !dbg !32
45  %0 = load i8, i8* @x2, align 4, !dbg !32
46  tail call void @llvm.dbg.value(metadata i8 %0, i64 0, metadata !19, metadata !MDExpression()), !dbg !32
47  store i8 %a, i8* @x2, align 4, !dbg !32
48  ret i8 %0, !dbg !33
49}
50
51define zeroext i8 @get3(i8 zeroext %a) nounwind optsize {
52entry:
53  tail call void @llvm.dbg.value(metadata i8 %a, i64 0, metadata !21, metadata !MDExpression()), !dbg !34
54  %0 = load i8, i8* @x3, align 4, !dbg !34
55  tail call void @llvm.dbg.value(metadata i8 %0, i64 0, metadata !22, metadata !MDExpression()), !dbg !34
56  store i8 %a, i8* @x3, align 4, !dbg !34
57  ret i8 %0, !dbg !35
58}
59
60define zeroext i8 @get4(i8 zeroext %a) nounwind optsize {
61entry:
62  tail call void @llvm.dbg.value(metadata i8 %a, i64 0, metadata !24, metadata !MDExpression()), !dbg !36
63  %0 = load i8, i8* @x4, align 4, !dbg !36
64  tail call void @llvm.dbg.value(metadata i8 %0, i64 0, metadata !25, metadata !MDExpression()), !dbg !36
65  store i8 %a, i8* @x4, align 4, !dbg !36
66  ret i8 %0, !dbg !37
67}
68
69define zeroext i8 @get5(i8 zeroext %a) nounwind optsize {
70entry:
71  tail call void @llvm.dbg.value(metadata i8 %a, i64 0, metadata !27, metadata !MDExpression()), !dbg !38
72  %0 = load i8, i8* @x5, align 4, !dbg !38
73  tail call void @llvm.dbg.value(metadata i8 %0, i64 0, metadata !28, metadata !MDExpression()), !dbg !38
74  store i8 %a, i8* @x5, align 4, !dbg !38
75  ret i8 %0, !dbg !39
76}
77
78!llvm.dbg.cu = !{!2}
79!llvm.module.flags = !{!49}
80
81!0 = !MDSubprogram(name: "get1", linkageName: "get1", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 4, file: !47, scope: !1, type: !3, function: i8 (i8)* @get1, variables: !42)
82!1 = !MDFile(filename: "foo.c", directory: "/tmp/")
83!2 = !MDCompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2369.8)", isOptimized: true, emissionKind: 0, file: !47, enums: !48, retainedTypes: !48, subprograms: !40, globals: !41, imports:  !48)
84!3 = !MDSubroutineType(types: !4)
85!4 = !{!5, !5}
86!5 = !MDBasicType(tag: DW_TAG_base_type, name: "_Bool", size: 8, align: 8, encoding: DW_ATE_boolean)
87!6 = !MDSubprogram(name: "get2", linkageName: "get2", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 7, file: !47, scope: !1, type: !3, function: i8 (i8)* @get2, variables: !43)
88!7 = !MDSubprogram(name: "get3", linkageName: "get3", line: 10, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 10, file: !47, scope: !1, type: !3, function: i8 (i8)* @get3, variables: !44)
89!8 = !MDSubprogram(name: "get4", linkageName: "get4", line: 13, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 13, file: !47, scope: !1, type: !3, function: i8 (i8)* @get4, variables: !45)
90!9 = !MDSubprogram(name: "get5", linkageName: "get5", line: 16, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 16, file: !47, scope: !1, type: !3, function: i8 (i8)* @get5, variables: !46)
91!10 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "a", line: 4, arg: 0, scope: !0, file: !1, type: !5)
92!11 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "b", line: 4, scope: !12, file: !1, type: !5)
93!12 = distinct !MDLexicalBlock(line: 4, column: 0, file: !47, scope: !0)
94!13 = !MDGlobalVariable(name: "x1", line: 3, isLocal: true, isDefinition: true, scope: !1, file: !1, type: !5, variable: i8* @x1)
95!14 = !MDGlobalVariable(name: "x2", line: 6, isLocal: true, isDefinition: true, scope: !1, file: !1, type: !5, variable: i8* @x2)
96!15 = !MDGlobalVariable(name: "x3", line: 9, isLocal: true, isDefinition: true, scope: !1, file: !1, type: !5, variable: i8* @x3)
97!16 = !MDGlobalVariable(name: "x4", line: 12, isLocal: true, isDefinition: true, scope: !1, file: !1, type: !5, variable: i8* @x4)
98!17 = !MDGlobalVariable(name: "x5", line: 15, isLocal: false, isDefinition: true, scope: !1, file: !1, type: !5, variable: i8* @x5)
99!18 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "a", line: 7, arg: 0, scope: !6, file: !1, type: !5)
100!19 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "b", line: 7, scope: !20, file: !1, type: !5)
101!20 = distinct !MDLexicalBlock(line: 7, column: 0, file: !47, scope: !6)
102!21 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "a", line: 10, arg: 0, scope: !7, file: !1, type: !5)
103!22 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "b", line: 10, scope: !23, file: !1, type: !5)
104!23 = distinct !MDLexicalBlock(line: 10, column: 0, file: !47, scope: !7)
105!24 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "a", line: 13, arg: 0, scope: !8, file: !1, type: !5)
106!25 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "b", line: 13, scope: !26, file: !1, type: !5)
107!26 = distinct !MDLexicalBlock(line: 13, column: 0, file: !47, scope: !8)
108!27 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "a", line: 16, arg: 0, scope: !9, file: !1, type: !5)
109!28 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "b", line: 16, scope: !29, file: !1, type: !5)
110!29 = distinct !MDLexicalBlock(line: 16, column: 0, file: !47, scope: !9)
111!30 = !MDLocation(line: 4, scope: !0)
112!31 = !MDLocation(line: 4, scope: !12)
113!32 = !MDLocation(line: 7, scope: !6)
114!33 = !MDLocation(line: 7, scope: !20)
115!34 = !MDLocation(line: 10, scope: !7)
116!35 = !MDLocation(line: 10, scope: !23)
117!36 = !MDLocation(line: 13, scope: !8)
118!37 = !MDLocation(line: 13, scope: !26)
119!38 = !MDLocation(line: 16, scope: !9)
120!39 = !MDLocation(line: 16, scope: !29)
121!40 = !{!0, !6, !7, !8, !9}
122!41 = !{!13, !14, !15, !16, !17}
123!42 = !{!10, !11}
124!43 = !{!18, !19}
125!44 = !{!21, !22}
126!45 = !{!24, !25}
127!46 = !{!27, !28}
128!47 = !MDFile(filename: "foo.c", directory: "/tmp/")
129!48 = !{}
130!49 = !{i32 1, !"Debug Info Version", i32 3}
131