aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/PCHWriter.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-22 19:09:20 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-22 19:09:20 +0000
commit0af2ca4b6ddc788658069a0994941268ce250fc7 (patch)
tree11483ed96a1a322713a05d9c308ccb50829d5a31 /lib/Frontend/PCHWriter.cpp
parent25bcbaf55691f15db3e2bbf7b4c53056a04c6a54 (diff)
Minimize the number and kind of "external definitions" that the PCH
file needs to store. CodeGen needs to see these definitions (via HandleTopLevelDecl), otherwise it won't be able to generate code for them. This patch notifies the consumer (e.g., CodeGen) about function definitions and variable definitions when the corresponding declarations are deserialized. Hence, we don't eagerly deserialize the declarations for every variable or function that has a definition in the PCH file. This gives another 5% speedup for the Carbon-prefixed "Hello, World!", and brings our PCH statistics down to something far more reasonable: *** PCH Statistics: 13/20693 types read (0.062823%) 17/59230 declarations read (0.028702%) 54/44914 identifiers read (0.120230%) 0/32954 statements read (0.000000%) 5/6187 macros read (0.080815%) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69820 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHWriter.cpp')
-rw-r--r--lib/Frontend/PCHWriter.cpp17
1 files changed, 1 insertions, 16 deletions
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 15ee2369dd..b081a2813f 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -574,8 +574,7 @@ void PCHDeclWriter::VisitBlockDecl(BlockDecl *D) {
void PCHDeclWriter::VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset,
uint64_t VisibleOffset) {
Record.push_back(LexicalOffset);
- if (DC->getPrimaryContext() == DC)
- Record.push_back(VisibleOffset);
+ Record.push_back(VisibleOffset);
}
//===----------------------------------------------------------------------===//
@@ -1728,20 +1727,6 @@ void PCHWriter::WriteDeclsBlock(ASTContext &Context) {
// in the PCH file later.
if (isa<FileScopeAsmDecl>(D))
ExternalDefinitions.push_back(ID);
- else if (VarDecl *Var = dyn_cast<VarDecl>(D)) {
- if (// Non-static file-scope variables with initializers or that
- // are tentative definitions.
- (Var->isFileVarDecl() &&
- (Var->getInit() || Var->getStorageClass() == VarDecl::None)) ||
- // Out-of-line definitions of static data members (C++).
- (Var->getDeclContext()->isRecord() &&
- !Var->getLexicalDeclContext()->isRecord() &&
- Var->getStorageClass() == VarDecl::Static))
- ExternalDefinitions.push_back(ID);
- } else if (FunctionDecl *Func = dyn_cast<FunctionDecl>(D)) {
- if (Func->isThisDeclarationADefinition())
- ExternalDefinitions.push_back(ID);
- }
}
// Exit the declarations block