[DwarfDebug] Move emission of imported entities from beginModule() to… · llvm/llvm-project@40b2eb6 (original) (raw)

6 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -1258,10 +1258,6 @@ void DwarfDebug::beginModule(Module *M) {
1258 1258 // There is no point in force-emitting a forward declaration.
1259 1259 CU.getOrCreateTypeDIE(RT);
1260 1260 }
1261 -// Emit imported_modules last so that the relevant context is already
1262 -// available.
1263 -for (auto *IE : CUNode->getImportedEntities())
1264 -constructAndAddImportedEntityDIE(CU, IE);
1265 1261 }
1266 1262 }
1267 1263
@@ -1442,8 +1438,15 @@ void DwarfDebug::endModule() {
1442 1438 assert(CurMI == nullptr);
1443 1439
1444 1440 for (const auto &P : CUMap) {
1445 -auto &CU = *P.second;
1446 - CU.createBaseTypeDIEs();
1441 +const auto *CUNode = cast(P.first);
1442 + DwarfCompileUnit *CU = &*P.second;
1443 +
1444 +// Emit imported entities.
1445 +for (auto *IE : CUNode->getImportedEntities())
1446 +constructAndAddImportedEntityDIE(*CU, IE);
1447 +
1448 +// Emit base types.
1449 + CU->createBaseTypeDIEs();
1447 1450 }
1448 1451
1449 1452 // If we aren't actually generating debug info (check beginModule -
Original file line number Diff line number Diff line change
@@ -36,9 +36,8 @@ entry:
36 36 ; CHECK: .quad bla1
37 37 ; CHECK-NEXT: DW_TAG_variable
38 38 ;
39 -; CHECK: .quad bla2
39 +; CHECK: .quad bla2
40 40 ; CHECK-NEXT: DW_TAG_const_type
41 -; CHECK-NEXT: DW_TAG_subprogram
42 41
43 42 ; Function Attrs: nounwind readnone speculatable willreturn
44 43 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
Original file line number Diff line number Diff line change
@@ -57,13 +57,8 @@
57 57 ; CHECK: NULL
58 58
59 59 ; CHECK: DW_TAG_base_type
60 -; CHECK: DW_TAG_imported_module
61 -; CHECK: DW_AT_decl_file ([[F2:.*]])
62 -; CHECK: DW_AT_decl_line (18)
63 -; CHECK: DW_AT_import ([[NS1]])
64 -; CHECK: DW_TAG_imported_declaration
65 -
66 60 ; CHECK: DW_TAG_subprogram
61 +
67 62 ; CHECK: DW_TAG_subprogram
68 63 ; CHECK: DW_AT_MIPS_linkage_name
69 64 ; CHECK: DW_AT_name ("func")
@@ -127,6 +122,11 @@
127 122 ; CHECK: NULL
128 123
129 124 ; CHECK: DW_TAG_subprogram
125 +; CHECK: DW_TAG_imported_module
126 +; CHECK: DW_AT_decl_file ([[F2:.*]])
127 +; CHECK: DW_AT_decl_line (18)
128 +; CHECK: DW_AT_import ([[NS1]])
129 +; CHECK: DW_TAG_imported_declaration
130 130 ; CHECK: DW_TAG_base_type
131 131 ; CHECK: NULL
132 132