161 lines · plain
1; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -v -debug-info - | FileCheck %s2 3;; This test checks that Inlined DILexicalBlockFile with local decl entry4;; is skipped and only one DW_TAG_lexical_block is generated.5;; This test is special because it contains DILexicalBlockFile that has a6;; DILexicalBlockFile as a parent scope.7;;8;; This test was generated by running following command:9;; clang -cc1 -O0 -debug-info-kind=limited -dwarf-version=4 -emit-llvm test.cpp10;; Where test.cpp11;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;12;;namespace N {}13;; __attribute__((always_inline)) int bar() {14;; {15;; int y;16;;#line 1 "test.h"17;; using namespace N;18;; while (y < 0) return 2;19;; return 0;20;; }21;;}22;;int foo() { 23;; return bar();24;;}25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;26 27;; Concrete "bar" function28; CHECK: DW_TAG_subprogram29; CHECK-NOT: {{DW_TAG|NULL}}30; CHECK: DW_AT_abstract_origin {{.*}} {[[Offset_bar:0x[0-9abcdef]+]]}31; CHECK-NOT: {{DW_TAG|NULL}}32; CHECK: DW_TAG_lexical_block33; CHECK-NOT: {{DW_TAG|NULL}}34; CHECK: DW_AT_abstract_origin {{.*}}[[Offset_lb:0x[0-9a-f]+]]35; CHECK-NOT: {{DW_TAG|NULL}}36; CHECK: DW_TAG_variable37 38;; Abstract "bar" function39; CHECK: [[Offset_bar]]: DW_TAG_subprogram40; CHECK-NOT: {{DW_TAG|NULL}}41; CHECK: DW_AT_name {{.*}} "bar"42; CHECK-NOT: {{DW_TAG|NULL}}43; CHECK: DW_AT_inline44; CHECK-NOT: {{DW_TAG|NULL}}45; CHECK: [[Offset_lb]]: DW_TAG_lexical_block46; CHECK-NOT: {{DW_TAG|NULL}}47; CHECK: DW_TAG_variable48; CHECK-NOT: {{DW_TAG|NULL}}49; CHECK: DW_TAG_imported_module50 51; CHECK: DW_TAG_subprogram52; CHECK-NOT: {{DW_TAG|NULL}}53; CHECK: DW_AT_name {{.*}} "foo"54; CHECK-NOT: {{NULL}}55 56;; Inlined "bar" function57; CHECK: DW_TAG_inlined_subroutine58; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]}59; CHECK-NOT: {{DW_TAG|NULL}}60; CHECK: DW_TAG_lexical_block61; CHECK-NOT: {{DW_TAG|NULL}}62; CHECK: DW_AT_abstract_origin {{.*}}[[Offset_lb]]63; CHECK-NOT: {{DW_TAG|NULL}}64; CHECK: DW_TAG_variable65 66; Function Attrs: alwaysinline nounwind67define i32 @_Z3barv() #0 !dbg !4 {68entry:69 %retval = alloca i32, align 470 %y = alloca i32, align 471 call void @llvm.dbg.declare(metadata ptr %y, metadata !18, metadata !19), !dbg !2072 br label %while.cond, !dbg !2173 74while.cond: ; preds = %entry75 %0 = load i32, ptr %y, align 4, !dbg !2276 %cmp = icmp slt i32 %0, 0, !dbg !2277 br i1 %cmp, label %while.body, label %while.end, !dbg !2278 79while.body: ; preds = %while.cond80 store i32 2, ptr %retval, align 4, !dbg !2481 br label %return, !dbg !2482 83while.end: ; preds = %while.cond84 store i32 0, ptr %retval, align 4, !dbg !2685 br label %return, !dbg !2686 87return: ; preds = %while.end, %while.body88 %1 = load i32, ptr %retval, align 4, !dbg !2789 ret i32 %1, !dbg !2790}91 92; Function Attrs: nounwind readnone93declare void @llvm.dbg.declare(metadata, metadata, metadata) #194 95; Function Attrs: nounwind96define i32 @_Z3foov() #2 !dbg !8 {97entry:98 %retval.i = alloca i32, align 499 %y.i = alloca i32, align 4100 call void @llvm.dbg.declare(metadata ptr %y.i, metadata !18, metadata !19), !dbg !29101 %0 = load i32, ptr %y.i, align 4, !dbg !31102 %cmp.i = icmp slt i32 %0, 0, !dbg !31103 br i1 %cmp.i, label %while.body.i, label %while.end.i, !dbg !31104 105while.body.i: ; preds = %entry106 store i32 2, ptr %retval.i, align 4, !dbg !32107 br label %_Z3barv.exit, !dbg !32108 109while.end.i: ; preds = %entry110 store i32 0, ptr %retval.i, align 4, !dbg !33111 br label %_Z3barv.exit, !dbg !33112 113_Z3barv.exit: ; preds = %while.end.i, %while.body.i114 %1 = load i32, ptr %retval.i, align 4, !dbg !34115 ret i32 %1, !dbg !35116}117 118attributes #0 = { alwaysinline nounwind }119attributes #1 = { nounwind readnone }120attributes #2 = { nounwind }121 122!llvm.dbg.cu = !{!0}123!llvm.module.flags = !{!15, !16}124!llvm.ident = !{!17}125 126!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 264349)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2)127!1 = !DIFile(filename: "test.cpp", directory: "/")128!2 = !{}129!4 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !1, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !10)130!5 = !DISubroutineType(types: !6)131!6 = !{!7}132!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)133!8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !9, file: !9, line: 6, type: !5, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)134!9 = !DIFile(filename: "test.h", directory: "/")135!10 = !{!11}136!11 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !12, entity: !14, file: !1, line: 1)137!12 = !DILexicalBlockFile(scope: !13, file: !9, discriminator: 0)138!13 = distinct !DILexicalBlock(scope: !4, file: !1, line: 3)139!14 = !DINamespace(name: "N", scope: null)140!15 = !{i32 2, !"Dwarf Version", i32 4}141!16 = !{i32 2, !"Debug Info Version", i32 3}142!17 = !{!"clang version 3.9.0 (trunk 264349)"}143!18 = !DILocalVariable(name: "y", scope: !13, file: !1, line: 4, type: !7)144!19 = !DIExpression()145!20 = !DILocation(line: 4, scope: !13)146!21 = !DILocation(line: 2, scope: !12)147!22 = !DILocation(line: 2, scope: !23)148!23 = !DILexicalBlockFile(scope: !12, file: !9, discriminator: 1)149!24 = !DILocation(line: 2, scope: !25)150!25 = !DILexicalBlockFile(scope: !12, file: !9, discriminator: 2)151!26 = !DILocation(line: 3, scope: !12)152!27 = !DILocation(line: 5, scope: !28)153!28 = !DILexicalBlockFile(scope: !4, file: !9, discriminator: 0)154!29 = !DILocation(line: 4, scope: !13, inlinedAt: !30)155!30 = distinct !DILocation(line: 7, scope: !8)156!31 = !DILocation(line: 2, scope: !23, inlinedAt: !30)157!32 = !DILocation(line: 2, scope: !25, inlinedAt: !30)158!33 = !DILocation(line: 3, scope: !12, inlinedAt: !30)159!34 = !DILocation(line: 5, scope: !28, inlinedAt: !30)160!35 = !DILocation(line: 7, scope: !8)161