llvm-project/clang/lib/Lex
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
..
CMakeLists.txt Add CMake dependencies so that LLVM_USED_LIBS order doesn't matter. 2011-02-11 23:46:38 +00:00
HeaderMap.cpp remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports 2011-07-23 10:55:15 +00:00
HeaderSearch.cpp When we load header file information from the external source (i.e., 2011-09-17 05:35:18 +00:00
Lexer.cpp Move about 20 random diagnostics under -W flags. Patch by Ahmed Charles! 2011-10-17 21:47:53 +00:00
LiteralSupport.cpp We do parse hexfloats in C++11; make it actually work. 2011-10-12 18:51:02 +00:00
MacroArgs.cpp Fixed exapnsion range for # and ##. 2011-10-03 18:39:03 +00:00
MacroArgs.h Fixed exapnsion range for # and ##. 2011-10-03 18:39:03 +00:00
MacroInfo.cpp For modules, all macros that aren't include guards are implicitly 2011-10-17 15:32:29 +00:00
Makefile BUILD_ARCHIVE is the default for libraries, no need to set it. 2010-07-18 00:14:47 +00:00
PPCaching.cpp Optimize the preprocessor's handling of the __import_module__ 2011-09-07 23:11:54 +00:00
PPDirectives.cpp For modules, all macros that aren't include guards are implicitly 2011-10-17 15:32:29 +00:00
PPExpressions.cpp -Wc++98-compat warnings for the lexer. 2011-10-15 01:18:56 +00:00
PPLexerChange.cpp Argyrios says this change is required for safety under PTH. 2011-10-18 01:36:41 +00:00
PPMacroExpansion.cpp Make the loading of information attached to an IdentifierInfo from an 2011-10-27 09:33:13 +00:00
PTHLexer.cpp Rename Diagnostic to DiagnosticsEngine as per issue 5397 2011-09-25 23:23:43 +00:00
Pragma.cpp Make the loading of information attached to an IdentifierInfo from an 2011-10-27 09:33:13 +00:00
PreprocessingRecord.cpp [PCH] When visiting preprocessed entities, make it possible to avoid deserializing 2011-10-25 00:29:50 +00:00
Preprocessor.cpp Make the loading of information attached to an IdentifierInfo from an 2011-10-27 09:33:13 +00:00
PreprocessorLexer.cpp Boost the efficiency of SourceManager::getMacroArgExpandedLocation. 2011-08-21 23:33:04 +00:00
ScratchBuffer.cpp Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset. 2011-09-19 20:40:19 +00:00
TokenConcatenation.cpp Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset. 2011-09-19 20:40:19 +00:00
TokenLexer.cpp Fixed exapnsion range for # and ##. 2011-10-03 18:39:03 +00:00