diff options
author | Vladislav Dzhidzhoev <vdzhidzhoev@accesssoftek.com> | 2023-06-15 18:04:32 +0200 |
---|---|---|
committer | Vladislav Dzhidzhoev <vdzhidzhoev@accesssoftek.com> | 2023-06-15 18:04:32 +0200 |
commit | fbdeb8cbc147f8f49fbd4bf23fae01bd142f0f5d (patch) | |
tree | adafb5b1b81e23b3f185cdcabc44ac42b844fa5d /llvm/lib/Linker/IRMover.cpp | |
parent | dcdfc963d7934a1313094b6fe9ce7aa04debe495 (diff) | |
download | llvm-fbdeb8cbc147f8f49fbd4bf23fae01bd142f0f5d.zip llvm-fbdeb8cbc147f8f49fbd4bf23fae01bd142f0f5d.tar.gz llvm-fbdeb8cbc147f8f49fbd4bf23fae01bd142f0f5d.tar.bz2 |
Revert "[DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local imported entities (3/7)"
This reverts commit d80fdc6fc1a6e717af1bcd7a7313e65de433ba85.
split-dwarf-local-impor3.ll fails because of an issue with
Dwo sections emission on Windows platform.
Diffstat (limited to 'llvm/lib/Linker/IRMover.cpp')
-rw-r--r-- | llvm/lib/Linker/IRMover.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index df090c59..97794ee 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -1211,7 +1211,39 @@ void IRLinker::prepareCompileUnitsForImport() { // size inefficient. CU->replaceGlobalVariables(nullptr); - CU->replaceImportedEntities(nullptr); + // Imported entities only need to be mapped in if they have local + // scope, as those might correspond to an imported entity inside a + // function being imported (any locally scoped imported entities that + // don't end up referenced by an imported function will not be emitted + // into the object). Imported entities not in a local scope + // (e.g. on the namespace) only need to be emitted by the originating + // module. Create a list of the locally scoped imported entities, and + // replace the source CUs imported entity list with the new list, so + // only those are mapped in. + // FIXME: Locally-scoped imported entities could be moved to the + // functions they are local to instead of listing them on the CU, and + // we would naturally only link in those needed by function importing. + SmallVector<TrackingMDNodeRef, 4> AllImportedModules; + bool ReplaceImportedEntities = false; + for (auto *IE : CU->getImportedEntities()) { + DIScope *Scope = IE->getScope(); + assert(Scope && "Invalid Scope encoding!"); + if (isa<DILocalScope>(Scope)) + AllImportedModules.emplace_back(IE); + else + ReplaceImportedEntities = true; + } + if (ReplaceImportedEntities) { + if (!AllImportedModules.empty()) + CU->replaceImportedEntities(MDTuple::get( + CU->getContext(), + SmallVector<Metadata *, 16>(AllImportedModules.begin(), + AllImportedModules.end()))); + else + // If there were no local scope imported entities, we can map + // the whole list to nullptr. + CU->replaceImportedEntities(nullptr); + } } } |