summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Linker
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-02 17:39:31 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-02 17:39:31 +0000
commit0d60a9887fafd6433121210742bd82e2a36f14bc (patch)
treecd3c124a4afe3ef3119e3eb9d372dd97c3e50461 /llvm/lib/Linker
parent8958c404302f3e25ea7b8719108140a4ffc66681 (diff)
downloadbcm5719-llvm-0d60a9887fafd6433121210742bd82e2a36f14bc.tar.gz
bcm5719-llvm-0d60a9887fafd6433121210742bd82e2a36f14bc.zip
Linker: Avoid unnecessary work when moving named metadata
IRLinker::mapUnneededSubprograms has to be sure that any "needed" subprograms get linked in. Rather than traversing through imported entities using llvm::getSubprogram, call MapMetadata. The latter memoizes the result in the ValueMap (sharing work with IRLinker::linkNamedMDNodes proper), and makes the local SmallPtrSet redundant. llvm-svn: 265231
Diffstat (limited to 'llvm/lib/Linker')
-rw-r--r--llvm/lib/Linker/IRMover.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index f104db44bb8..9a69d0bae46 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -1043,28 +1043,22 @@ void IRLinker::mapUnneededSubprograms() {
for (unsigned I = 0, E = CompileUnits->getNumOperands(); I != E; ++I) {
auto *CU = cast<DICompileUnit>(CompileUnits->getOperand(I));
assert(CU && "Expected valid compile unit");
- // Ensure that we don't remove subprograms referenced by DIImportedEntity.
- // It is not legal to have a DIImportedEntity with a null entity or scope.
- // Using getDISubprogram handles the case where the subprogram is reached
- // via an intervening DILexicalBlock.
+
+ // Seed the ValueMap with the imported entities, in case they reference new
+ // subprograms.
// FIXME: The DISubprogram for functions not linked in but kept due to
// being referenced by a DIImportedEntity should also get their
// IsDefinition flag is unset.
- SmallPtrSet<DISubprogram *, 8> ImportedEntitySPs;
- for (auto *IE : CU->getImportedEntities()) {
- if (auto *SP = getDISubprogram(dyn_cast<MDNode>(IE->getEntity())))
- ImportedEntitySPs.insert(SP);
- if (auto *SP = getDISubprogram(dyn_cast<MDNode>(IE->getScope())))
- ImportedEntitySPs.insert(SP);
- }
+ if (MDTuple *IEs = CU->getImportedEntities().get())
+ (void)MapMetadata(IEs, ValueMap,
+ ValueMapperFlags | RF_NullMapMissingGlobalValues,
+ &TypeMap, &GValMaterializer);
- // Try to insert nullptr into the map for any SP not referenced from
- // functions and not in the imported entities. If the insertino succeeded,
- // set HasUnneededSPs.
+ // Try to insert nullptr into the map for any SP not already mapped. If
+ // the insertion succeeds, we don't need this subprogram.
for (auto *Op : CU->getSubprograms())
- if (!ImportedEntitySPs.count(Op))
- if (ValueMap.MD().insert(std::make_pair(Op, TrackingMDRef())).second)
- HasUnneededSPs = true;
+ if (ValueMap.MD().insert(std::make_pair(Op, TrackingMDRef())).second)
+ HasUnneededSPs = true;
}
}
OpenPOWER on IntegriCloud