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

@@ -190,7 +190,7 @@ static void lookupInModule(Module *module, Module::AccessPathTy accessPath,
if (!foundDecls || !canReturnEarly ||
resolutionKind == ResolutionKind::Overloadable) {
SmallVector<Module::ImportedModule, 8> reexports;
module->getImportedModules(reexports, Module::ImportFilter::Public);
module->getImportedModulesForLookup(reexports);
reexports.append(extraImports.begin(), extraImports.end());
// Prefer scoped imports (import func Swift.max) to whole-module imports.