1247dedeaSTom Stellard; RUN: %llc_dwarf -mtriple x86_64-gnu-linux -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck %s 2*10b03e66SOrlando Cazalet-Hyams; RUN: %llc_dwarf --try-experimental-debuginfo-iterators -mtriple x86_64-gnu-linux -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck %s 3247dedeaSTom Stellard; Build from the following source with clang -O2. 4247dedeaSTom Stellard 5247dedeaSTom Stellard; The important details are that 'x's abstract definition is first built during 6247dedeaSTom Stellard; the definition of 'b', where the parameter to 'x' is constant and so 'x's 's' 7247dedeaSTom Stellard; variable is optimized away. No abstract definition DIE for 's' is constructed. 8247dedeaSTom Stellard; Then, during 'a' emission, the abstract DbgVariable for 's' is created, but 9247dedeaSTom Stellard; the abstract DIE isn't (since the abstract definition for 'b' is already 10247dedeaSTom Stellard; built). This results in 's' inlined in 'a' being emitted with its name, line, 11247dedeaSTom Stellard; file there, rather than referencing an abstract definition. 12247dedeaSTom Stellard 13247dedeaSTom Stellard; extern int t; 14247dedeaSTom Stellard; 15247dedeaSTom Stellard; void f(int); 16247dedeaSTom Stellard; 17247dedeaSTom Stellard; inline void x(bool b) { 18247dedeaSTom Stellard; if (b) { 19247dedeaSTom Stellard; int s = t; 20247dedeaSTom Stellard; f(s); 21247dedeaSTom Stellard; } 22247dedeaSTom Stellard; f(0); 23247dedeaSTom Stellard; } 24247dedeaSTom Stellard; 25247dedeaSTom Stellard; void b() { 26247dedeaSTom Stellard; x(false); 27247dedeaSTom Stellard; } 28247dedeaSTom Stellard; 29247dedeaSTom Stellard; void a(bool u) { 30247dedeaSTom Stellard; x(u); 31247dedeaSTom Stellard; } 32247dedeaSTom Stellard 33247dedeaSTom Stellard; CHECK: [[X_DECL:.*]]: DW_TAG_subprogram 34247dedeaSTom Stellard; CHECK-NOT: DW_TAG 35247dedeaSTom Stellard; CHECK: DW_AT_name ("x") 36247dedeaSTom Stellard; CHECK-NOT: {{DW_TAG|NULL}} 37247dedeaSTom Stellard; CHECK: DW_TAG_formal_parameter 38247dedeaSTom Stellard; CHECK-NOT: DW_TAG 39247dedeaSTom Stellard; CHECK: DW_AT_name ("b") 40247dedeaSTom Stellard; CHECK-NOT: {{DW_TAG|NULL}} 41247dedeaSTom Stellard; CHECK: DW_TAG_lexical_block 42247dedeaSTom Stellard; CHECK-NOT: {{DW_TAG|NULL}} 43247dedeaSTom Stellard; CHECK: DW_TAG_variable 44247dedeaSTom Stellard; CHECK-NOT: DW_TAG 45247dedeaSTom Stellard; CHECK: DW_AT_name ("s") 46247dedeaSTom Stellard 47247dedeaSTom Stellard; CHECK: DW_TAG_subprogram 48247dedeaSTom Stellard; CHECK-NOT: DW_TAG 49247dedeaSTom Stellard; CHECK: DW_AT_name ("b") 50247dedeaSTom Stellard; CHECK-NOT: {{DW_TAG|NULL}} 51247dedeaSTom Stellard; CHECK: DW_TAG_inlined_subroutine 52247dedeaSTom Stellard; CHECK-NOT: DW_TAG 53247dedeaSTom Stellard; CHECK: DW_AT_abstract_origin {{.*}}[[X_DECL]] 54247dedeaSTom Stellard; CHECK-NOT: {{DW_TAG|NULL}} 55247dedeaSTom Stellard; CHECK: DW_TAG_formal_parameter 56247dedeaSTom Stellard; CHECK-NOT: DW_TAG 57247dedeaSTom Stellard; CHECK: DW_AT_abstract_origin {{.*}} "b" 58247dedeaSTom Stellard; Notice 'x's local variable 's' is missing. Not necessarily a bug here, 59247dedeaSTom Stellard; since it's been optimized entirely away and it should be described in 60247dedeaSTom Stellard; abstract subprogram. 61247dedeaSTom Stellard; CHECK-NOT: DW_TAG 62247dedeaSTom Stellard; CHECK: NULL 63247dedeaSTom Stellard; CHECK-NOT: DW_TAG 64247dedeaSTom Stellard; CHECK: NULL 65247dedeaSTom Stellard 66247dedeaSTom Stellard; CHECK: DW_TAG_subprogram 67247dedeaSTom Stellard; CHECK-NOT: DW_TAG 68247dedeaSTom Stellard; CHECK: DW_AT_name ("a") 69247dedeaSTom Stellard; CHECK-NOT: {{DW_TAG|NULL}} 70247dedeaSTom Stellard; CHECK: DW_TAG_formal_parameter 71247dedeaSTom Stellard; CHECK-NOT: {{DW_TAG|NULL}} 72247dedeaSTom Stellard; CHECK: DW_TAG_inlined_subroutine 73247dedeaSTom Stellard; CHECK-NOT: DW_TAG 74247dedeaSTom Stellard; CHECK: DW_AT_abstract_origin {{.*}}[[X_DECL]] 75247dedeaSTom Stellard; CHECK-NOT: {{DW_TAG|NULL}} 76247dedeaSTom Stellard; FIXME: This formal parameter goes missing at least at -O2 (& on 77247dedeaSTom Stellard; mips/powerpc), maybe before that. Perhaps SelectionDAG is to blame (and 78247dedeaSTom Stellard; fastisel succeeds). 79247dedeaSTom Stellard; CHECK: DW_TAG_formal_parameter 80247dedeaSTom Stellard; CHECK-NOT: DW_TAG 81247dedeaSTom Stellard; CHECK: DW_AT_location 82247dedeaSTom Stellard; CHECK: DW_AT_abstract_origin {{.*}} "b" 83247dedeaSTom Stellard 84247dedeaSTom Stellard; CHECK-NOT: {{DW_TAG|NULL}} 85247dedeaSTom Stellard; CHECK: DW_TAG_lexical_block 86247dedeaSTom Stellard; CHECK-NOT: {{DW_TAG|NULL}} 87247dedeaSTom Stellard; CHECK: DW_TAG_variable 88247dedeaSTom Stellard; CHECK-NOT: DW_TAG 89247dedeaSTom Stellard; CHECK: DW_AT_abstract_origin {{.*}} "s" 90247dedeaSTom Stellard 91247dedeaSTom Stellard@t = external global i32 92247dedeaSTom Stellard 93247dedeaSTom Stellard; Function Attrs: uwtable 94247dedeaSTom Stellarddefine void @_Z1bv() #0 !dbg !4 { 95247dedeaSTom Stellardentry: 96247dedeaSTom Stellard tail call void @llvm.dbg.value(metadata i1 false, metadata !25, metadata !DIExpression()), !dbg !27 97247dedeaSTom Stellard tail call void @_Z1fi(i32 0), !dbg !28 98247dedeaSTom Stellard ret void, !dbg !29 99247dedeaSTom Stellard} 100247dedeaSTom Stellard 101247dedeaSTom Stellard; Function Attrs: uwtable 102247dedeaSTom Stellarddefine void @_Z1ab(i1 zeroext %u) #0 !dbg !8 { 103247dedeaSTom Stellardentry: 104247dedeaSTom Stellard tail call void @llvm.dbg.value(metadata i1 %u, metadata !13, metadata !DIExpression()), !dbg !30 105247dedeaSTom Stellard tail call void @llvm.dbg.value(metadata i1 %u, metadata !31, metadata !DIExpression()), !dbg !33 106247dedeaSTom Stellard br i1 %u, label %if.then.i, label %_Z1xb.exit, !dbg !34 107247dedeaSTom Stellard 108247dedeaSTom Stellardif.then.i: ; preds = %entry 1095a288fa3SNikita Popov %0 = load i32, ptr @t, align 4, !dbg !35, !tbaa !36 110247dedeaSTom Stellard tail call void @llvm.dbg.value(metadata i32 %0, metadata !40, metadata !DIExpression()), !dbg !35 111247dedeaSTom Stellard tail call void @_Z1fi(i32 %0), !dbg !41 112247dedeaSTom Stellard br label %_Z1xb.exit, !dbg !42 113247dedeaSTom Stellard 114247dedeaSTom Stellard_Z1xb.exit: ; preds = %entry, %if.then.i 115247dedeaSTom Stellard tail call void @_Z1fi(i32 0), !dbg !43 116247dedeaSTom Stellard ret void, !dbg !44 117247dedeaSTom Stellard} 118247dedeaSTom Stellard 119247dedeaSTom Stellarddeclare void @_Z1fi(i32) #1 120247dedeaSTom Stellard 121247dedeaSTom Stellard; Function Attrs: nounwind readnone 122247dedeaSTom Stellarddeclare void @llvm.dbg.value(metadata, metadata, metadata) #2 123247dedeaSTom Stellard 124247dedeaSTom Stellardattributes #0 = { uwtable "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 125247dedeaSTom Stellardattributes #1 = { "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 126247dedeaSTom Stellardattributes #2 = { nounwind readnone } 127247dedeaSTom Stellard 128247dedeaSTom Stellard!llvm.dbg.cu = !{!0} 129247dedeaSTom Stellard!llvm.module.flags = !{!21, !22} 130247dedeaSTom Stellard!llvm.ident = !{!23} 131247dedeaSTom Stellard 132247dedeaSTom Stellard!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) 133247dedeaSTom Stellard!1 = !DIFile(filename: "missing-abstract-variables.cc", directory: "/tmp/dbginfo") 134247dedeaSTom Stellard!2 = !{} 135247dedeaSTom Stellard!4 = distinct !DISubprogram(name: "b", linkageName: "_Z1bv", line: 13, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 13, file: !1, scope: !5, type: !6, retainedNodes: !2) 136247dedeaSTom Stellard!5 = !DIFile(filename: "missing-abstract-variables.cc", directory: "/tmp/dbginfo") 137247dedeaSTom Stellard!6 = !DISubroutineType(types: !7) 138247dedeaSTom Stellard!7 = !{null} 139247dedeaSTom Stellard!8 = distinct !DISubprogram(name: "a", linkageName: "_Z1ab", line: 17, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 17, file: !1, scope: !5, type: !9, retainedNodes: !12) 140247dedeaSTom Stellard!9 = !DISubroutineType(types: !10) 141247dedeaSTom Stellard!10 = !{null, !11} 142247dedeaSTom Stellard!11 = !DIBasicType(tag: DW_TAG_base_type, name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean) 143247dedeaSTom Stellard!12 = !{!13} 144247dedeaSTom Stellard!13 = !DILocalVariable(name: "u", line: 17, arg: 1, scope: !8, file: !5, type: !11) 145247dedeaSTom Stellard!14 = distinct !DISubprogram(name: "x", linkageName: "_Z1xb", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 5, file: !1, scope: !5, type: !9, retainedNodes: !15) 146247dedeaSTom Stellard!15 = !{!16, !17} 147247dedeaSTom Stellard!16 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11) 148247dedeaSTom Stellard!17 = !DILocalVariable(name: "s", line: 7, scope: !18, file: !5, type: !20) 149247dedeaSTom Stellard!18 = distinct !DILexicalBlock(line: 6, column: 0, file: !1, scope: !19) 150247dedeaSTom Stellard!19 = distinct !DILexicalBlock(line: 6, column: 0, file: !1, scope: !14) 151247dedeaSTom Stellard!20 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 152247dedeaSTom Stellard!21 = !{i32 2, !"Dwarf Version", i32 4} 153247dedeaSTom Stellard!22 = !{i32 2, !"Debug Info Version", i32 3} 154247dedeaSTom Stellard!23 = !{!"clang version 3.5.0 "} 155247dedeaSTom Stellard!24 = !{i1 false} 156247dedeaSTom Stellard!25 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11) 157247dedeaSTom Stellard!26 = !DILocation(line: 14, scope: !4) 158247dedeaSTom Stellard!27 = !DILocation(line: 5, scope: !14, inlinedAt: !26) 159247dedeaSTom Stellard!28 = !DILocation(line: 10, scope: !14, inlinedAt: !26) 160247dedeaSTom Stellard!29 = !DILocation(line: 15, scope: !4) 161247dedeaSTom Stellard!30 = !DILocation(line: 17, scope: !8) 162247dedeaSTom Stellard!31 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11) 163247dedeaSTom Stellard!32 = !DILocation(line: 18, scope: !8) 164247dedeaSTom Stellard!33 = !DILocation(line: 5, scope: !14, inlinedAt: !32) 165247dedeaSTom Stellard!34 = !DILocation(line: 6, scope: !19, inlinedAt: !32) 166247dedeaSTom Stellard!35 = !DILocation(line: 7, scope: !18, inlinedAt: !32) 167247dedeaSTom Stellard!36 = !{!37, !37, i64 0} 168247dedeaSTom Stellard!37 = !{!"int", !38, i64 0} 169247dedeaSTom Stellard!38 = !{!"omnipotent char", !39, i64 0} 170247dedeaSTom Stellard!39 = !{!"Simple C/C++ TBAA"} 171247dedeaSTom Stellard!40 = !DILocalVariable(name: "s", line: 7, scope: !18, file: !5, type: !20) 172247dedeaSTom Stellard!41 = !DILocation(line: 8, scope: !18, inlinedAt: !32) 173247dedeaSTom Stellard!42 = !DILocation(line: 9, scope: !18, inlinedAt: !32) 174247dedeaSTom Stellard!43 = !DILocation(line: 10, scope: !14, inlinedAt: !32) 175247dedeaSTom Stellard!44 = !DILocation(line: 19, scope: !8) 176