IR: Move MDLocation into place
[oota-llvm.git] / test / DebugInfo / X86 / dbg-value-location.ll
1 ; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s
2 ; RUN: llc -filetype=obj %s -regalloc=basic -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s
3 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"
4 target triple = "x86_64-apple-darwin10.0.0"
5 ; Test that the type for the formal parameter "var" makes it into the debug info.
6 ; rdar://8950491
7
8 ;CHECK: DW_TAG_formal_parameter
9 ;CHECK-NEXT: DW_AT_location
10 ;CHECK-NEXT: DW_AT_name {{.*}} "var"
11 ;CHECK-NEXT: DW_AT_decl_file
12 ;CHECK-NEXT: DW_AT_decl_line
13 ;CHECK-NEXT: DW_AT_type
14
15 @dfm = external global i32, align 4
16
17 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
18
19 define i32 @foo(i32 %dev, i64 %cmd, i8* %data, i32 %data2) nounwind optsize ssp {
20 entry:
21   call void @llvm.dbg.value(metadata i32 %dev, i64 0, metadata !12, metadata !{!"0x102"}), !dbg !13
22   %tmp.i = load i32* @dfm, align 4, !dbg !14
23   %cmp.i = icmp eq i32 %tmp.i, 0, !dbg !14
24   br i1 %cmp.i, label %if.else, label %if.end.i, !dbg !14
25
26 if.end.i:                                         ; preds = %entry
27   switch i64 %cmd, label %if.then [
28     i64 2147772420, label %bb.i
29     i64 536897538, label %bb116.i
30   ], !dbg !22
31
32 bb.i:                                             ; preds = %if.end.i
33   unreachable
34
35 bb116.i:                                          ; preds = %if.end.i
36   unreachable
37
38 if.then:                                          ; preds = %if.end.i
39   ret i32 undef, !dbg !23
40
41 if.else:                                          ; preds = %entry
42   ret i32 0
43 }
44
45 declare hidden fastcc i32 @bar(i32, i32* nocapture) nounwind optsize ssp
46 declare hidden fastcc i32 @bar2(i32) nounwind optsize ssp
47 declare hidden fastcc i32 @bar3(i32) nounwind optsize ssp
48 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
49
50 !llvm.dbg.cu = !{!2}
51 !llvm.module.flags = !{!29}
52
53 !0 = !{!"0x2e\00foo\00foo\00\0019510\000\001\000\006\00256\001\0019510", !26, !1, !3, null, i32 (i32, i64, i8*, i32)* @foo, null, null, null} ; [ DW_TAG_subprogram ] [line 19510] [def] [foo]
54 !1 = !{!"0x29", !26} ; [ DW_TAG_file_type ]
55 !2 = !{!"0x11\0012\00clang version 2.9 (trunk 124753)\001\00\000\00\000", !27, !28, !28, !24, null,  null} ; [ DW_TAG_compile_unit ]
56 !3 = !{!"0x15\00\000\000\000\000\000\000", !26, !1, null, !4, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
57 !4 = !{!5}
58 !5 = !{!"0x24\00int\000\0032\0032\000\000\005", null, !2} ; [ DW_TAG_base_type ]
59 !6 = !{!"0x2e\00bar3\00bar3\00\0014827\001\001\000\006\00256\001\000", !26, !1, !3, null, i32 (i32)* @bar3, null, null, null} ; [ DW_TAG_subprogram ] [line 14827] [local] [def] [scope 0] [bar3]
60 !7 = !{!"0x2e\00bar2\00bar2\00\0015397\001\001\000\006\00256\001\000", !26, !1, !3, null, i32 (i32)* @bar2, null, null, null} ; [ DW_TAG_subprogram ] [line 15397] [local] [def] [scope 0] [bar2]
61 !8 = !{!"0x2e\00bar\00bar\00\0012382\001\001\000\006\00256\001\000", !26, !1, !9, null, i32 (i32, i32*)* @bar, null, null, null} ; [ DW_TAG_subprogram ] [line 12382] [local] [def] [scope 0] [bar]
62 !9 = !{!"0x15\00\000\000\000\000\000\000", !26, !1, null, !10, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
63 !10 = !{!11}
64 !11 = !{!"0x24\00unsigned char\000\008\008\000\000\008", null, !2} ; [ DW_TAG_base_type ]
65 !12 = !{!"0x101\00var\0019509\000", !0, !1, !5} ; [ DW_TAG_arg_variable ]
66 !13 = !MDLocation(line: 19509, column: 20, scope: !0)
67 !14 = !MDLocation(line: 18091, column: 2, scope: !15, inlinedAt: !17)
68 !15 = !{!"0xb\0018086\001\00748", !26, !16} ; [ DW_TAG_lexical_block ]
69 !16 = !{!"0x2e\00foo_bar\00foo_bar\00\0018086\001\001\000\006\00256\001\000", !26, !1, !3, null, null, null, null, null} ; [ DW_TAG_subprogram ] [line 18086] [local] [def] [scope 0] [foo_bar]
70 !17 = !MDLocation(line: 19514, column: 2, scope: !18)
71 !18 = !{!"0xb\0019510\001\0099", !26, !0} ; [ DW_TAG_lexical_block ]
72 !22 = !MDLocation(line: 18094, column: 2, scope: !15, inlinedAt: !17)
73 !23 = !MDLocation(line: 19524, column: 1, scope: !18)
74 !24 = !{!0, !6, !7, !8, !16}
75 !25 = !{!"0x29", !27} ; [ DW_TAG_file_type ]
76 !26 = !{!"/tmp/f.c", !"/tmp"}
77 !27 = !{!"f.i", !"/tmp"}
78 !28 = !{i32 0}
79 !29 = !{i32 1, !"Debug Info Version", i32 2}