[DwarfDebug] Move emission of imported entities from beginModule() to endModule() (2/7)
RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 !Note! Extracted from the following patch for review purpose only, should be squashed with the next patch (D144004) before committing. Currently the back-end emits imported entities in `DwarfDebug::beginModule()`. However in case an imported declaration is a function, it must point to an abstract subprogram if it exists (see PR51501). But in `DwarfDebug::beginModule()` the DWARF generator doesn't have information to identify if an abstract subprogram needs to be created. Only by entering `DwarfDebug::endModule()` all subprograms are processed, so it's clear which subprogram DIE should be referred to. Hence, the patch moves the emission there. The patch is need to fix PR51501, but it only does the preliminary work. Since it changes the order of debug entities in emitted DWARF and therefore affect many tests it's separated from the fix for the sake of simplifying review. Note that there are other issues with handling an imported declaration in `DwarfDebug::beginModule()`. They are described in more details in D114705. Differential Revision: https://reviews.llvm.org/D143985 Depends on D143984
This commit is contained in:
committed by
Vladislav Dzhidzhoev
parent
b8c08f7ae8
commit
40b2eb62aa
@@ -1258,10 +1258,6 @@ void DwarfDebug::beginModule(Module *M) {
|
||||
// There is no point in force-emitting a forward declaration.
|
||||
CU.getOrCreateTypeDIE(RT);
|
||||
}
|
||||
// Emit imported_modules last so that the relevant context is already
|
||||
// available.
|
||||
for (auto *IE : CUNode->getImportedEntities())
|
||||
constructAndAddImportedEntityDIE(CU, IE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1442,8 +1438,15 @@ void DwarfDebug::endModule() {
|
||||
assert(CurMI == nullptr);
|
||||
|
||||
for (const auto &P : CUMap) {
|
||||
auto &CU = *P.second;
|
||||
CU.createBaseTypeDIEs();
|
||||
const auto *CUNode = cast<DICompileUnit>(P.first);
|
||||
DwarfCompileUnit *CU = &*P.second;
|
||||
|
||||
// Emit imported entities.
|
||||
for (auto *IE : CUNode->getImportedEntities())
|
||||
constructAndAddImportedEntityDIE(*CU, IE);
|
||||
|
||||
// Emit base types.
|
||||
CU->createBaseTypeDIEs();
|
||||
}
|
||||
|
||||
// If we aren't actually generating debug info (check beginModule -
|
||||
|
||||
@@ -36,9 +36,8 @@ entry:
|
||||
; CHECK: .quad bla1
|
||||
; CHECK-NEXT: DW_TAG_variable
|
||||
;
|
||||
; CHECK: .quad bla2
|
||||
; CHECK: .quad bla2
|
||||
; CHECK-NEXT: DW_TAG_const_type
|
||||
; CHECK-NEXT: DW_TAG_subprogram
|
||||
|
||||
; Function Attrs: nounwind readnone speculatable willreturn
|
||||
declare void @llvm.dbg.value(metadata, metadata, metadata) #1
|
||||
|
||||
@@ -57,13 +57,8 @@
|
||||
; CHECK: NULL
|
||||
|
||||
; CHECK: DW_TAG_base_type
|
||||
; CHECK: DW_TAG_imported_module
|
||||
; CHECK: DW_AT_decl_file ([[F2:.*]])
|
||||
; CHECK: DW_AT_decl_line (18)
|
||||
; CHECK: DW_AT_import ([[NS1]])
|
||||
; CHECK: DW_TAG_imported_declaration
|
||||
|
||||
; CHECK: DW_TAG_subprogram
|
||||
|
||||
; CHECK: DW_TAG_subprogram
|
||||
; CHECK: DW_AT_MIPS_linkage_name
|
||||
; CHECK: DW_AT_name ("func")
|
||||
@@ -127,6 +122,11 @@
|
||||
; CHECK: NULL
|
||||
|
||||
; CHECK: DW_TAG_subprogram
|
||||
; CHECK: DW_TAG_imported_module
|
||||
; CHECK: DW_AT_decl_file ([[F2:.*]])
|
||||
; CHECK: DW_AT_decl_line (18)
|
||||
; CHECK: DW_AT_import ([[NS1]])
|
||||
; CHECK: DW_TAG_imported_declaration
|
||||
; CHECK: DW_TAG_base_type
|
||||
; CHECK: NULL
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -119,10 +119,10 @@
|
||||
; CHECK: DW_AT_name ("D")
|
||||
; CHECK: DW_TAG_member
|
||||
; CHECK: NULL
|
||||
; CHECK: DW_TAG_variable
|
||||
; CHECK: [[GLOB_NS_FUNC:0x[0-9a-f]+]]: DW_TAG_subprogram
|
||||
; CHECK: DW_AT_linkage_name
|
||||
; CHECK: DW_AT_name ("global_namespace_function")
|
||||
; CHECK: DW_TAG_variable
|
||||
; CHECK: NULL
|
||||
|
||||
; CHECK: [[F3:0x[0-9a-f]+]]: DW_TAG_subprogram
|
||||
@@ -172,8 +172,6 @@
|
||||
; CHECK: DW_AT_name ("named_enum_class_enumerator")
|
||||
; CHECK: NULL
|
||||
|
||||
; CHECK: DW_TAG_imported_declaration
|
||||
|
||||
; CHECK: [[MEM_FUNC:0x[0-9a-f]+]]: DW_TAG_subprogram
|
||||
; CHECK: DW_AT_specification {{.*}} "_ZN1C15member_functionEv"
|
||||
; CHECK: DW_TAG_formal_parameter
|
||||
@@ -190,6 +188,7 @@
|
||||
; CHECK: DW_AT_linkage_name
|
||||
; CHECK: DW_AT_name ("f7")
|
||||
|
||||
; CHECK: DW_TAG_imported_declaration
|
||||
; CHECK: DW_TAG_pointer_type
|
||||
; CHECK: DW_TAG_pointer_type
|
||||
; CHECK: NULL
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
; CHECK: DW_TAG_lexical_block
|
||||
; CHECK-NOT: {{DW_TAG|NULL}}
|
||||
; CHECK: DW_TAG_variable
|
||||
; CHECK-NOT: {{DW_TAG|NULL}}
|
||||
; CHECK: DW_TAG_imported_module
|
||||
|
||||
;; Abstract "bar" function
|
||||
; CHECK: [[Offset_bar]]: DW_TAG_subprogram
|
||||
@@ -60,9 +58,6 @@
|
||||
; CHECK: DW_TAG_lexical_block
|
||||
; CHECK-NOT: {{DW_TAG|NULL}}
|
||||
; CHECK: DW_TAG_variable
|
||||
; CHECK-NOT: {{DW_TAG|NULL}}
|
||||
; CHECK: DW_TAG_imported_module
|
||||
|
||||
|
||||
; Function Attrs: alwaysinline nounwind
|
||||
define i32 @_Z3barv() #0 !dbg !4 {
|
||||
|
||||
Reference in New Issue
Block a user