diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-18 00:07:54 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-18 00:07:54 +0000 |
commit | 3c3aa617581999a0ad757c05fd8920682bedaccc (patch) | |
tree | 7badab0e510c5c046be96f5fbc5f6688c508dc0a /clang/lib/Frontend/PCHReader.cpp | |
parent | e3dcb2ddd11d76b5b0a394f8c33437a38810bcb7 (diff) | |
download | bcm5719-llvm-3c3aa617581999a0ad757c05fd8920682bedaccc.tar.gz bcm5719-llvm-3c3aa617581999a0ad757c05fd8920682bedaccc.zip |
Lazy deserialization of function bodies for PCH files. For the Carbon
"Hello, World!", this takes us from deserializing 6469
statements/expressions down to deserializing 1
statement/expression. It only translated into a 1% improvement on the
Carbon-prefixed 403.gcc, but (a) it's the right thing to do, and (b)
we expect this to matter more once we lazily deserialize identifiers.
llvm-svn: 69407
Diffstat (limited to 'clang/lib/Frontend/PCHReader.cpp')
-rw-r--r-- | clang/lib/Frontend/PCHReader.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp index 5ea1f7c6c22..dc8d3fce34f 100644 --- a/clang/lib/Frontend/PCHReader.cpp +++ b/clang/lib/Frontend/PCHReader.cpp @@ -140,7 +140,7 @@ void PCHDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) { void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) { VisitValueDecl(FD); if (Record[Idx++]) - FD->setBody(cast<CompoundStmt>(Reader.ReadStmt())); + FD->setLazyBody(Reader.getStream().GetCurrentBitNo()); FD->setPreviousDeclaration( cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++]))); FD->setStorageClass((FunctionDecl::StorageClass)Record[Idx++]); @@ -1880,6 +1880,15 @@ Decl *PCHReader::GetDecl(pch::DeclID ID) { return ReadDeclRecord(DeclOffsets[Index], Index); } +Stmt *PCHReader::GetStmt(uint64_t Offset) { + // Keep track of where we are in the stream, then jump back there + // after reading this declaration. + SavedStreamPosition SavedPosition(Stream); + + Stream.JumpToBit(Offset); + return ReadStmt(); +} + bool PCHReader::ReadDeclsLexicallyInContext(DeclContext *DC, llvm::SmallVectorImpl<pch::DeclID> &Decls) { assert(DC->hasExternalLexicalStorage() && |