blob: 46e08bcc2dd4d3d5fa55f65e41036d4c5ed1ebc5 [file] [log] [blame]
David Blaikie9b8c8cd2014-05-14 01:08:28 +00001; 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
David Blaikieea862262014-05-25 18:11:35 +000035; CHECK: DW_TAG_variable
36; CHECK-NOT: DW_TAG
37; CHECK: DW_AT_abstract_origin
David Blaikie9b8c8cd2014-05-14 01:08:28 +000038
39; Function Attrs: uwtable
40define i32 @main() #0 {
41entry:
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
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000046 call void @llvm.dbg.declare(metadata i8* %b.i, metadata !16, metadata !DIExpression()), !dbg !19
David Blaikie9b8c8cd2014-05-14 01:08:28 +000047 %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
David Blaikiea79ac142015-02-27 21:17:42 +000050 %0 = load i8, i8* %b.i, align 1, !dbg !19
David Blaikie9b8c8cd2014-05-14 01:08:28 +000051 %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
54if.then.i: ; preds = %entry
55 store i32 1, i32* %retval.i, !dbg !21
56 br label %_Z2f1v.exit, !dbg !21
57
58if.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
David Blaikiea79ac142015-02-27 21:17:42 +000063 %1 = load i32, i32* %retval.i, !dbg !23
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000064 call void @llvm.dbg.declare(metadata i8* %b.i3, metadata !24, metadata !DIExpression()), !dbg !27
David Blaikie9b8c8cd2014-05-14 01:08:28 +000065 %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
David Blaikiea79ac142015-02-27 21:17:42 +000068 %2 = load i8, i8* %b.i3, align 1, !dbg !27
David Blaikie9b8c8cd2014-05-14 01:08:28 +000069 %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
72if.then.i7: ; preds = %_Z2f1v.exit
73 store i32 3, i32* %retval.i2, !dbg !29
74 br label %_Z2f2v.exit, !dbg !29
75
76if.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
David Blaikiea79ac142015-02-27 21:17:42 +000081 %3 = load i32, i32* %retval.i2, !dbg !31
David Blaikie9b8c8cd2014-05-14 01:08:28 +000082 ret i32 0, !dbg !32
83}
84
85; Function Attrs: nounwind readnone
Adrian Prantl87b7eb92014-10-01 18:55:02 +000086declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
David Blaikie9b8c8cd2014-05-14 01:08:28 +000087
88declare zeroext i1 @_Z1fv() #2
89
90attributes #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" }
91attributes #1 = { nounwind readnone }
92attributes #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
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000098!0 = !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")
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000100!2 = !{}
101!3 = !{!4, !10, !12}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000102!4 = !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)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000106!8 = !{!9}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000107!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
108!10 = !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 = !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)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000111!13 = !{i32 2, !"Dwarf Version", i32 4}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000112!14 = !{i32 1, !"Debug Info Version", i32 3}
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000113!15 = !{!"clang version 3.5.0 "}
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000114!16 = !DILocalVariable(name: "b", line: 3, scope: !17, file: !11, type: !18)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000115!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)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000122!24 = !DILocalVariable(name: "b", line: 2, scope: !25, file: !6, type: !18)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000123!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)