Name lookup: avoid even calling lookup code on Clang submodules.

This is a hack.

We currently don't put anything in Clang submodules; they're just wrappers
to track what is and isn't visible. All lookups happen through the top-
level module.

This commit adds a new API getImportedModulesForLookup, which is ONLY used
by top-level name lookup and forAllVisibleModules. It is identical to
getImportedModules for everything but ClangModuleUnits, which instead
compute and cache a list of their transitively imported top-level modules.

This speeds up building Foundation.swiftmodule with a release compiler by
a bit more than 5%, and makes a previously lookup-bound test case compile
a third faster than before.

This is a hack.

rdar://problem/20813240

Swift SVN r28598
This commit is contained in:
Jordan Rose
2015-05-15 01:26:05 +00:00
parent 63eb2d0128
commit c129637bf6
5 changed files with 180 additions and 75 deletions

View File

@@ -1076,8 +1076,6 @@ LOOKUP_OPERATOR(Postfix)
void Module::getImportedModules(SmallVectorImpl<ImportedModule> &modules,
Module::ImportFilter filter) const {
// FIXME: Audit uses of this function and make sure they make sense in a
// multi-file world.
FORWARD(getImportedModules, (modules, filter));
}
@@ -1103,6 +1101,11 @@ SourceFile::getImportedModules(SmallVectorImpl<Module::ImportedModule> &modules,
}
}
void Module::getImportedModulesForLookup(
SmallVectorImpl<ImportedModule> &modules) const {
FORWARD(getImportedModulesForLookup, (modules));
}
bool Module::isSameAccessPath(AccessPathTy lhs, AccessPathTy rhs) {
using AccessPathElem = std::pair<Identifier, SourceLoc>;
if (lhs.size() != rhs.size())
@@ -1288,7 +1291,11 @@ static bool forAllImportedModules(Module *topLevel,
if (!fn(next))
return false;
next.second->getImportedModules(stack, filter);
if (respectVisibility)
next.second->getImportedModulesForLookup(stack);
else
next.second->getImportedModules(stack, filter);
}
return true;