brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.2 KiB · c31c442 Raw
177 lines · plain
1; RUN: %llc_dwarf -mtriple x86_64-gnu-linux -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck %s2; Build from the following source with clang -O2.3 4; The important details are that 'x's abstract definition is first built during5; the definition of 'b', where the parameter to 'x' is constant and so 'x's 's'6; variable is optimized away. No abstract definition DIE for 's' is constructed.7; Then, during 'a' emission, the abstract DbgVariable for 's' is created, but8; the abstract DIE isn't (since the abstract definition for 'b' is already9; built). This results in 's' inlined in 'a' being emitted with its name, line,10; file there, rather than referencing an abstract definition.11 12; extern int t;13;14; void f(int);15;16; inline void x(bool b) {17;   if (b) {18;     int s = t;19;     f(s);20;   }21;   f(0);22; }23;24; void b() {25;   x(false);26; }27;28; void a(bool u) {29;   x(u);30; }31 32; CHECK: [[X_DECL:.*]]: DW_TAG_subprogram33; CHECK-NOT: DW_TAG34; CHECK:   DW_AT_name ("x")35; CHECK-NOT: {{DW_TAG|NULL}}36; CHECK:   DW_TAG_formal_parameter37; CHECK-NOT: DW_TAG38; CHECK:     DW_AT_name ("b")39; CHECK-NOT: {{DW_TAG|NULL}}40; CHECK:       [[LB_DECL:.*]]: DW_TAG_lexical_block41; CHECK-NOT: {{DW_TAG|NULL}}42; CHECK:   DW_TAG_variable43; CHECK-NOT: DW_TAG44; CHECK:         DW_AT_name ("s")45 46; CHECK: DW_TAG_subprogram47; CHECK-NOT: DW_TAG48; CHECK:   DW_AT_name ("b")49; CHECK-NOT: {{DW_TAG|NULL}}50; CHECK:   DW_TAG_inlined_subroutine51; CHECK-NOT: DW_TAG52; CHECK:     DW_AT_abstract_origin {{.*}}[[X_DECL]]53; CHECK-NOT: {{DW_TAG|NULL}}54; CHECK:     DW_TAG_formal_parameter55; CHECK-NOT: DW_TAG56; CHECK:       DW_AT_abstract_origin {{.*}} "b"57; Notice 'x's local variable 's' is missing. Not necessarily a bug here,58; since it's been optimized entirely away and it should be described in59; abstract subprogram.60; CHECK-NOT: DW_TAG61; CHECK: NULL62; CHECK-NOT: DW_TAG63; CHECK: NULL64 65; CHECK: DW_TAG_subprogram66; CHECK-NOT: DW_TAG67; CHECK:   DW_AT_name ("a")68; CHECK-NOT: {{DW_TAG|NULL}}69; CHECK:   DW_TAG_formal_parameter70; CHECK-NOT: {{DW_TAG|NULL}}71; CHECK:   DW_TAG_inlined_subroutine72; CHECK-NOT: DW_TAG73; CHECK:     DW_AT_abstract_origin {{.*}}[[X_DECL]]74; CHECK-NOT: {{DW_TAG|NULL}}75; FIXME: This formal parameter goes missing at least at -O2 (& on76; mips/powerpc), maybe before that. Perhaps SelectionDAG is to blame (and77; fastisel succeeds).78; CHECK:     DW_TAG_formal_parameter79; CHECK-NOT: DW_TAG80; CHECK:       DW_AT_location81; CHECK:       DW_AT_abstract_origin {{.*}} "b"82 83; CHECK-NOT: {{DW_TAG|NULL}}84; CHECK:     DW_TAG_lexical_block85; CHECK-NOT:   {{DW_TAG|NULL}}86; CHECK:       DW_AT_abstract_origin {{.*}}[[LB_DECL]]87; CHECK-NOT:   {{DW_TAG|NULL}}88; CHECK:       DW_TAG_variable89; CHECK-NOT: DW_TAG90; CHECK:         DW_AT_abstract_origin {{.*}} "s"91 92@t = external global i3293 94; Function Attrs: uwtable95define void @_Z1bv() #0 !dbg !4 {96entry:97  tail call void @llvm.dbg.value(metadata i1 false, metadata !25, metadata !DIExpression()), !dbg !2798  tail call void @_Z1fi(i32 0), !dbg !2899  ret void, !dbg !29100}101 102; Function Attrs: uwtable103define void @_Z1ab(i1 zeroext %u) #0 !dbg !8 {104entry:105  tail call void @llvm.dbg.value(metadata i1 %u, metadata !13, metadata !DIExpression()), !dbg !30106  tail call void @llvm.dbg.value(metadata i1 %u, metadata !31, metadata !DIExpression()), !dbg !33107  br i1 %u, label %if.then.i, label %_Z1xb.exit, !dbg !34108 109if.then.i:                                        ; preds = %entry110  %0 = load i32, ptr @t, align 4, !dbg !35, !tbaa !36111  tail call void @llvm.dbg.value(metadata i32 %0, metadata !40, metadata !DIExpression()), !dbg !35112  tail call void @_Z1fi(i32 %0), !dbg !41113  br label %_Z1xb.exit, !dbg !42114 115_Z1xb.exit:                                       ; preds = %entry, %if.then.i116  tail call void @_Z1fi(i32 0), !dbg !43117  ret void, !dbg !44118}119 120declare void @_Z1fi(i32) #1121 122; Function Attrs: nounwind readnone123declare void @llvm.dbg.value(metadata, metadata, metadata) #2124 125attributes #0 = { uwtable "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }126attributes #1 = { "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }127attributes #2 = { nounwind readnone }128 129!llvm.dbg.cu = !{!0}130!llvm.module.flags = !{!21, !22}131!llvm.ident = !{!23}132 133!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)134!1 = !DIFile(filename: "missing-abstract-variables.cc", directory: "/tmp/dbginfo")135!2 = !{}136!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)137!5 = !DIFile(filename: "missing-abstract-variables.cc", directory: "/tmp/dbginfo")138!6 = !DISubroutineType(types: !7)139!7 = !{null}140!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)141!9 = !DISubroutineType(types: !10)142!10 = !{null, !11}143!11 = !DIBasicType(tag: DW_TAG_base_type, name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)144!12 = !{!13}145!13 = !DILocalVariable(name: "u", line: 17, arg: 1, scope: !8, file: !5, type: !11)146!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)147!15 = !{!16, !17}148!16 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11)149!17 = !DILocalVariable(name: "s", line: 7, scope: !18, file: !5, type: !20)150!18 = distinct !DILexicalBlock(line: 6, column: 0, file: !1, scope: !19)151!19 = distinct !DILexicalBlock(line: 6, column: 0, file: !1, scope: !14)152!20 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)153!21 = !{i32 2, !"Dwarf Version", i32 4}154!22 = !{i32 2, !"Debug Info Version", i32 3}155!23 = !{!"clang version 3.5.0 "}156!24 = !{i1 false}157!25 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11)158!26 = !DILocation(line: 14, scope: !4)159!27 = !DILocation(line: 5, scope: !14, inlinedAt: !26)160!28 = !DILocation(line: 10, scope: !14, inlinedAt: !26)161!29 = !DILocation(line: 15, scope: !4)162!30 = !DILocation(line: 17, scope: !8)163!31 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11)164!32 = !DILocation(line: 18, scope: !8)165!33 = !DILocation(line: 5, scope: !14, inlinedAt: !32)166!34 = !DILocation(line: 6, scope: !19, inlinedAt: !32)167!35 = !DILocation(line: 7, scope: !18, inlinedAt: !32)168!36 = !{!37, !37, i64 0}169!37 = !{!"int", !38, i64 0}170!38 = !{!"omnipotent char", !39, i64 0}171!39 = !{!"Simple C/C++ TBAA"}172!40 = !DILocalVariable(name: "s", line: 7, scope: !18, file: !5, type: !20)173!41 = !DILocation(line: 8, scope: !18, inlinedAt: !32)174!42 = !DILocation(line: 9, scope: !18, inlinedAt: !32)175!43 = !DILocation(line: 10, scope: !14, inlinedAt: !32)176!44 = !DILocation(line: 19, scope: !8)177