Skip to content

Commit

Permalink
Revert "[clang][modules] Use relative offsets for input files"
Browse files Browse the repository at this point in the history
This reverts commit b9d78bd. After this change, all libc++ `clang_modules_include.gen.py` tests started failing on Linux builders: https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-arm64/b8771862804321535569/test-results
  • Loading branch information
jansvoboda11 committed Aug 24, 2023
1 parent b6ba804 commit 870f158
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
5 changes: 1 addition & 4 deletions clang/include/clang/Serialization/ModuleFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,7 @@ class ModuleFile {
/// The cursor to the start of the input-files block.
llvm::BitstreamCursor InputFilesCursor;

/// Absolute offset of the start of the input-files block.
uint64_t InputFilesOffsetBase = 0;

/// Relative offsets for all of the input file entries in the AST file.
/// Offsets for all of the input file entries in the AST file.
const llvm::support::unaligned_uint64_t *InputFileOffsets = nullptr;

/// The input files that have been loaded from this AST file.
Expand Down
12 changes: 3 additions & 9 deletions clang/lib/Serialization/ASTReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2326,8 +2326,7 @@ InputFileInfo ASTReader::getInputFileInfo(ModuleFile &F, unsigned ID) {
// Go find this input file.
BitstreamCursor &Cursor = F.InputFilesCursor;
SavedStreamPosition SavedPosition(Cursor);
if (llvm::Error Err = Cursor.JumpToBit(F.InputFilesOffsetBase +
F.InputFileOffsets[ID - 1])) {
if (llvm::Error Err = Cursor.JumpToBit(F.InputFileOffsets[ID - 1])) {
// FIXME this drops errors on the floor.
consumeError(std::move(Err));
}
Expand Down Expand Up @@ -2411,8 +2410,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
// Go find this input file.
BitstreamCursor &Cursor = F.InputFilesCursor;
SavedStreamPosition SavedPosition(Cursor);
if (llvm::Error Err = Cursor.JumpToBit(F.InputFilesOffsetBase +
F.InputFileOffsets[ID - 1])) {
if (llvm::Error Err = Cursor.JumpToBit(F.InputFileOffsets[ID - 1])) {
// FIXME this drops errors on the floor.
consumeError(std::move(Err));
}
Expand Down Expand Up @@ -2790,7 +2788,6 @@ ASTReader::ReadControlBlock(ModuleFile &F,
Error("malformed block record in AST file");
return Failure;
}
F.InputFilesOffsetBase = F.InputFilesCursor.GetCurrentBitNo();
continue;

case OPTIONS_BLOCK_ID:
Expand Down Expand Up @@ -5331,7 +5328,6 @@ bool ASTReader::readASTFileControlBlock(
bool NeedsSystemInputFiles = Listener.needsSystemInputFileVisitation();
bool NeedsImports = Listener.needsImportVisitation();
BitstreamCursor InputFilesCursor;
uint64_t InputFilesOffsetBase = 0;

RecordData Record;
std::string ModuleDir;
Expand Down Expand Up @@ -5367,7 +5363,6 @@ bool ASTReader::readASTFileControlBlock(
if (NeedsInputFiles &&
ReadBlockAbbrevs(InputFilesCursor, INPUT_FILES_BLOCK_ID))
return true;
InputFilesOffsetBase = InputFilesCursor.GetCurrentBitNo();
break;

default:
Expand Down Expand Up @@ -5440,8 +5435,7 @@ bool ASTReader::readASTFileControlBlock(

BitstreamCursor &Cursor = InputFilesCursor;
SavedStreamPosition SavedPosition(Cursor);
if (llvm::Error Err =
Cursor.JumpToBit(InputFilesOffsetBase + InputFileOffs[I])) {
if (llvm::Error Err = Cursor.JumpToBit(InputFileOffs[I])) {
// FIXME this drops errors on the floor.
consumeError(std::move(Err));
}
Expand Down
4 changes: 1 addition & 3 deletions clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1570,8 +1570,6 @@ void ASTWriter::WriteInputFiles(SourceManager &SourceMgr,
IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
unsigned IFHAbbrevCode = Stream.EmitAbbrev(std::move(IFHAbbrev));

uint64_t InputFilesOffsetBase = Stream.GetCurrentBitNo();

// Get all ContentCache objects for files.
std::vector<InputFileEntry> UserFiles;
std::vector<InputFileEntry> SystemFiles;
Expand Down Expand Up @@ -1635,7 +1633,7 @@ void ASTWriter::WriteInputFiles(SourceManager &SourceMgr,
continue; // already recorded this file.

// Record this entry's offset.
InputFileOffsets.push_back(Stream.GetCurrentBitNo() - InputFilesOffsetBase);
InputFileOffsets.push_back(Stream.GetCurrentBitNo());

InputFileID = InputFileOffsets.size();

Expand Down

0 comments on commit 870f158

Please sign in to comment.