Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 40b623b

Browse files
committed
Debug Info: Allow a DIModule to appear as the scope of other entities.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247304 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 8b25542 commit 40b623b

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

lib/CodeGen/AsmPrinter/DwarfUnit.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ DIE *DwarfUnit::getOrCreateContextDIE(const DIScope *Context) {
693693
return getOrCreateNameSpace(NS);
694694
if (auto *SP = dyn_cast<DISubprogram>(Context))
695695
return getOrCreateSubprogramDIE(SP);
696+
if (auto *M = dyn_cast<DIModule>(Context))
697+
return getOrCreateModule(M);
696698
return getDIE(Context);
697699
}
698700

test/DebugInfo/X86/DIModuleContext.ll

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
target triple = "x86_64-apple-macosx"
2+
; RUN: %llc_dwarf %s -o - -filetype=obj \
3+
; RUN: | llvm-dwarfdump -debug-dump=info - | FileCheck %s
4+
; CHECK: DW_TAG_module
5+
; CHECK-NOT: NULL
6+
; CHECK: DW_TAG_structure_type
7+
8+
; Hand-crafted based on
9+
; struct s;
10+
; struct s *s;
11+
12+
%struct.s = type opaque
13+
14+
@i = common global %struct.s* null, align 8
15+
16+
!llvm.dbg.cu = !{!0}
17+
!llvm.module.flags = !{!7, !8}
18+
19+
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, globals: !3, imports: !11)
20+
!1 = !DIFile(filename: "test.c", directory: "/")
21+
!2 = !{}
22+
!3 = !{!4}
23+
!4 = !DIGlobalVariable(name: "s", scope: !0, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, variable: %struct.s** @i)
24+
!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64, align: 64)
25+
!6 = !DICompositeType(tag: DW_TAG_structure_type, name: "s", scope: !9, file: !1, line: 1, flags: DIFlagFwdDecl)
26+
!7 = !{i32 2, !"Dwarf Version", i32 2}
27+
!8 = !{i32 2, !"Debug Info Version", i32 3}
28+
!9 = !DIModule(scope: null, name: "Module", configMacros: "", includePath: ".", isysroot: "/")
29+
!10 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !9, line: 11)
30+
!11 = !{!10}

0 commit comments

Comments
 (0)