diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-25 23:30:02 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-25 23:30:02 +0000 |
commit | 99734e76691de1011a4afc76e2aa183161a5aa1c (patch) | |
tree | 26909b19bb1972331e0831085b3bcd0d88288ca6 /clang/lib/Lex | |
parent | c06ce0f71083f6bd5d9fd18dfb9a7abe382028e9 (diff) | |
download | bcm5719-llvm-99734e76691de1011a4afc76e2aa183161a5aa1c.tar.gz bcm5719-llvm-99734e76691de1011a4afc76e2aa183161a5aa1c.zip |
Lazily load the controlling macros for all of the headers known in the
PCH file. In the Cocoa-prefixed "Hello, World" benchmark, this takes
us from reading 503 identifiers down to 37 and from 470 macros down to
4. It also results in an 8% performance improvement.
llvm-svn: 70094
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r-- | clang/lib/Lex/HeaderSearch.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index ddea8e52a02..129fa1ae35f 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -20,10 +20,23 @@ #include <cstdio> using namespace clang; +const IdentifierInfo * +HeaderFileInfo::getControllingMacro(ExternalIdentifierLookup *External) { + if (ControllingMacro) + return ControllingMacro; + + if (!ControllingMacroID || !External) + return 0; + + ControllingMacro = External->GetIdentifier(ControllingMacroID); + return ControllingMacro; +} + HeaderSearch::HeaderSearch(FileManager &FM) : FileMgr(FM), FrameworkMap(64) { SystemDirIdx = 0; NoCurDirSearch = false; - + + ExternalLookup = 0; NumIncluded = 0; NumMultiIncludeFileOptzn = 0; NumFrameworkLookups = NumSubFrameworkLookups = 0; @@ -417,11 +430,12 @@ bool HeaderSearch::ShouldEnterIncludeFile(const FileEntry *File, bool isImport){ // Next, check to see if the file is wrapped with #ifndef guards. If so, and // if the macro that guards it is defined, we know the #include has no effect. - if (FileInfo.ControllingMacro && - FileInfo.ControllingMacro->hasMacroDefinition()) { - ++NumMultiIncludeFileOptzn; - return false; - } + if (const IdentifierInfo *ControllingMacro + = FileInfo.getControllingMacro(ExternalLookup)) + if (ControllingMacro->hasMacroDefinition()) { + ++NumMultiIncludeFileOptzn; + return false; + } // Increment the number of times this file has been included. ++FileInfo.NumIncludes; |