llvm.org GIT mirror llvm / 85cd16c
Debug info: Add dwarf backend support for DIModule. rdar://problem/20965932 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241034 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 4 years ago
6 changed file(s) with 60 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
238238 DW_AT_GNU_pubnames = 0x2134,
239239 DW_AT_GNU_pubtypes = 0x2135,
240240
241 // LLVM project extensions.
242 DW_AT_LLVM_include_path = 0x3e00,
243 DW_AT_LLVM_config_macros = 0x3e01,
244 DW_AT_LLVM_isysroot = 0x3e02,
245
241246 // Apple extensions.
242247 DW_AT_APPLE_optimized = 0x3fe1,
243248 DW_AT_APPLE_flags = 0x3fe2,
637637 auto *Entity = resolve(Module->getEntity());
638638 if (auto *NS = dyn_cast(Entity))
639639 EntityDie = getOrCreateNameSpace(NS);
640 else if (auto *M = dyn_cast(Entity))
641 EntityDie = getOrCreateModule(M);
640642 else if (auto *SP = dyn_cast(Entity))
641643 EntityDie = getOrCreateSubprogramDIE(SP);
642644 else if (auto *T = dyn_cast(Entity))
10681068 return &NDie;
10691069 }
10701070
1071 DIE *DwarfUnit::getOrCreateModule(const DIModule *M) {
1072 // Construct the context before querying for the existence of the DIE in case
1073 // such construction creates the DIE.
1074 DIE *ContextDIE = getOrCreateContextDIE(M->getScope());
1075
1076 if (DIE *MDie = getDIE(M))
1077 return MDie;
1078 DIE &MDie = createAndAddDIE(dwarf::DW_TAG_module, *ContextDIE, M);
1079
1080 if (!M->getName().empty()) {
1081 addString(MDie, dwarf::DW_AT_name, M->getName());
1082 addGlobalName(M->getName(), MDie, M->getScope());
1083 }
1084 if (!M->getConfigurationMacros().empty())
1085 addString(MDie, dwarf::DW_AT_LLVM_config_macros,
1086 M->getConfigurationMacros());
1087 if (!M->getIncludePath().empty())
1088 addString(MDie, dwarf::DW_AT_LLVM_include_path, M->getIncludePath());
1089 if (!M->getISysRoot().empty())
1090 addString(MDie, dwarf::DW_AT_LLVM_isysroot, M->getISysRoot());
1091
1092 return &MDie;
1093 }
1094
10711095 DIE *DwarfUnit::getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal) {
10721096 // Construct the context before querying for the existence of the DIE in case
10731097 // such construction creates the DIE (as is the case for member function
290290 dwarf::Attribute Attribute = dwarf::DW_AT_type);
291291
292292 DIE *getOrCreateNameSpace(const DINamespace *NS);
293 DIE *getOrCreateModule(const DIModule *M);
293294 DIE *getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal = false);
294295
295296 void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie,
189189 case DW_AT_APPLE_property_attribute: return "DW_AT_APPLE_property_attribute";
190190 case DW_AT_APPLE_property: return "DW_AT_APPLE_property";
191191 case DW_AT_APPLE_objc_complete_type: return "DW_AT_APPLE_objc_complete_type";
192 case DW_AT_LLVM_include_path: return "DW_AT_LLVM_include_path";
193 case DW_AT_LLVM_config_macros: return "DW_AT_LLVM_config_macros";
194 case DW_AT_LLVM_isysroot: return "DW_AT_LLVM_isysroot";
192195
193196 // DWARF5 Fission Extension Attribute
194197 case DW_AT_GNU_dwo_name: return "DW_AT_GNU_dwo_name";
0 ; ModuleID = '/Volumes/Data/apple-internal/llvm/tools/clang/test/Modules/debug-info-moduleimport.m'
1 ; RUN: llc %s -o %t -filetype=obj
2 ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
3 ; CHECK: DW_TAG_module
4 ; CHECK-NEXT: DW_AT_name {{.*}}"DebugModule"
5 ; CHECK-NEXT: DW_AT_LLVM_config_macros {{.*}}"-DMODULES=0"
6 ; CHECK-NEXT: DW_AT_LLVM_include_path {{.*}}"/llvm/tools/clang/test/Modules/Inputs"
7 ; CHECK-NEXT: DW_AT_LLVM_isysroot {{.*}}"/"
8
9 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
10 target triple = "x86_64-apple-macosx"
11
12 !llvm.dbg.cu = !{!0}
13 !llvm.module.flags = !{!6, !7}
14 !llvm.ident = !{!8}
15
16 !0 = distinct !DICompileUnit(language: DW_LANG_ObjC, file: !1, producer: "LLVM version 3.7.0", isOptimized: false, runtimeVersion: 2, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !2, globals: !2, imports: !3)
17 !1 = !DIFile(filename: "/llvm/tools/clang/test/Modules/", directory: "/")
18 !2 = !{}
19 !3 = !{!4}
20 !4 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !5, line: 5)
21 !5 = !DIModule(scope: null, name: "DebugModule", configMacros: "-DMODULES=0", includePath: "/llvm/tools/clang/test/Modules/Inputs", isysroot: "/")
22 !6 = !{i32 2, !"Dwarf Version", i32 4}
23 !7 = !{i32 2, !"Debug Info Version", i32 3}
24 !8 = !{!"LLVM version 3.7.0"}