1; RUN: llc -mtriple=x86_64-apple-darwin10 < %s | FileCheck %s
2
3%struct.a = type { i32 }
4
5define i32 @bar(%struct.a* nocapture %b) nounwind ssp {
6entry:
7  tail call void @llvm.dbg.value(metadata %struct.a* %b, i64 0, metadata !6, metadata !{!"0x102"}), !dbg !13
8  %tmp1 = getelementptr inbounds %struct.a* %b, i64 0, i32 0, !dbg !14
9  %tmp2 = load i32* %tmp1, align 4, !dbg !14
10  tail call void @llvm.dbg.value(metadata i32 %tmp2, i64 0, metadata !11, metadata !{!"0x102"}), !dbg !14
11  %call = tail call i32 (...)* @foo(i32 %tmp2) nounwind , !dbg !18
12  %add = add nsw i32 %tmp2, 1, !dbg !19
13  ret i32 %add, !dbg !19
14}
15
16declare i32 @foo(...)
17
18declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
19
20!llvm.dbg.cu = !{!2}
21!llvm.module.flags = !{!24}
22
23!0 = !{!"0x2e\00bar\00bar\00\005\000\001\000\006\00256\001\000", !22, !1, !3, null, i32 (%struct.a*)* @bar, null, null, !21} ; [ DW_TAG_subprogram ] [line 5] [def] [scope 0] [bar]
24!1 = !{!"0x29", !22} ; [ DW_TAG_file_type ]
25!2 = !{!"0x11\0012\00clang version 2.9 (trunk 122997)\001\00\000\00\001", !22, !23, !23, !20, null,  null} ; [ DW_TAG_compile_unit ]
26!3 = !{!"0x15\00\000\000\000\000\000\000", !22, !1, null, !4, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
27!4 = !{!5}
28!5 = !{!"0x24\00int\000\0032\0032\000\000\005", null, !2} ; [ DW_TAG_base_type ]
29!6 = !{!"0x101\00b\005\000", !0, !1, !7} ; [ DW_TAG_arg_variable ]
30!7 = !{!"0xf\00\000\0064\0064\000\000", null, !2, !8} ; [ DW_TAG_pointer_type ]
31!8 = !{!"0x13\00a\001\0032\0032\000\000\000", !22, !2, null, !9, null, null, null} ; [ DW_TAG_structure_type ] [a] [line 1, size 32, align 32, offset 0] [def] [from ]
32!9 = !{!10}
33!10 = !{!"0xd\00c\002\0032\0032\000\000", !22, !1, !5} ; [ DW_TAG_member ]
34!11 = !{!"0x100\00x\006\000", !12, !1, !5} ; [ DW_TAG_auto_variable ]
35!12 = !{!"0xb\005\0022\000", !22, !0} ; [ DW_TAG_lexical_block ]
36!13 = !MDLocation(line: 5, column: 19, scope: !0)
37!14 = !MDLocation(line: 6, column: 14, scope: !12)
38!18 = !MDLocation(line: 7, column: 2, scope: !12)
39!19 = !MDLocation(line: 8, column: 2, scope: !12)
40!20 = !{!0}
41!21 = !{!6, !11}
42!22 = !{!"bar.c", !"/private/tmp"}
43!23 = !{i32 0}
44
45; Check that variable bar:b value range is appropriately truncated in debug info.
46; The variable is in %rdi which is clobbered by 'movl %ebx, %edi'
47; Here Ltmp7 is the end of the location range.
48
49;CHECK: .loc	1 7 2
50;CHECK: movl
51;CHECK-NEXT: [[CLOBBER:Ltmp[0-9]*]]
52
53;CHECK:Ldebug_loc0:
54;CHECK-NEXT: Lset{{.*}} =
55;CHECK-NEXT:	.quad
56;CHECK-NEXT: [[CLOBBER_OFF:Lset.*]] = [[CLOBBER]]-{{.*}}
57;CHECK-NEXT:	.quad	[[CLOBBER_OFF]]
58;CHECK-NEXT: Lset{{.*}} = Ltmp{{.*}}-Ltmp{{.*}}
59;CHECK-NEXT:    .short  Lset
60;CHECK-NEXT: Ltmp
61;CHECK-NEXT:	.byte	85 ## DW_OP_reg
62;CHECK-NEXT: Ltmp
63;CHECK-NEXT:	.quad	0
64;CHECK-NEXT:	.quad	0
65!24 = !{i32 1, !"Debug Info Version", i32 2}
66