Make the default triple optional by allowing an empty string
[oota-llvm.git] / test / DebugInfo / Generic / inline-scopes.ll
1 ; REQUIRES: object-emission
2
3 ; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
4
5 ; bool f();
6 ; inline __attribute__((always_inline)) int f1() {
7 ;   if (bool b = f())
8 ;     return 1;
9 ;   return 2;
10 ; }
11 ;
12 ; inline __attribute__((always_inline)) int f2() {
13 ; # 2 "y.cc"
14 ;   if (bool b = f())
15 ;     return 3;
16 ;   return 4;
17 ; }
18 ;
19 ; int main() {
20 ;   f1();
21 ;   f2();
22 ; }
23
24 ; Ensure that lexical_blocks within inlined_subroutines are preserved/emitted.
25 ; CHECK: DW_TAG_inlined_subroutine
26 ; CHECK-NOT: DW_TAG
27 ; CHECK-NOT: NULL
28 ; CHECK: DW_TAG_lexical_block
29 ; CHECK-NOT: DW_TAG
30 ; CHECK-NOT: NULL
31 ; CHECK: DW_TAG_variable
32 ; Ensure that file changes don't interfere with creating inlined subroutines.
33 ; (see the line directive inside 'f2' in thesource)
34 ; CHECK: DW_TAG_inlined_subroutine
35 ; CHECK:   DW_TAG_variable
36 ; CHECK-NOT: DW_TAG
37 ; CHECK:     DW_AT_abstract_origin
38
39 ; Function Attrs: uwtable
40 define i32 @main() #0 {
41 entry:
42   %retval.i2 = alloca i32, align 4
43   %b.i3 = alloca i8, align 1
44   %retval.i = alloca i32, align 4
45   %b.i = alloca i8, align 1
46   call void @llvm.dbg.declare(metadata i8* %b.i, metadata !16, metadata !DIExpression()), !dbg !19
47   %call.i = call zeroext i1 @_Z1fv(), !dbg !19
48   %frombool.i = zext i1 %call.i to i8, !dbg !19
49   store i8 %frombool.i, i8* %b.i, align 1, !dbg !19
50   %0 = load i8, i8* %b.i, align 1, !dbg !19
51   %tobool.i = trunc i8 %0 to i1, !dbg !19
52   br i1 %tobool.i, label %if.then.i, label %if.end.i, !dbg !19
53
54 if.then.i:                                        ; preds = %entry
55   store i32 1, i32* %retval.i, !dbg !21
56   br label %_Z2f1v.exit, !dbg !21
57
58 if.end.i:                                         ; preds = %entry
59   store i32 2, i32* %retval.i, !dbg !22
60   br label %_Z2f1v.exit, !dbg !22
61
62 _Z2f1v.exit:                                      ; preds = %if.then.i, %if.end.i
63   %1 = load i32, i32* %retval.i, !dbg !23
64   call void @llvm.dbg.declare(metadata i8* %b.i3, metadata !24, metadata !DIExpression()), !dbg !27
65   %call.i4 = call zeroext i1 @_Z1fv(), !dbg !27
66   %frombool.i5 = zext i1 %call.i4 to i8, !dbg !27
67   store i8 %frombool.i5, i8* %b.i3, align 1, !dbg !27
68   %2 = load i8, i8* %b.i3, align 1, !dbg !27
69   %tobool.i6 = trunc i8 %2 to i1, !dbg !27
70   br i1 %tobool.i6, label %if.then.i7, label %if.end.i8, !dbg !27
71
72 if.then.i7:                                       ; preds = %_Z2f1v.exit
73   store i32 3, i32* %retval.i2, !dbg !29
74   br label %_Z2f2v.exit, !dbg !29
75
76 if.end.i8:                                        ; preds = %_Z2f1v.exit
77   store i32 4, i32* %retval.i2, !dbg !30
78   br label %_Z2f2v.exit, !dbg !30
79
80 _Z2f2v.exit:                                      ; preds = %if.then.i7, %if.end.i8
81   %3 = load i32, i32* %retval.i2, !dbg !31
82   ret i32 0, !dbg !32
83 }
84
85 ; Function Attrs: nounwind readnone
86 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
87
88 declare zeroext i1 @_Z1fv() #2
89
90 attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
91 attributes #1 = { nounwind readnone }
92 attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
93
94 !llvm.dbg.cu = !{!0}
95 !llvm.module.flags = !{!13, !14}
96 !llvm.ident = !{!15}
97
98 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
99 !1 = !DIFile(filename: "inline-scopes.cpp", directory: "/tmp/dbginfo")
100 !2 = !{}
101 !3 = !{!4, !10, !12}
102 !4 = distinct !DISubprogram(name: "main", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 7, file: !5, scope: !6, type: !7, function: i32 ()* @main, variables: !2)
103 !5 = !DIFile(filename: "y.cc", directory: "/tmp/dbginfo")
104 !6 = !DIFile(filename: "y.cc", directory: "/tmp/dbginfo")
105 !7 = !DISubroutineType(types: !8)
106 !8 = !{!9}
107 !9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
108 !10 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", line: 8, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 8, file: !1, scope: !11, type: !7, variables: !2)
109 !11 = !DIFile(filename: "inline-scopes.cpp", directory: "/tmp/dbginfo")
110 !12 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !1, scope: !11, type: !7, variables: !2)
111 !13 = !{i32 2, !"Dwarf Version", i32 4}
112 !14 = !{i32 1, !"Debug Info Version", i32 3}
113 !15 = !{!"clang version 3.5.0 "}
114 !16 = !DILocalVariable(name: "b", line: 3, scope: !17, file: !11, type: !18)
115 !17 = distinct !DILexicalBlock(line: 3, column: 0, file: !1, scope: !12)
116 !18 = !DIBasicType(tag: DW_TAG_base_type, name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)
117 !19 = !DILocation(line: 3, scope: !17, inlinedAt: !20)
118 !20 = !DILocation(line: 8, scope: !4)
119 !21 = !DILocation(line: 4, scope: !17, inlinedAt: !20)
120 !22 = !DILocation(line: 5, scope: !12, inlinedAt: !20)
121 !23 = !DILocation(line: 6, scope: !12, inlinedAt: !20)
122 !24 = !DILocalVariable(name: "b", line: 2, scope: !25, file: !6, type: !18)
123 !25 = distinct !DILexicalBlock(line: 2, column: 0, file: !5, scope: !26)
124 !26 = !DILexicalBlockFile(discriminator: 0, file: !5, scope: !10)
125 !27 = !DILocation(line: 2, scope: !25, inlinedAt: !28)
126 !28 = !DILocation(line: 9, scope: !4)
127 !29 = !DILocation(line: 3, scope: !25, inlinedAt: !28)
128 !30 = !DILocation(line: 4, scope: !26, inlinedAt: !28)
129 !31 = !DILocation(line: 5, scope: !26, inlinedAt: !28)
130 !32 = !DILocation(line: 10, scope: !4)