Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/lib/Bitstream/Reader/BitstreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ Expected<unsigned> BitstreamCursor::readRecord(unsigned AbbrevID,

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me this raises a question of whether we want to support writing 4GB+ blobs in bitcode files. We could use ReadVBR64(6) above and EmitVBR64(6) on the writer side, and I think that would be backwards compatible, it just widens the maximum encodable value.

Copy link
Contributor

@mingmingl-llvm mingmingl-llvm Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change to {Read,Emit}VBR64(6) looks backward compatible to me as well, and https://llvm.org/docs/BitCodeFormat.html#define-abbrev-encoding needs an update around Blob (code 5): This field is emitted as a vbr6, followed by padding to a 32-bit boundary (for alignment) and an array of 8-bit objects It's not clear to me (from the doc and code comment around) how 32-bit alignment is related with value width (32 vs 64) and whether alignment needs an update for 4GB+ blobs.

If we decide not to support 4GB blob soon, I think emitting a release-build visible warning (e.g., by LLVMContext's diagnostic handler) when blob size is larger than 4GB around

EmitVBR(static_cast<uint32_t>(Bytes.size()), 6);
is generally a good change.

// Figure out where the end of this blob will be including tail padding.
size_t CurBitPos = GetCurrentBitNo();
const size_t NewEnd = CurBitPos + alignTo(NumElts, 4) * 8;
const size_t NewEnd =
CurBitPos + static_cast<uint64_t>(alignTo(NumElts, 4)) * 8;

// Make sure the bitstream is large enough to contain the blob.
if (!canSkipToPos(NewEnd/8))
Expand Down
Loading