hanchenye-llvm-project/clang/test/Modules
Douglas Gregor 935bc7a214 Make the loading of information attached to an IdentifierInfo from an
AST file more lazy, so that we don't eagerly load that information for
all known identifiers each time a new AST file is loaded. The eager
reloading made some sense in the context of precompiled headers, since
very few identifiers were defined before PCH load time. With modules,
however, a huge amount of code can get parsed before we see an
@import, so laziness becomes important here.

The approach taken to make this information lazy is fairly simple:
when we load a new AST file, we mark all of the existing identifiers
as being out-of-date. Whenever we want to access information that may
come from an AST (e.g., whether the identifier has a macro definition,
or what top-level declarations have that name), we check the
out-of-date bit and, if it's set, ask the AST reader to update the
IdentifierInfo from the AST files. The update is a merge, and we now
take care to merge declarations before/after imports with declarations
from multiple imports.

The results of this optimization are fairly dramatic. On a small
application that brings in 14 non-trivial modules, this takes modules
from being > 3x slower than a "perfect" PCH file down to 30% slower
for a full rebuild. A partial rebuild (where the PCH file or modules
can be re-used) is down to 7% slower. Making the PCH file just a
little imperfect (e.g., adding two smallish modules used by a bunch of
.m files that aren't in the PCH file) tips the scales in favor of the
modules approach, with 24% faster partial rebuilds.

This is just a first step; the lazy scheme could possibly be improved
by adding versioning, so we don't search into modules we already
searched. Moreover, we'll need similar lazy schemes for all of the
other lookup data structures, such as DeclContexts.

llvm-svn: 143100
2011-10-27 09:33:13 +00:00
..
Inputs For modules, all macros that aren't include guards are implicitly 2011-10-17 15:32:29 +00:00
auto-module-import.c Add an experimental flag -fauto-module-import that automatically turns 2011-09-15 22:00:41 +00:00
cycles.c Add test case for mutually recursive modules 2011-09-15 20:54:06 +00:00
diamond.c For modules, use a hash of the compiler version, language options, and 2011-09-13 23:15:45 +00:00
driver.c Add test for the driver's handling of modules 2011-09-14 20:29:10 +00:00
header-import.m When we load header file information from the external source (i.e., 2011-09-17 05:35:18 +00:00
irgen.c When we load the first module, make sure that we wire up the ASTConsumer to the newly-created ASTReader. This makes sure that CodeGen sees the declarations it is interested in 2011-09-15 18:47:32 +00:00
load_failure.c For modules, use a hash of the compiler version, language options, and 2011-09-13 23:15:45 +00:00
lookup.cpp For modules, use a hash of the compiler version, language options, and 2011-09-13 23:15:45 +00:00
lookup.m For modules, use a hash of the compiler version, language options, and 2011-09-13 23:15:45 +00:00
macros.c For modules, all macros that aren't include guards are implicitly 2011-10-17 15:32:29 +00:00
module-private.cpp For modules, use a hash of the compiler version, language options, and 2011-09-13 23:15:45 +00:00
objc-categories.m With modules, we can end up loading a new module after we've seen an 2011-09-17 00:05:03 +00:00
on-demand-build-warnings.m When building a module, use the macro definitions on the command line 2011-10-17 14:55:37 +00:00
on-demand-build.m For modules, all macros that aren't include guards are implicitly 2011-10-17 15:32:29 +00:00
on-demand-macros.m When building a module, use the macro definitions on the command line 2011-10-17 14:55:37 +00:00
redeclarations.m Make the loading of information attached to an IdentifierInfo from an 2011-10-27 09:33:13 +00:00