diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-01-19 23:13:15 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-01-19 23:13:15 +0000 |
commit | 8433f0b400683a539c25f40047eb8cbf92dca92c (patch) | |
tree | 24246e6d0a07026f28c840768c6a56e88472d734 /clang/Driver/CacheTokens.cpp | |
parent | ea9f1d3c47a5fa42bee7207e8c588f61bb31b183 (diff) | |
download | bcm5719-llvm-8433f0b400683a539c25f40047eb8cbf92dca92c.tar.gz bcm5719-llvm-8433f0b400683a539c25f40047eb8cbf92dca92c.zip |
PTH: Emitted tokens now consist of 12 bytes that are loaded used 3 32-bit loads. This reduces user time but increases system time because of the slightly larger PTH file. Although there is no performance win on Cocoa.h and -Eonly, overall this seems like a good step.
llvm-svn: 62542
Diffstat (limited to 'clang/Driver/CacheTokens.cpp')
-rw-r--r-- | clang/Driver/CacheTokens.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/clang/Driver/CacheTokens.cpp b/clang/Driver/CacheTokens.cpp index 7aa63b3a384..1d33105668f 100644 --- a/clang/Driver/CacheTokens.cpp +++ b/clang/Driver/CacheTokens.cpp @@ -133,12 +133,13 @@ uint32_t PTHWriter::ResolveID(const IdentifierInfo* II) { void PTHWriter::EmitToken(const Token& T) { uint32_t fpos = PP.getSourceManager().getFullFilePos(T.getLocation()); - Emit8(T.getKind()); - Emit8(T.getFlags()); - Emit24(ResolveID(T.getIdentifierInfo())); + + Emit32(((uint32_t) T.getKind()) | + (((uint32_t) T.getFlags()) << 8) | + (((uint32_t) T.getLength()) << 16)); + Emit32(ResolveID(T.getIdentifierInfo())); Emit32(fpos); - Emit16(T.getLength()); - + // For specific tokens we cache their spelling. if (T.getIdentifierInfo()) return; @@ -270,9 +271,10 @@ Offset PTHWriter::EmitFileTable() { } PCHEntry PTHWriter::LexTokens(Lexer& L) { - - // Record the location within the token file. - Offset off = (Offset) Out.tell(); + // Pad 0's so that we emit tokens to a 4-byte alignment. + // This speed up reading them back in. + Offset off = (Offset) Out.tell(); + for (unsigned Pad = off % 4 ; Pad != 0 ; --Pad, ++off) Emit8(0); // Keep track of matching '#if' ... '#endif'. typedef std::vector<std::pair<Offset, unsigned> > PPCondTable; |