diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-03-27 20:13:24 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-03-27 20:13:24 +0000 |
commit | b22a1d186ff5d6bb649e302bc28863e97c0db0bf (patch) | |
tree | 4c75d72dbc1c25c0eea7a948da213583934253e9 /clang/lib/Serialization/ASTWriter.cpp | |
parent | 8930aab886eed9470bca67425e08455f32590a44 (diff) | |
download | bcm5719-llvm-b22a1d186ff5d6bb649e302bc28863e97c0db0bf.tar.gz bcm5719-llvm-b22a1d186ff5d6bb649e302bc28863e97c0db0bf.zip |
[modules] When encoding SourceLocations in bitcode, rotate the 'is macro' flag
bit from the top bit to the bottom bit, so that we don't need 6 VBR6 hunks for
each macro location. Reduces libstdc++ module size by about 1%.
llvm-svn: 264540
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 89a54a18d3d..a828d350c04 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1912,7 +1912,7 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr, Record.push_back(SLoc->getOffset() - 2); if (SLoc->isFile()) { const SrcMgr::FileInfo &File = SLoc->getFile(); - Record.push_back(File.getIncludeLoc().getRawEncoding()); + AddSourceLocation(File.getIncludeLoc(), Record); Record.push_back(File.getFileCharacteristic()); // FIXME: stable encoding Record.push_back(File.hasLineDirectives()); @@ -1984,10 +1984,12 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr, } else { // The source location entry is a macro expansion. const SrcMgr::ExpansionInfo &Expansion = SLoc->getExpansion(); - Record.push_back(Expansion.getSpellingLoc().getRawEncoding()); - Record.push_back(Expansion.getExpansionLocStart().getRawEncoding()); - Record.push_back(Expansion.isMacroArgExpansion() ? 0 - : Expansion.getExpansionLocEnd().getRawEncoding()); + AddSourceLocation(Expansion.getSpellingLoc(), Record); + AddSourceLocation(Expansion.getExpansionLocStart(), Record); + AddSourceLocation(Expansion.isMacroArgExpansion() + ? SourceLocation() + : Expansion.getExpansionLocEnd(), + Record); // Compute the token length for this macro expansion. unsigned NextOffset = SourceMgr.getNextLocalOffset(); @@ -2669,7 +2671,7 @@ void ASTWriter::WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag, if (point.Loc.isInvalid()) continue; - Record.push_back(point.Loc.getRawEncoding()); + AddSourceLocation(point.Loc, Record); unsigned &DiagStateID = DiagStateIDMap[point.State]; Record.push_back(DiagStateID); @@ -4782,7 +4784,8 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) { } void ASTWriter::AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record) { - Record.push_back(Loc.getRawEncoding()); + uint32_t Raw = Loc.getRawEncoding(); + Record.push_back((Raw << 1) | (Raw >> 31)); } void ASTWriter::AddSourceRange(SourceRange Range, RecordDataImpl &Record) { |