Skip to content

Commit 870f158

Browse files
committed
Revert "[clang][modules] Use relative offsets for input files"
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
1 parent b6ba804 commit 870f158

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

clang/include/clang/Serialization/ModuleFile.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,7 @@ class ModuleFile {
245245
/// The cursor to the start of the input-files block.
246246
llvm::BitstreamCursor InputFilesCursor;
247247

248-
/// Absolute offset of the start of the input-files block.
249-
uint64_t InputFilesOffsetBase = 0;
250-
251-
/// Relative offsets for all of the input file entries in the AST file.
248+
/// Offsets for all of the input file entries in the AST file.
252249
const llvm::support::unaligned_uint64_t *InputFileOffsets = nullptr;
253250

254251
/// The input files that have been loaded from this AST file.

clang/lib/Serialization/ASTReader.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,8 +2326,7 @@ InputFileInfo ASTReader::getInputFileInfo(ModuleFile &F, unsigned ID) {
23262326
// Go find this input file.
23272327
BitstreamCursor &Cursor = F.InputFilesCursor;
23282328
SavedStreamPosition SavedPosition(Cursor);
2329-
if (llvm::Error Err = Cursor.JumpToBit(F.InputFilesOffsetBase +
2330-
F.InputFileOffsets[ID - 1])) {
2329+
if (llvm::Error Err = Cursor.JumpToBit(F.InputFileOffsets[ID - 1])) {
23312330
// FIXME this drops errors on the floor.
23322331
consumeError(std::move(Err));
23332332
}
@@ -2411,8 +2410,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
24112410
// Go find this input file.
24122411
BitstreamCursor &Cursor = F.InputFilesCursor;
24132412
SavedStreamPosition SavedPosition(Cursor);
2414-
if (llvm::Error Err = Cursor.JumpToBit(F.InputFilesOffsetBase +
2415-
F.InputFileOffsets[ID - 1])) {
2413+
if (llvm::Error Err = Cursor.JumpToBit(F.InputFileOffsets[ID - 1])) {
24162414
// FIXME this drops errors on the floor.
24172415
consumeError(std::move(Err));
24182416
}
@@ -2790,7 +2788,6 @@ ASTReader::ReadControlBlock(ModuleFile &F,
27902788
Error("malformed block record in AST file");
27912789
return Failure;
27922790
}
2793-
F.InputFilesOffsetBase = F.InputFilesCursor.GetCurrentBitNo();
27942791
continue;
27952792

27962793
case OPTIONS_BLOCK_ID:
@@ -5331,7 +5328,6 @@ bool ASTReader::readASTFileControlBlock(
53315328
bool NeedsSystemInputFiles = Listener.needsSystemInputFileVisitation();
53325329
bool NeedsImports = Listener.needsImportVisitation();
53335330
BitstreamCursor InputFilesCursor;
5334-
uint64_t InputFilesOffsetBase = 0;
53355331

53365332
RecordData Record;
53375333
std::string ModuleDir;
@@ -5367,7 +5363,6 @@ bool ASTReader::readASTFileControlBlock(
53675363
if (NeedsInputFiles &&
53685364
ReadBlockAbbrevs(InputFilesCursor, INPUT_FILES_BLOCK_ID))
53695365
return true;
5370-
InputFilesOffsetBase = InputFilesCursor.GetCurrentBitNo();
53715366
break;
53725367

53735368
default:
@@ -5440,8 +5435,7 @@ bool ASTReader::readASTFileControlBlock(
54405435

54415436
BitstreamCursor &Cursor = InputFilesCursor;
54425437
SavedStreamPosition SavedPosition(Cursor);
5443-
if (llvm::Error Err =
5444-
Cursor.JumpToBit(InputFilesOffsetBase + InputFileOffs[I])) {
5438+
if (llvm::Error Err = Cursor.JumpToBit(InputFileOffs[I])) {
54455439
// FIXME this drops errors on the floor.
54465440
consumeError(std::move(Err));
54475441
}

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,8 +1570,6 @@ void ASTWriter::WriteInputFiles(SourceManager &SourceMgr,
15701570
IFHAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
15711571
unsigned IFHAbbrevCode = Stream.EmitAbbrev(std::move(IFHAbbrev));
15721572

1573-
uint64_t InputFilesOffsetBase = Stream.GetCurrentBitNo();
1574-
15751573
// Get all ContentCache objects for files.
15761574
std::vector<InputFileEntry> UserFiles;
15771575
std::vector<InputFileEntry> SystemFiles;
@@ -1635,7 +1633,7 @@ void ASTWriter::WriteInputFiles(SourceManager &SourceMgr,
16351633
continue; // already recorded this file.
16361634

16371635
// Record this entry's offset.
1638-
InputFileOffsets.push_back(Stream.GetCurrentBitNo() - InputFilesOffsetBase);
1636+
InputFileOffsets.push_back(Stream.GetCurrentBitNo());
16391637

16401638
InputFileID = InputFileOffsets.size();
16411639

0 commit comments

Comments
 (0)