[Pass][Layout] Make algorithm not n^2.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Tue, 12 Mar 2013 00:10:00 +0000 (00:10 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Tue, 12 Mar 2013 00:10:00 +0000 (00:10 +0000)
This reduces the time spent in this function while linking ASTMatchersTests
from %43 to %2.4 of total link time.

llvm-svn: 176842

lld/lib/Passes/LayoutPass.cpp

index 4f2a177..2bf43aa 100644 (file)
@@ -390,6 +390,8 @@ void LayoutPass::buildOrdinalOverrideMap(MutableFile::DefinedAtomRange &range) {
   uint64_t index = 0;
   for (auto ai : range) {
     const DefinedAtom *atom = ai;
+    if (_ordinalOverrideMap.find(atom) != _ordinalOverrideMap.end())
+      continue;
     AtomToAtomT::iterator start = _followOnRoots.find(atom);
     if (start != _followOnRoots.end()) {
       for (const DefinedAtom *nextAtom = start->second; nextAtom != NULL;