summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-09-10 17:13:58 +0000
committerAdrian Prantl <aprantl@apple.com>2015-09-10 17:13:58 +0000
commitd209500fd5ef7defaccf91b2cc544eafe595c53f (patch)
tree6a32a8568ae7884bf0345edbd00ef951bb2cff74
parent54a3457fe1e2e50dedd5c576bb8bc2012e83e8e8 (diff)
downloadbcm5719-llvm-d209500fd5ef7defaccf91b2cc544eafe595c53f.tar.gz
bcm5719-llvm-d209500fd5ef7defaccf91b2cc544eafe595c53f.zip
Debug Info: Allow a DIModule to appear as the scope of other entities.
llvm-svn: 247304
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp2
-rw-r--r--llvm/test/DebugInfo/X86/DIModuleContext.ll30
2 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index d3e0b8b798c..3a89c809da3 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -693,6 +693,8 @@ DIE *DwarfUnit::getOrCreateContextDIE(const DIScope *Context) {
return getOrCreateNameSpace(NS);
if (auto *SP = dyn_cast<DISubprogram>(Context))
return getOrCreateSubprogramDIE(SP);
+ if (auto *M = dyn_cast<DIModule>(Context))
+ return getOrCreateModule(M);
return getDIE(Context);
}
diff --git a/llvm/test/DebugInfo/X86/DIModuleContext.ll b/llvm/test/DebugInfo/X86/DIModuleContext.ll
new file mode 100644
index 00000000000..413b45c4ab4
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/DIModuleContext.ll
@@ -0,0 +1,30 @@
+target triple = "x86_64-apple-macosx"
+; RUN: %llc_dwarf %s -o - -filetype=obj \
+; RUN: | llvm-dwarfdump -debug-dump=info - | FileCheck %s
+; CHECK: DW_TAG_module
+; CHECK-NOT: NULL
+; CHECK: DW_TAG_structure_type
+
+; Hand-crafted based on
+; struct s;
+; struct s *s;
+
+%struct.s = type opaque
+
+@i = common global %struct.s* null, align 8
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!7, !8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, globals: !3, imports: !11)
+!1 = !DIFile(filename: "test.c", directory: "/")
+!2 = !{}
+!3 = !{!4}
+!4 = !DIGlobalVariable(name: "s", scope: !0, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, variable: %struct.s** @i)
+!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64, align: 64)
+!6 = !DICompositeType(tag: DW_TAG_structure_type, name: "s", scope: !9, file: !1, line: 1, flags: DIFlagFwdDecl)
+!7 = !{i32 2, !"Dwarf Version", i32 2}
+!8 = !{i32 2, !"Debug Info Version", i32 3}
+!9 = !DIModule(scope: null, name: "Module", configMacros: "", includePath: ".", isysroot: "/")
+!10 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !9, line: 11)
+!11 = !{!10}
OpenPOWER on IntegriCloud