[clang] 870f158 - Revert "[clang][modules] Use relative offsets for input files"
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 24 14:43:30 PDT 2023
Author: Jan Svoboda
Date: 2023-08-24T14:43:23-07:00
New Revision: 870f1583eed0f22ddfb1a1979a90198c3dc09927
URL: https://github.com/llvm/llvm-project/commit/870f1583eed0f22ddfb1a1979a90198c3dc09927
DIFF: https://github.com/llvm/llvm-project/commit/870f1583eed0f22ddfb1a1979a90198c3dc09927.diff
LOG: Revert "[clang][modules] Use relative offsets for input files"
This reverts commit b9d78bdc730b2fcfe029a7579c24020536c3fa25. 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
Added:
Modified:
clang/include/clang/Serialization/ModuleFile.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Serialization/ModuleFile.h b/clang/include/clang/Serialization/ModuleFile.h
index 0af5cae6aebc37..8c4067853d6646 100644
--- a/clang/include/clang/Serialization/ModuleFile.h
+++ b/clang/include/clang/Serialization/ModuleFile.h
@@ -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.
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 82dac5fbfc888d..9491733d47df3d 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -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));
}
@@ -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));
}
@@ -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:
@@ -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;
@@ -5367,7 +5363,6 @@ bool ASTReader::readASTFileControlBlock(
if (NeedsInputFiles &&
ReadBlockAbbrevs(InputFilesCursor, INPUT_FILES_BLOCK_ID))
return true;
- InputFilesOffsetBase = InputFilesCursor.GetCurrentBitNo();
break;
default:
@@ -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));
}
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 2a12779b0d7d12..22420aab9ca08c 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -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;
@@ -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();
More information about the cfe-commits
mailing list