diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-03-24 23:41:14 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-03-24 23:41:14 +0000 |
commit | d07268c52832948e7d8cd61b53312aa0e14e93f8 (patch) | |
tree | f4c892244c259a08abd0ccb3cf003371cece7501 | |
parent | 9dd8c146746a0435115a461bd19d9aede965800c (diff) | |
download | bcm5719-llvm-d07268c52832948e7d8cd61b53312aa0e14e93f8.tar.gz bcm5719-llvm-d07268c52832948e7d8cd61b53312aa0e14e93f8.zip |
[modules] Store offset to LOCAL_REDECLARATIONS record relative to the current
record rather than relative to the start of the bitcode file. Saves a couple of
bytes per LOCAL_REDECLARATIONS record (also makes diffs of llvm-bcanalyzer
output more useful when tracking down nondeterminism...).
llvm-svn: 264359
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 16 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTWriterDecl.cpp | 3 |
2 files changed, 13 insertions, 6 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index e580eb03e85..573a13aee2d 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -38,6 +38,7 @@ namespace clang { class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> { ASTReader &Reader; ModuleFile &F; + uint64_t Offset; const DeclID ThisDeclID; const unsigned RawLocation; typedef ASTReader::RecordData RecordData; @@ -199,9 +200,10 @@ namespace clang { FindExistingResult findExisting(NamedDecl *D); public: - ASTDeclReader(ASTReader &Reader, ModuleFile &F, DeclID thisDeclID, - unsigned RawLocation, const RecordData &Record, unsigned &Idx) - : Reader(Reader), F(F), ThisDeclID(thisDeclID), + ASTDeclReader(ASTReader &Reader, ASTReader::RecordLocation Loc, + DeclID thisDeclID, unsigned RawLocation, + const RecordData &Record, unsigned &Idx) + : Reader(Reader), F(*Loc.F), Offset(Loc.Offset), ThisDeclID(thisDeclID), RawLocation(RawLocation), Record(Record), Idx(Idx), TypeIDForTypeDecl(0), NamedDeclForTagDecl(0), TypedefNameForLinkage(nullptr), HasPendingBody(false) {} @@ -2224,6 +2226,9 @@ ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) { MergeWith = ReadDecl(Record, Idx/*, MergeWith*/); RedeclOffset = Record[Idx++]; + // RedeclOffset is a delta relative to the start of this record. + if (RedeclOffset) + RedeclOffset = Offset - RedeclOffset; } else { // This declaration was not the first local declaration. Read the first // local declaration now, to trigger the import of other redeclarations. @@ -3178,7 +3183,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) { RecordData Record; unsigned Code = DeclsCursor.ReadCode(); unsigned Idx = 0; - ASTDeclReader Reader(*this, *Loc.F, ID, RawLocation, Record,Idx); + ASTDeclReader Reader(*this, Loc, ID, RawLocation, Record,Idx); Decl *D = nullptr; switch ((DeclCode)DeclsCursor.readRecord(Code, Record)) { @@ -3471,7 +3476,8 @@ void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) { assert(RecCode == DECL_UPDATES && "Expected DECL_UPDATES record!"); unsigned Idx = 0; - ASTDeclReader Reader(*this, *F, ID, 0, Record, Idx); + ASTDeclReader Reader(*this, RecordLocation(F, Offset), ID, 0, Record, + Idx); Reader.UpdateDecl(D, *F, Record); // We might have made this declaration interesting. If so, remember that diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index 6c81b9e53c1..e22a94df2f3 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -1624,8 +1624,9 @@ void ASTDeclWriter::VisitRedeclarable(Redeclarable<T> *D) { if (LocalRedecls.empty()) Record.push_back(0); else { - Record.push_back(Writer.Stream.GetCurrentBitNo()); + auto Start = Writer.Stream.GetCurrentBitNo(); Writer.Stream.EmitRecord(LOCAL_REDECLARATIONS, LocalRedecls); + Record.push_back(Writer.Stream.GetCurrentBitNo() - Start); } } else { Record.push_back(0); |