b7d5d520add3a14f93339498d95eeace9bd6ac42
[oota-llvm.git] / test / DebugInfo / X86 / dbg-value-range.ll
1 ; RUN: llc -mtriple=x86_64-apple-darwin10 < %s | FileCheck %s
2
3 %struct.a = type { i32 }
4
5 define i32 @bar(%struct.a* nocapture %b) nounwind ssp {
6 entry:
7   tail call void @llvm.dbg.value(metadata %struct.a* %b, i64 0, metadata !6, metadata !DIExpression()), !dbg !13
8   %tmp1 = getelementptr inbounds %struct.a, %struct.a* %b, i64 0, i32 0, !dbg !14
9   %tmp2 = load i32, i32* %tmp1, align 4, !dbg !14
10   tail call void @llvm.dbg.value(metadata i32 %tmp2, i64 0, metadata !11, metadata !DIExpression()), !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
16 declare i32 @foo(...) 
17
18 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
19
20 !llvm.dbg.cu = !{!2}
21 !llvm.module.flags = !{!24}
22
23 !0 = !DISubprogram(name: "bar", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !22, scope: !1, type: !3, function: i32 (%struct.a*)* @bar, variables: !21)
24 !1 = !DIFile(filename: "bar.c", directory: "/private/tmp")
25 !2 = !DICompileUnit(language: DW_LANG_C99, producer: "clang version 2.9 (trunk 122997)", isOptimized: true, emissionKind: 1, file: !22, enums: !23, retainedTypes: !23, subprograms: !20, imports:  null)
26 !3 = !DISubroutineType(types: !4)
27 !4 = !{!5}
28 !5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
29 !6 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "b", line: 5, arg: 1, scope: !0, file: !1, type: !7)
30 !7 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, scope: !2, baseType: !8)
31 !8 = !DICompositeType(tag: DW_TAG_structure_type, name: "a", line: 1, size: 32, align: 32, file: !22, scope: !2, elements: !9)
32 !9 = !{!10}
33 !10 = !DIDerivedType(tag: DW_TAG_member, name: "c", line: 2, size: 32, align: 32, file: !22, scope: !1, baseType: !5)
34 !11 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "x", line: 6, scope: !12, file: !1, type: !5)
35 !12 = distinct !DILexicalBlock(line: 5, column: 22, file: !22, scope: !0)
36 !13 = !DILocation(line: 5, column: 19, scope: !0)
37 !14 = !DILocation(line: 6, column: 14, scope: !12)
38 !18 = !DILocation(line: 7, column: 2, scope: !12)
39 !19 = !DILocation(line: 8, column: 2, scope: !12)
40 !20 = !{!0}
41 !21 = !{!6, !11}
42 !22 = !DIFile(filename: "bar.c", directory: "/private/tmp")
43 !23 = !{}
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:  .short 1 ## Loc expr size
59 ;CHECK-NEXT:    .byte   85 ## DW_OP_reg
60 ;CHECK-NEXT:    .quad   0
61 ;CHECK-NEXT:    .quad   0
62 !24 = !{i32 1, !"Debug Info Version", i32 3}