IR: Give 'DI' prefix to debug info metadata
[oota-llvm.git] / test / DebugInfo / X86 / parameters.ll
1 ; REQUIRES: object-emission
2 ;
3 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -O0 -filetype=obj < %s > %t
4 ; RUN: llvm-dwarfdump %t | FileCheck %s
5
6 ; Test case derived from compiling the following source with clang -g:
7 ;
8 ; namespace pr14763 {
9 ; struct foo {
10 ;   foo(const foo&);
11 ; };
12 ;
13 ; foo func(foo f) {
14 ;   return f; // reference 'f' for now because otherwise we hit another bug
15 ; }
16 ;
17 ; void sink(void*);
18 ;
19 ; void func2(bool b, foo g) {
20 ;   if (b)
21 ;     sink(&g); // reference 'f' for now because otherwise we hit another bug
22 ; }
23 ; }
24
25 ; CHECK: debug_info contents
26 ; 0x74 is DW_OP_breg4, showing that the parameter is accessed indirectly
27 ; (with a zero offset) from the register parameter
28 ; CHECK: DW_AT_location{{.*}}(<0x0{{.}}> 74 00
29 ; CHECK-NOT: DW_TAG
30 ; CHECK: DW_AT_name{{.*}} = "f"
31
32 ; CHECK: DW_AT_location{{.*}}([[G_LOC:0x[0-9]*]])
33 ; CHECK-NOT: DW_TAG
34 ; CHECK: DW_AT_name{{.*}} = "g"
35 ; CHECK: debug_loc contents
36 ; CHECK-NEXT: [[G_LOC]]: Beginning
37 ; CHECK-NEXT:               Ending
38 ; CHECK-NEXT: Location description: 74 00
39
40 %"struct.pr14763::foo" = type { i8 }
41
42 ; Function Attrs: uwtable
43 define void @_ZN7pr147634funcENS_3fooE(%"struct.pr14763::foo"* noalias sret %agg.result, %"struct.pr14763::foo"* %f) #0 {
44 entry:
45   call void @llvm.dbg.declare(metadata %"struct.pr14763::foo"* %f, metadata !22, metadata !DIExpression(DW_OP_deref)), !dbg !24
46   call void @_ZN7pr147633fooC1ERKS0_(%"struct.pr14763::foo"* %agg.result, %"struct.pr14763::foo"* %f), !dbg !25
47   ret void, !dbg !25
48 }
49
50 ; Function Attrs: nounwind readnone
51 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
52
53 declare void @_ZN7pr147633fooC1ERKS0_(%"struct.pr14763::foo"*, %"struct.pr14763::foo"*) #2
54
55 ; Function Attrs: uwtable
56 define void @_ZN7pr147635func2EbNS_3fooE(i1 zeroext %b, %"struct.pr14763::foo"* %g) #0 {
57 entry:
58   %b.addr = alloca i8, align 1
59   %frombool = zext i1 %b to i8
60   store i8 %frombool, i8* %b.addr, align 1
61   call void @llvm.dbg.declare(metadata i8* %b.addr, metadata !26, metadata !DIExpression()), !dbg !27
62   call void @llvm.dbg.declare(metadata %"struct.pr14763::foo"* %g, metadata !28, metadata !DIExpression(DW_OP_deref)), !dbg !27
63   %0 = load i8, i8* %b.addr, align 1, !dbg !29
64   %tobool = trunc i8 %0 to i1, !dbg !29
65   br i1 %tobool, label %if.then, label %if.end, !dbg !29
66
67 if.then:                                          ; preds = %entry
68   %1 = bitcast %"struct.pr14763::foo"* %g to i8*, !dbg !31
69   call void @_ZN7pr147634sinkEPv(i8* %1), !dbg !31
70   br label %if.end, !dbg !31
71
72 if.end:                                           ; preds = %if.then, %entry
73   ret void, !dbg !32
74 }
75
76 declare void @_ZN7pr147634sinkEPv(i8*) #2
77
78 attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
79 attributes #1 = { nounwind readnone }
80 attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
81
82 !llvm.dbg.cu = !{!0}
83 !llvm.module.flags = !{!21, !33}
84
85 !0 = !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.4 ", isOptimized: false, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
86 !1 = !DIFile(filename: "pass.cpp", directory: "/tmp")
87 !2 = !{}
88 !3 = !{!4, !17}
89 !4 = !DISubprogram(name: "func", linkageName: "_ZN7pr147634funcENS_3fooE", line: 6, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 6, file: !1, scope: !5, type: !6, function: void (%"struct.pr14763::foo"*, %"struct.pr14763::foo"*)* @_ZN7pr147634funcENS_3fooE, variables: !2)
90 !5 = !DINamespace(name: "pr14763", line: 1, file: !1, scope: null)
91 !6 = !DISubroutineType(types: !7)
92 !7 = !{!8, !8}
93 !8 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", line: 2, size: 8, align: 8, file: !1, scope: !5, elements: !9)
94 !9 = !{!10}
95 !10 = !DISubprogram(name: "foo", line: 3, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 3, file: !1, scope: !8, type: !11)
96 !11 = !DISubroutineType(types: !12)
97 !12 = !{null, !13, !14}
98 !13 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !8)
99 !14 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !15)
100 !15 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
101 !17 = !DISubprogram(name: "func2", linkageName: "_ZN7pr147635func2EbNS_3fooE", line: 12, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 12, file: !1, scope: !5, type: !18, function: void (i1, %"struct.pr14763::foo"*)* @_ZN7pr147635func2EbNS_3fooE, variables: !2)
102 !18 = !DISubroutineType(types: !19)
103 !19 = !{null, !20, !8}
104 !20 = !DIBasicType(tag: DW_TAG_base_type, name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)
105 !21 = !{i32 2, !"Dwarf Version", i32 3}
106 !22 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "f", line: 6, arg: 1, scope: !4, file: !23, type: !8)
107 !23 = !DIFile(filename: "pass.cpp", directory: "/tmp")
108 !24 = !DILocation(line: 6, scope: !4)
109 !25 = !DILocation(line: 7, scope: !4)
110 !26 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "b", line: 12, arg: 1, scope: !17, file: !23, type: !20)
111 !27 = !DILocation(line: 12, scope: !17)
112 !28 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "g", line: 12, arg: 2, scope: !17, file: !23, type: !8)
113 !29 = !DILocation(line: 13, scope: !30)
114 !30 = distinct !DILexicalBlock(line: 13, column: 0, file: !1, scope: !17)
115 !31 = !DILocation(line: 14, scope: !30)
116 !32 = !DILocation(line: 15, scope: !17)
117 !33 = !{i32 1, !"Debug Info Version", i32 3}