Index: llvm/include/llvm/DebugInfo/MSF/MappedBlockStream.h =================================================================== --- llvm/include/llvm/DebugInfo/MSF/MappedBlockStream.h +++ llvm/include/llvm/DebugInfo/MSF/MappedBlockStream.h @@ -58,12 +58,12 @@ return support::little; } - Error readBytes(uint32_t Offset, uint32_t Size, + Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override; - Error readLongestContiguousChunk(uint32_t Offset, + Error readLongestContiguousChunk(uint64_t Offset, ArrayRef &Buffer) override; - uint32_t getLength() override; + uint64_t getLength() override; BumpPtrAllocator &getAllocator() { return Allocator; } @@ -79,10 +79,10 @@ private: const MSFStreamLayout &getStreamLayout() const { return StreamLayout; } - void fixCacheAfterWrite(uint32_t Offset, ArrayRef Data) const; + void fixCacheAfterWrite(uint64_t Offset, ArrayRef Data) const; - Error readBytes(uint32_t Offset, MutableArrayRef Buffer); - bool tryReadContiguously(uint32_t Offset, uint32_t Size, + Error readBytes(uint64_t Offset, MutableArrayRef Buffer); + bool tryReadContiguously(uint64_t Offset, uint64_t Size, ArrayRef &Buffer); const uint32_t BlockSize; @@ -125,13 +125,13 @@ return support::little; } - Error readBytes(uint32_t Offset, uint32_t Size, + Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override; - Error readLongestContiguousChunk(uint32_t Offset, + Error readLongestContiguousChunk(uint64_t Offset, ArrayRef &Buffer) override; - uint32_t getLength() override; + uint64_t getLength() override; - Error writeBytes(uint32_t Offset, ArrayRef Buffer) override; + Error writeBytes(uint64_t Offset, ArrayRef Buffer) override; Error commit() override; Index: llvm/include/llvm/Support/BinaryByteStream.h =================================================================== --- llvm/include/llvm/Support/BinaryByteStream.h +++ llvm/include/llvm/Support/BinaryByteStream.h @@ -38,7 +38,7 @@ llvm::support::endianness getEndian() const override { return Endian; } - Error readBytes(uint32_t Offset, uint32_t Size, + Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override { if (auto EC = checkOffsetForRead(Offset, Size)) return EC; @@ -46,7 +46,7 @@ return Error::success(); } - Error readLongestContiguousChunk(uint32_t Offset, + Error readLongestContiguousChunk(uint64_t Offset, ArrayRef &Buffer) override { if (auto EC = checkOffsetForRead(Offset, 1)) return EC; @@ -54,7 +54,7 @@ return Error::success(); } - uint32_t getLength() override { return Data.size(); } + uint64_t getLength() override { return Data.size(); } ArrayRef data() const { return Data; } @@ -97,19 +97,19 @@ return ImmutableStream.getEndian(); } - Error readBytes(uint32_t Offset, uint32_t Size, + Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override { return ImmutableStream.readBytes(Offset, Size, Buffer); } - Error readLongestContiguousChunk(uint32_t Offset, + Error readLongestContiguousChunk(uint64_t Offset, ArrayRef &Buffer) override { return ImmutableStream.readLongestContiguousChunk(Offset, Buffer); } - uint32_t getLength() override { return ImmutableStream.getLength(); } + uint64_t getLength() override { return ImmutableStream.getLength(); } - Error writeBytes(uint32_t Offset, ArrayRef Buffer) override { + Error writeBytes(uint64_t Offset, ArrayRef Buffer) override { if (Buffer.empty()) return Error::success(); @@ -145,7 +145,7 @@ llvm::support::endianness getEndian() const override { return Endian; } - Error readBytes(uint32_t Offset, uint32_t Size, + Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override { if (auto EC = checkOffsetForWrite(Offset, Buffer.size())) return EC; @@ -154,11 +154,11 @@ return Error::success(); } - void insert(uint32_t Offset, ArrayRef Bytes) { + void insert(uint64_t Offset, ArrayRef Bytes) { Data.insert(Data.begin() + Offset, Bytes.begin(), Bytes.end()); } - Error readLongestContiguousChunk(uint32_t Offset, + Error readLongestContiguousChunk(uint64_t Offset, ArrayRef &Buffer) override { if (auto EC = checkOffsetForWrite(Offset, 1)) return EC; @@ -167,9 +167,9 @@ return Error::success(); } - uint32_t getLength() override { return Data.size(); } + uint64_t getLength() override { return Data.size(); } - Error writeBytes(uint32_t Offset, ArrayRef Buffer) override { + Error writeBytes(uint64_t Offset, ArrayRef Buffer) override { if (Buffer.empty()) return Error::success(); @@ -182,7 +182,7 @@ if (Offset > getLength()) return make_error(stream_error_code::invalid_offset); - uint32_t RequiredSize = Offset + Buffer.size(); + uint64_t RequiredSize = Offset + Buffer.size(); if (RequiredSize > Data.size()) Data.resize(RequiredSize); @@ -240,19 +240,19 @@ return Impl.getEndian(); } - Error readBytes(uint32_t Offset, uint32_t Size, + Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override { return Impl.readBytes(Offset, Size, Buffer); } - Error readLongestContiguousChunk(uint32_t Offset, + Error readLongestContiguousChunk(uint64_t Offset, ArrayRef &Buffer) override { return Impl.readLongestContiguousChunk(Offset, Buffer); } - uint32_t getLength() override { return Impl.getLength(); } + uint64_t getLength() override { return Impl.getLength(); } - Error writeBytes(uint32_t Offset, ArrayRef Data) override { + Error writeBytes(uint64_t Offset, ArrayRef Data) override { return Impl.writeBytes(Offset, Data); } Index: llvm/include/llvm/Support/BinaryItemStream.h =================================================================== --- llvm/include/llvm/Support/BinaryItemStream.h +++ llvm/include/llvm/Support/BinaryItemStream.h @@ -38,7 +38,7 @@ llvm::support::endianness getEndian() const override { return Endian; } - Error readBytes(uint32_t Offset, uint32_t Size, + Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override { auto ExpectedIndex = translateOffsetIndex(Offset); if (!ExpectedIndex) @@ -52,7 +52,7 @@ return Error::success(); } - Error readLongestContiguousChunk(uint32_t Offset, + Error readLongestContiguousChunk(uint64_t Offset, ArrayRef &Buffer) override { auto ExpectedIndex = translateOffsetIndex(Offset); if (!ExpectedIndex) @@ -66,7 +66,7 @@ computeItemOffsets(); } - uint32_t getLength() override { + uint64_t getLength() override { return ItemEndOffsets.empty() ? 0 : ItemEndOffsets.back(); } @@ -74,16 +74,16 @@ void computeItemOffsets() { ItemEndOffsets.clear(); ItemEndOffsets.reserve(Items.size()); - uint32_t CurrentOffset = 0; + uint64_t CurrentOffset = 0; for (const auto &Item : Items) { - uint32_t Len = Traits::length(Item); + uint64_t Len = Traits::length(Item); assert(Len > 0 && "no empty items"); CurrentOffset += Len; ItemEndOffsets.push_back(CurrentOffset); } } - Expected translateOffsetIndex(uint32_t Offset) { + Expected translateOffsetIndex(uint64_t Offset) { // Make sure the offset is somewhere in our items array. if (Offset >= getLength()) return make_error(stream_error_code::stream_too_short); @@ -98,7 +98,7 @@ ArrayRef Items; // Sorted vector of offsets to accelerate lookup. - std::vector ItemEndOffsets; + std::vector ItemEndOffsets; }; } // end namespace llvm Index: llvm/include/llvm/Support/BinaryStream.h =================================================================== --- llvm/include/llvm/Support/BinaryStream.h +++ llvm/include/llvm/Support/BinaryStream.h @@ -41,22 +41,22 @@ /// Given an offset into the stream and a number of bytes, attempt to /// read the bytes and set the output ArrayRef to point to data owned by the /// stream. - virtual Error readBytes(uint32_t Offset, uint32_t Size, + virtual Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) = 0; /// Given an offset into the stream, read as much as possible without /// copying any data. - virtual Error readLongestContiguousChunk(uint32_t Offset, + virtual Error readLongestContiguousChunk(uint64_t Offset, ArrayRef &Buffer) = 0; /// Return the number of bytes of data in this stream. - virtual uint32_t getLength() = 0; + virtual uint64_t getLength() = 0; /// Return the properties of this stream. virtual BinaryStreamFlags getFlags() const { return BSF_None; } protected: - Error checkOffsetForRead(uint32_t Offset, uint32_t DataSize) { + Error checkOffsetForRead(uint64_t Offset, uint64_t DataSize) { if (Offset > getLength()) return make_error(stream_error_code::invalid_offset); if (getLength() < DataSize + Offset) @@ -77,7 +77,7 @@ /// Attempt to write the given bytes into the stream at the desired /// offset. This will always necessitate a copy. Cannot shrink or grow the /// stream, only writes into existing allocated space. - virtual Error writeBytes(uint32_t Offset, ArrayRef Data) = 0; + virtual Error writeBytes(uint64_t Offset, ArrayRef Data) = 0; /// For buffered streams, commits changes to the backing store. virtual Error commit() = 0; @@ -86,7 +86,7 @@ BinaryStreamFlags getFlags() const override { return BSF_Write; } protected: - Error checkOffsetForWrite(uint32_t Offset, uint32_t DataSize) { + Error checkOffsetForWrite(uint64_t Offset, uint64_t DataSize) { if (!(getFlags() & BSF_Append)) return checkOffsetForRead(Offset, DataSize); Index: llvm/include/llvm/Support/BinaryStreamReader.h =================================================================== --- llvm/include/llvm/Support/BinaryStreamReader.h +++ llvm/include/llvm/Support/BinaryStreamReader.h @@ -251,16 +251,16 @@ } bool empty() const { return bytesRemaining() == 0; } - void setOffset(uint32_t Off) { Offset = Off; } - uint32_t getOffset() const { return Offset; } - uint32_t getLength() const { return Stream.getLength(); } - uint32_t bytesRemaining() const { return getLength() - getOffset(); } + void setOffset(uint64_t Off) { Offset = Off; } + uint64_t getOffset() const { return Offset; } + uint64_t getLength() const { return Stream.getLength(); } + uint64_t bytesRemaining() const { return getLength() - getOffset(); } /// Advance the stream's offset by \p Amount bytes. /// /// \returns a success error code if at least \p Amount bytes remain in the /// stream, otherwise returns an appropriate error code. - Error skip(uint32_t Amount); + Error skip(uint64_t Amount); /// Examine the next byte of the underlying stream without advancing the /// stream's offset. If the stream is empty the behavior is undefined. @@ -271,11 +271,11 @@ Error padToAlignment(uint32_t Align); std::pair - split(uint32_t Offset) const; + split(uint64_t Offset) const; private: BinaryStreamRef Stream; - uint32_t Offset = 0; + uint64_t Offset = 0; }; } // namespace llvm Index: llvm/include/llvm/Support/BinaryStreamRef.h =================================================================== --- llvm/include/llvm/Support/BinaryStreamRef.h +++ llvm/include/llvm/Support/BinaryStreamRef.h @@ -30,12 +30,12 @@ Length = BorrowedImpl.getLength(); } - BinaryStreamRefBase(std::shared_ptr SharedImpl, uint32_t Offset, - Optional Length) + BinaryStreamRefBase(std::shared_ptr SharedImpl, uint64_t Offset, + Optional Length) : SharedImpl(SharedImpl), BorrowedImpl(SharedImpl.get()), ViewOffset(Offset), Length(Length) {} - BinaryStreamRefBase(StreamType &BorrowedImpl, uint32_t Offset, - Optional Length) + BinaryStreamRefBase(StreamType &BorrowedImpl, uint64_t Offset, + Optional Length) : BorrowedImpl(&BorrowedImpl), ViewOffset(Offset), Length(Length) {} BinaryStreamRefBase(const BinaryStreamRefBase &Other) = default; BinaryStreamRefBase &operator=(const BinaryStreamRefBase &Other) = default; @@ -48,7 +48,7 @@ return BorrowedImpl->getEndian(); } - uint32_t getLength() const { + uint64_t getLength() const { if (Length.hasValue()) return *Length; @@ -58,7 +58,7 @@ /// Return a new BinaryStreamRef with the first \p N elements removed. If /// this BinaryStreamRef is length-tracking, then the resulting one will be /// too. - RefType drop_front(uint32_t N) const { + RefType drop_front(uint64_t N) const { if (!BorrowedImpl) return RefType(); @@ -76,7 +76,7 @@ /// Return a new BinaryStreamRef with the last \p N elements removed. If /// this BinaryStreamRef is length-tracking and \p N is greater than 0, then /// this BinaryStreamRef will no longer length-track. - RefType drop_back(uint32_t N) const { + RefType drop_back(uint64_t N) const { if (!BorrowedImpl) return RefType(); @@ -96,26 +96,26 @@ } /// Return a new BinaryStreamRef with only the first \p N elements remaining. - RefType keep_front(uint32_t N) const { + RefType keep_front(uint64_t N) const { assert(N <= getLength()); return drop_back(getLength() - N); } /// Return a new BinaryStreamRef with only the last \p N elements remaining. - RefType keep_back(uint32_t N) const { + RefType keep_back(uint64_t N) const { assert(N <= getLength()); return drop_front(getLength() - N); } /// Return a new BinaryStreamRef with the first and last \p N elements /// removed. - RefType drop_symmetric(uint32_t N) const { + RefType drop_symmetric(uint64_t N) const { return drop_front(N).drop_back(N); } /// Return a new BinaryStreamRef with the first \p Offset elements removed, /// and retaining exactly \p Len elements. - RefType slice(uint32_t Offset, uint32_t Len) const { + RefType slice(uint64_t Offset, uint64_t Len) const { return drop_front(Offset).keep_front(Len); } @@ -132,7 +132,7 @@ } protected: - Error checkOffsetForRead(uint32_t Offset, uint32_t DataSize) const { + Error checkOffsetForRead(uint64_t Offset, uint64_t DataSize) const { if (Offset > getLength()) return make_error(stream_error_code::invalid_offset); if (getLength() < DataSize + Offset) @@ -142,8 +142,8 @@ std::shared_ptr SharedImpl; StreamType *BorrowedImpl = nullptr; - uint32_t ViewOffset = 0; - Optional Length; + uint64_t ViewOffset = 0; + Optional Length; }; /// BinaryStreamRef is to BinaryStream what ArrayRef is to an Array. It @@ -157,15 +157,15 @@ : public BinaryStreamRefBase { friend BinaryStreamRefBase; friend class WritableBinaryStreamRef; - BinaryStreamRef(std::shared_ptr Impl, uint32_t ViewOffset, - Optional Length) + BinaryStreamRef(std::shared_ptr Impl, uint64_t ViewOffset, + Optional Length) : BinaryStreamRefBase(Impl, ViewOffset, Length) {} public: BinaryStreamRef() = default; BinaryStreamRef(BinaryStream &Stream); - BinaryStreamRef(BinaryStream &Stream, uint32_t Offset, - Optional Length); + BinaryStreamRef(BinaryStream &Stream, uint64_t Offset, + Optional Length); explicit BinaryStreamRef(ArrayRef Data, llvm::support::endianness Endian); explicit BinaryStreamRef(StringRef Data, llvm::support::endianness Endian); @@ -176,8 +176,8 @@ BinaryStreamRef &operator=(BinaryStreamRef &&Other) = default; // Use BinaryStreamRef.slice() instead. - BinaryStreamRef(BinaryStreamRef &S, uint32_t Offset, - uint32_t Length) = delete; + BinaryStreamRef(BinaryStreamRef &S, uint64_t Offset, + uint64_t Length) = delete; /// Given an Offset into this StreamRef and a Size, return a reference to a /// buffer owned by the stream. @@ -185,7 +185,7 @@ /// \returns a success error code if the entire range of data is within the /// bounds of this BinaryStreamRef's view and the implementation could read /// the data, and an appropriate error code otherwise. - Error readBytes(uint32_t Offset, uint32_t Size, + Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) const; /// Given an Offset into this BinaryStreamRef, return a reference to the @@ -193,29 +193,28 @@ /// /// \returns a success error code if implementation could read the data, /// and an appropriate error code otherwise. - Error readLongestContiguousChunk(uint32_t Offset, + Error readLongestContiguousChunk(uint64_t Offset, ArrayRef &Buffer) const; }; struct BinarySubstreamRef { - uint32_t Offset = 0; // Offset in the parent stream + uint64_t Offset = 0; // Offset in the parent stream BinaryStreamRef StreamData; // Stream Data - BinarySubstreamRef slice(uint32_t Off, uint32_t Size) const { + BinarySubstreamRef slice(uint64_t Off, uint64_t Size) const { BinaryStreamRef SubSub = StreamData.slice(Off, Size); return {Off + Offset, SubSub}; } - BinarySubstreamRef drop_front(uint32_t N) const { + BinarySubstreamRef drop_front(uint64_t N) const { return slice(N, size() - N); } - BinarySubstreamRef keep_front(uint32_t N) const { return slice(0, N); } + BinarySubstreamRef keep_front(uint64_t N) const { return slice(0, N); } - std::pair - split(uint32_t Off) const { + std::pair split(uint64_t Off) const { return std::make_pair(keep_front(Off), drop_front(Off)); } - uint32_t size() const { return StreamData.getLength(); } + uint64_t size() const { return StreamData.getLength(); } bool empty() const { return size() == 0; } }; @@ -224,10 +223,10 @@ WritableBinaryStream> { friend BinaryStreamRefBase; WritableBinaryStreamRef(std::shared_ptr Impl, - uint32_t ViewOffset, Optional Length) + uint64_t ViewOffset, Optional Length) : BinaryStreamRefBase(Impl, ViewOffset, Length) {} - Error checkOffsetForWrite(uint32_t Offset, uint32_t DataSize) const { + Error checkOffsetForWrite(uint64_t Offset, uint64_t DataSize) const { if (!(BorrowedImpl->getFlags() & BSF_Append)) return checkOffsetForRead(Offset, DataSize); @@ -239,8 +238,8 @@ public: WritableBinaryStreamRef() = default; WritableBinaryStreamRef(WritableBinaryStream &Stream); - WritableBinaryStreamRef(WritableBinaryStream &Stream, uint32_t Offset, - Optional Length); + WritableBinaryStreamRef(WritableBinaryStream &Stream, uint64_t Offset, + Optional Length); explicit WritableBinaryStreamRef(MutableArrayRef Data, llvm::support::endianness Endian); WritableBinaryStreamRef(const WritableBinaryStreamRef &Other) = default; @@ -251,8 +250,8 @@ WritableBinaryStreamRef &operator=(WritableBinaryStreamRef &&Other) = default; // Use WritableBinaryStreamRef.slice() instead. - WritableBinaryStreamRef(WritableBinaryStreamRef &S, uint32_t Offset, - uint32_t Length) = delete; + WritableBinaryStreamRef(WritableBinaryStreamRef &S, uint64_t Offset, + uint64_t Length) = delete; /// Given an Offset into this WritableBinaryStreamRef and some input data, /// writes the data to the underlying stream. @@ -260,7 +259,7 @@ /// \returns a success error code if the data could fit within the underlying /// stream at the specified location and the implementation could write the /// data, and an appropriate error code otherwise. - Error writeBytes(uint32_t Offset, ArrayRef Data) const; + Error writeBytes(uint64_t Offset, ArrayRef Data) const; /// Conver this WritableBinaryStreamRef to a read-only BinaryStreamRef. operator BinaryStreamRef() const; Index: llvm/include/llvm/Support/BinaryStreamWriter.h =================================================================== --- llvm/include/llvm/Support/BinaryStreamWriter.h +++ llvm/include/llvm/Support/BinaryStreamWriter.h @@ -124,7 +124,7 @@ /// /// \returns a success error code if the data was successfully written, /// otherwise returns an appropriate error code. - Error writeStreamRef(BinaryStreamRef Ref, uint32_t Size); + Error writeStreamRef(BinaryStreamRef Ref, uint64_t Size); /// Writes the object \p Obj to the underlying stream, as if by using memcpy. /// It is up to the caller to ensure that type of \p Obj can be safely copied @@ -178,17 +178,17 @@ } /// Splits the Writer into two Writers at a given offset. - std::pair split(uint32_t Off) const; + std::pair split(uint64_t Off) const; - void setOffset(uint32_t Off) { Offset = Off; } - uint32_t getOffset() const { return Offset; } - uint32_t getLength() const { return Stream.getLength(); } - uint32_t bytesRemaining() const { return getLength() - getOffset(); } + void setOffset(uint64_t Off) { Offset = Off; } + uint64_t getOffset() const { return Offset; } + uint64_t getLength() const { return Stream.getLength(); } + uint64_t bytesRemaining() const { return getLength() - getOffset(); } Error padToAlignment(uint32_t Align); protected: WritableBinaryStreamRef Stream; - uint32_t Offset = 0; + uint64_t Offset = 0; }; } // end namespace llvm Index: llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp =================================================================== --- llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp +++ llvm/lib/DebugInfo/MSF/MappedBlockStream.cpp @@ -35,7 +35,7 @@ } // end anonymous namespace -using Interval = std::pair; +using Interval = std::pair; static Interval intersect(const Interval &I1, const Interval &I2) { return std::make_pair(std::max(I1.first, I2.first), @@ -85,7 +85,7 @@ return createStream(Layout.SB->BlockSize, SL, MsfData, Allocator); } -Error MappedBlockStream::readBytes(uint32_t Offset, uint32_t Size, +Error MappedBlockStream::readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) { // Make sure we aren't trying to read beyond the end of the stream. if (auto EC = checkOffsetForRead(Offset, Size)) @@ -138,7 +138,7 @@ if (Intersection != RequestExtent) continue; - uint32_t CacheRangeOffset = + uint64_t CacheRangeOffset = AbsoluteDifference(CachedExtent.first, Intersection.first); Buffer = CachedAlloc.slice(CacheRangeOffset, Size); return Error::success(); @@ -163,14 +163,14 @@ return Error::success(); } -Error MappedBlockStream::readLongestContiguousChunk(uint32_t Offset, +Error MappedBlockStream::readLongestContiguousChunk(uint64_t Offset, ArrayRef &Buffer) { // Make sure we aren't trying to read beyond the end of the stream. if (auto EC = checkOffsetForRead(Offset, 1)) return EC; - uint32_t First = Offset / BlockSize; - uint32_t Last = First; + uint64_t First = Offset / BlockSize; + uint64_t Last = First; while (Last < getNumBlocks() - 1) { if (StreamLayout.Blocks[Last] != StreamLayout.Blocks[Last + 1] - 1) @@ -178,13 +178,13 @@ ++Last; } - uint32_t OffsetInFirstBlock = Offset % BlockSize; - uint32_t BytesFromFirstBlock = BlockSize - OffsetInFirstBlock; - uint32_t BlockSpan = Last - First + 1; - uint32_t ByteSpan = BytesFromFirstBlock + (BlockSpan - 1) * BlockSize; + uint64_t OffsetInFirstBlock = Offset % BlockSize; + uint64_t BytesFromFirstBlock = BlockSize - OffsetInFirstBlock; + uint64_t BlockSpan = Last - First + 1; + uint64_t ByteSpan = BytesFromFirstBlock + (BlockSpan - 1) * BlockSize; ArrayRef BlockData; - uint32_t MsfOffset = blockToOffset(StreamLayout.Blocks[First], BlockSize); + uint64_t MsfOffset = blockToOffset(StreamLayout.Blocks[First], BlockSize); if (auto EC = MsfData.readBytes(MsfOffset, BlockSize, BlockData)) return EC; @@ -193,9 +193,9 @@ return Error::success(); } -uint32_t MappedBlockStream::getLength() { return StreamLayout.Length; } +uint64_t MappedBlockStream::getLength() { return StreamLayout.Length; } -bool MappedBlockStream::tryReadContiguously(uint32_t Offset, uint32_t Size, +bool MappedBlockStream::tryReadContiguously(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) { if (Size == 0) { Buffer = ArrayRef(); @@ -206,15 +206,15 @@ // all subsequent blocks are contiguous. For example, a 10k read with a 4k // block size can be filled with a reference if, from the starting offset, // 3 blocks in a row are contiguous. - uint32_t BlockNum = Offset / BlockSize; - uint32_t OffsetInBlock = Offset % BlockSize; - uint32_t BytesFromFirstBlock = std::min(Size, BlockSize - OffsetInBlock); - uint32_t NumAdditionalBlocks = + uint64_t BlockNum = Offset / BlockSize; + uint64_t OffsetInBlock = Offset % BlockSize; + uint64_t BytesFromFirstBlock = std::min(Size, BlockSize - OffsetInBlock); + uint64_t NumAdditionalBlocks = alignTo(Size - BytesFromFirstBlock, BlockSize) / BlockSize; - uint32_t RequiredContiguousBlocks = NumAdditionalBlocks + 1; - uint32_t E = StreamLayout.Blocks[BlockNum]; - for (uint32_t I = 0; I < RequiredContiguousBlocks; ++I, ++E) { + uint64_t RequiredContiguousBlocks = NumAdditionalBlocks + 1; + uint64_t E = StreamLayout.Blocks[BlockNum]; + for (uint64_t I = 0; I < RequiredContiguousBlocks; ++I, ++E) { if (StreamLayout.Blocks[I + BlockNum] != E) return false; } @@ -225,8 +225,8 @@ // cross-block span, explicitly resize the ArrayRef to cover the entire // request length. ArrayRef BlockData; - uint32_t FirstBlockAddr = StreamLayout.Blocks[BlockNum]; - uint32_t MsfOffset = blockToOffset(FirstBlockAddr, BlockSize); + uint64_t FirstBlockAddr = StreamLayout.Blocks[BlockNum]; + uint64_t MsfOffset = blockToOffset(FirstBlockAddr, BlockSize); if (auto EC = MsfData.readBytes(MsfOffset, BlockSize, BlockData)) { consumeError(std::move(EC)); return false; @@ -236,28 +236,28 @@ return true; } -Error MappedBlockStream::readBytes(uint32_t Offset, +Error MappedBlockStream::readBytes(uint64_t Offset, MutableArrayRef Buffer) { - uint32_t BlockNum = Offset / BlockSize; - uint32_t OffsetInBlock = Offset % BlockSize; + uint64_t BlockNum = Offset / BlockSize; + uint64_t OffsetInBlock = Offset % BlockSize; // Make sure we aren't trying to read beyond the end of the stream. if (auto EC = checkOffsetForRead(Offset, Buffer.size())) return EC; - uint32_t BytesLeft = Buffer.size(); - uint32_t BytesWritten = 0; + uint64_t BytesLeft = Buffer.size(); + uint64_t BytesWritten = 0; uint8_t *WriteBuffer = Buffer.data(); while (BytesLeft > 0) { - uint32_t StreamBlockAddr = StreamLayout.Blocks[BlockNum]; + uint64_t StreamBlockAddr = StreamLayout.Blocks[BlockNum]; ArrayRef BlockData; - uint32_t Offset = blockToOffset(StreamBlockAddr, BlockSize); + uint64_t Offset = blockToOffset(StreamBlockAddr, BlockSize); if (auto EC = MsfData.readBytes(Offset, BlockSize, BlockData)) return EC; const uint8_t *ChunkStart = BlockData.data() + OffsetInBlock; - uint32_t BytesInChunk = std::min(BytesLeft, BlockSize - OffsetInBlock); + uint64_t BytesInChunk = std::min(BytesLeft, BlockSize - OffsetInBlock); ::memcpy(WriteBuffer + BytesWritten, ChunkStart, BytesInChunk); BytesWritten += BytesInChunk; @@ -271,7 +271,7 @@ void MappedBlockStream::invalidateCache() { CacheMap.shrink_and_clear(); } -void MappedBlockStream::fixCacheAfterWrite(uint32_t Offset, +void MappedBlockStream::fixCacheAfterWrite(uint64_t Offset, ArrayRef Data) const { // If this write overlapped a read which previously came from the pool, // someone may still be holding a pointer to that alloc which is now invalid. @@ -297,10 +297,10 @@ auto Intersection = intersect(WriteInterval, CachedInterval); assert(Intersection.first <= Intersection.second); - uint32_t Length = Intersection.second - Intersection.first; - uint32_t SrcOffset = + uint64_t Length = Intersection.second - Intersection.first; + uint64_t SrcOffset = AbsoluteDifference(WriteInterval.first, Intersection.first); - uint32_t DestOffset = + uint64_t DestOffset = AbsoluteDifference(CachedInterval.first, Intersection.first); ::memcpy(Alloc.data() + DestOffset, Data.data() + SrcOffset, Length); } @@ -370,39 +370,39 @@ return createStream(Layout.SB->BlockSize, MinLayout, MsfData, Allocator); } -Error WritableMappedBlockStream::readBytes(uint32_t Offset, uint32_t Size, +Error WritableMappedBlockStream::readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) { return ReadInterface.readBytes(Offset, Size, Buffer); } Error WritableMappedBlockStream::readLongestContiguousChunk( - uint32_t Offset, ArrayRef &Buffer) { + uint64_t Offset, ArrayRef &Buffer) { return ReadInterface.readLongestContiguousChunk(Offset, Buffer); } -uint32_t WritableMappedBlockStream::getLength() { +uint64_t WritableMappedBlockStream::getLength() { return ReadInterface.getLength(); } -Error WritableMappedBlockStream::writeBytes(uint32_t Offset, +Error WritableMappedBlockStream::writeBytes(uint64_t Offset, ArrayRef Buffer) { // Make sure we aren't trying to write beyond the end of the stream. if (auto EC = checkOffsetForWrite(Offset, Buffer.size())) return EC; - uint32_t BlockNum = Offset / getBlockSize(); - uint32_t OffsetInBlock = Offset % getBlockSize(); + uint64_t BlockNum = Offset / getBlockSize(); + uint64_t OffsetInBlock = Offset % getBlockSize(); - uint32_t BytesLeft = Buffer.size(); - uint32_t BytesWritten = 0; + uint64_t BytesLeft = Buffer.size(); + uint64_t BytesWritten = 0; while (BytesLeft > 0) { - uint32_t StreamBlockAddr = getStreamLayout().Blocks[BlockNum]; - uint32_t BytesToWriteInChunk = + uint64_t StreamBlockAddr = getStreamLayout().Blocks[BlockNum]; + uint64_t BytesToWriteInChunk = std::min(BytesLeft, getBlockSize() - OffsetInBlock); const uint8_t *Chunk = Buffer.data() + BytesWritten; ArrayRef ChunkData(Chunk, BytesToWriteInChunk); - uint32_t MsfOffset = blockToOffset(StreamBlockAddr, getBlockSize()); + uint64_t MsfOffset = blockToOffset(StreamBlockAddr, getBlockSize()); MsfOffset += OffsetInBlock; if (auto EC = WriteInterface.writeBytes(MsfOffset, ChunkData)) return EC; Index: llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp =================================================================== --- llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp +++ llvm/lib/DebugInfo/PDB/Native/NativeEnumInjectedSources.cpp @@ -17,8 +17,8 @@ namespace { -Expected readStreamData(BinaryStream &Stream, uint32_t Limit) { - uint32_t Offset = 0, DataLength = std::min(Limit, Stream.getLength()); +Expected readStreamData(BinaryStream &Stream, uint64_t Limit) { + uint64_t Offset = 0, DataLength = std::min(Limit, Stream.getLength()); std::string Result; Result.reserve(DataLength); while (Offset < DataLength) { Index: llvm/lib/Support/BinaryStreamReader.cpp =================================================================== --- llvm/lib/Support/BinaryStreamReader.cpp +++ llvm/lib/Support/BinaryStreamReader.cpp @@ -72,10 +72,10 @@ } Error BinaryStreamReader::readCString(StringRef &Dest) { - uint32_t OriginalOffset = getOffset(); - uint32_t FoundOffset = 0; + uint64_t OriginalOffset = getOffset(); + uint64_t FoundOffset = 0; while (true) { - uint32_t ThisOffset = getOffset(); + uint64_t ThisOffset = getOffset(); ArrayRef Buffer; if (auto EC = readLongestContiguousChunk(Buffer)) return EC; @@ -100,8 +100,8 @@ } Error BinaryStreamReader::readWideString(ArrayRef &Dest) { - uint32_t Length = 0; - uint32_t OriginalOffset = getOffset(); + uint64_t Length = 0; + uint64_t OriginalOffset = getOffset(); const UTF16 *C; while (true) { if (auto EC = readObject(C)) @@ -110,7 +110,7 @@ break; ++Length; } - uint32_t NewOffset = getOffset(); + uint64_t NewOffset = getOffset(); setOffset(OriginalOffset); if (auto EC = readArray(Dest, Length)) @@ -145,7 +145,7 @@ return readStreamRef(Ref.StreamData, Length); } -Error BinaryStreamReader::skip(uint32_t Amount) { +Error BinaryStreamReader::skip(uint64_t Amount) { if (Amount > bytesRemaining()) return make_error(stream_error_code::stream_too_short); Offset += Amount; @@ -166,7 +166,7 @@ } std::pair -BinaryStreamReader::split(uint32_t Off) const { +BinaryStreamReader::split(uint64_t Off) const { assert(getLength() >= Off); BinaryStreamRef First = Stream.drop_front(Offset); Index: llvm/lib/Support/BinaryStreamRef.cpp =================================================================== --- llvm/lib/Support/BinaryStreamRef.cpp +++ llvm/lib/Support/BinaryStreamRef.cpp @@ -21,15 +21,15 @@ llvm::support::endianness getEndian() const override { return BBS.getEndian(); } - Error readBytes(uint32_t Offset, uint32_t Size, + Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override { return BBS.readBytes(Offset, Size, Buffer); } - Error readLongestContiguousChunk(uint32_t Offset, + Error readLongestContiguousChunk(uint64_t Offset, ArrayRef &Buffer) override { return BBS.readLongestContiguousChunk(Offset, Buffer); } - uint32_t getLength() override { return BBS.getLength(); } + uint64_t getLength() override { return BBS.getLength(); } private: BinaryByteStream BBS; @@ -44,17 +44,17 @@ llvm::support::endianness getEndian() const override { return BBS.getEndian(); } - Error readBytes(uint32_t Offset, uint32_t Size, + Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override { return BBS.readBytes(Offset, Size, Buffer); } - Error readLongestContiguousChunk(uint32_t Offset, + Error readLongestContiguousChunk(uint64_t Offset, ArrayRef &Buffer) override { return BBS.readLongestContiguousChunk(Offset, Buffer); } - uint32_t getLength() override { return BBS.getLength(); } + uint64_t getLength() override { return BBS.getLength(); } - Error writeBytes(uint32_t Offset, ArrayRef Data) override { + Error writeBytes(uint64_t Offset, ArrayRef Data) override { return BBS.writeBytes(Offset, Data); } Error commit() override { return BBS.commit(); } @@ -66,8 +66,8 @@ BinaryStreamRef::BinaryStreamRef(BinaryStream &Stream) : BinaryStreamRefBase(Stream) {} -BinaryStreamRef::BinaryStreamRef(BinaryStream &Stream, uint32_t Offset, - Optional Length) +BinaryStreamRef::BinaryStreamRef(BinaryStream &Stream, uint64_t Offset, + Optional Length) : BinaryStreamRefBase(Stream, Offset, Length) {} BinaryStreamRef::BinaryStreamRef(ArrayRef Data, endianness Endian) : BinaryStreamRefBase(std::make_shared(Data, Endian), 0, @@ -76,7 +76,7 @@ : BinaryStreamRef(makeArrayRef(Data.bytes_begin(), Data.bytes_end()), Endian) {} -Error BinaryStreamRef::readBytes(uint32_t Offset, uint32_t Size, +Error BinaryStreamRef::readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) const { if (auto EC = checkOffsetForRead(Offset, Size)) return EC; @@ -84,7 +84,7 @@ } Error BinaryStreamRef::readLongestContiguousChunk( - uint32_t Offset, ArrayRef &Buffer) const { + uint64_t Offset, ArrayRef &Buffer) const { if (auto EC = checkOffsetForRead(Offset, 1)) return EC; @@ -94,7 +94,7 @@ // This StreamRef might refer to a smaller window over a larger stream. In // that case we will have read out more bytes than we should return, because // we should not read past the end of the current view. - uint32_t MaxLength = getLength() - Offset; + uint64_t MaxLength = getLength() - Offset; if (Buffer.size() > MaxLength) Buffer = Buffer.slice(0, MaxLength); return Error::success(); @@ -104,8 +104,8 @@ : BinaryStreamRefBase(Stream) {} WritableBinaryStreamRef::WritableBinaryStreamRef(WritableBinaryStream &Stream, - uint32_t Offset, - Optional Length) + uint64_t Offset, + Optional Length) : BinaryStreamRefBase(Stream, Offset, Length) {} WritableBinaryStreamRef::WritableBinaryStreamRef(MutableArrayRef Data, @@ -113,8 +113,7 @@ : BinaryStreamRefBase(std::make_shared(Data, Endian), 0, Data.size()) {} - -Error WritableBinaryStreamRef::writeBytes(uint32_t Offset, +Error WritableBinaryStreamRef::writeBytes(uint64_t Offset, ArrayRef Data) const { if (auto EC = checkOffsetForWrite(Offset, Data.size())) return EC; Index: llvm/lib/Support/BinaryStreamWriter.cpp =================================================================== --- llvm/lib/Support/BinaryStreamWriter.cpp +++ llvm/lib/Support/BinaryStreamWriter.cpp @@ -62,7 +62,7 @@ return writeStreamRef(Ref, Ref.getLength()); } -Error BinaryStreamWriter::writeStreamRef(BinaryStreamRef Ref, uint32_t Length) { +Error BinaryStreamWriter::writeStreamRef(BinaryStreamRef Ref, uint64_t Length) { BinaryStreamReader SrcReader(Ref.slice(0, Length)); // This is a bit tricky. If we just call readBytes, we are requiring that it // return us the entire stream as a contiguous buffer. There is no guarantee @@ -80,7 +80,7 @@ } std::pair -BinaryStreamWriter::split(uint32_t Off) const { +BinaryStreamWriter::split(uint64_t Off) const { assert(getLength() >= Off); WritableBinaryStreamRef First = Stream.drop_front(Offset); @@ -93,7 +93,7 @@ } Error BinaryStreamWriter::padToAlignment(uint32_t Align) { - uint32_t NewOffset = alignTo(Offset, Align); + uint64_t NewOffset = alignTo(Offset, Align); if (NewOffset > getLength()) return make_error(stream_error_code::stream_too_short); while (Offset < NewOffset) Index: llvm/tools/llvm-pdbutil/LinePrinter.h =================================================================== --- llvm/tools/llvm-pdbutil/LinePrinter.h +++ llvm/tools/llvm-pdbutil/LinePrinter.h @@ -49,13 +49,13 @@ } void formatBinary(StringRef Label, ArrayRef Data, - uint32_t StartOffset); + uint64_t StartOffset); void formatBinary(StringRef Label, ArrayRef Data, uint64_t BaseAddr, - uint32_t StartOffset); + uint64_t StartOffset); void formatMsfStreamData(StringRef Label, PDBFile &File, uint32_t StreamIdx, - StringRef StreamPurpose, uint32_t Offset, - uint32_t Size); + StringRef StreamPurpose, uint64_t Offset, + uint64_t Size); void formatMsfStreamData(StringRef Label, PDBFile &File, const msf::MSFStreamLayout &Stream, BinarySubstreamRef Substream); @@ -66,7 +66,7 @@ int getIndentLevel() const { return CurrentIndent; } bool IsClassExcluded(const ClassLayout &Class); - bool IsTypeExcluded(llvm::StringRef TypeName, uint32_t Size); + bool IsTypeExcluded(llvm::StringRef TypeName, uint64_t Size); bool IsSymbolExcluded(llvm::StringRef SymbolName); bool IsCompilandExcluded(llvm::StringRef CompilandName); Index: llvm/tools/llvm-pdbutil/LinePrinter.cpp =================================================================== --- llvm/tools/llvm-pdbutil/LinePrinter.cpp +++ llvm/tools/llvm-pdbutil/LinePrinter.cpp @@ -100,7 +100,7 @@ } void LinePrinter::formatBinary(StringRef Label, ArrayRef Data, - uint32_t StartOffset) { + uint64_t StartOffset) { NewLine(); OS << Label << " ("; if (!Data.empty()) { @@ -113,7 +113,7 @@ } void LinePrinter::formatBinary(StringRef Label, ArrayRef Data, - uint64_t Base, uint32_t StartOffset) { + uint64_t Base, uint64_t StartOffset) { NewLine(); OS << Label << " ("; if (!Data.empty()) { @@ -131,7 +131,7 @@ Run() = default; explicit Run(uint32_t Block) : Block(Block) {} uint32_t Block = 0; - uint32_t ByteLen = 0; + uint64_t ByteLen = 0; }; } // namespace @@ -143,7 +143,7 @@ ArrayRef Blocks = Layout.Blocks; assert(!Blocks.empty()); - uint32_t StreamBytesRemaining = Layout.Length; + uint64_t StreamBytesRemaining = Layout.Length; uint32_t CurrentBlock = Blocks[0]; Runs.emplace_back(CurrentBlock); while (!Blocks.empty()) { @@ -153,7 +153,8 @@ Runs.emplace_back(NextBlock); CurrentRun = &Runs.back(); } - uint32_t Used = std::min(BlockSize, StreamBytesRemaining); + uint64_t Used = + std::min(static_cast(BlockSize), StreamBytesRemaining); CurrentRun->ByteLen += Used; StreamBytesRemaining -= Used; CurrentBlock = NextBlock; @@ -162,7 +163,7 @@ return Runs; } -static std::pair findRun(uint32_t Offset, ArrayRef Runs) { +static std::pair findRun(uint64_t Offset, ArrayRef Runs) { for (const auto &R : Runs) { if (Offset < R.ByteLen) return std::make_pair(R, Offset); @@ -173,8 +174,8 @@ void LinePrinter::formatMsfStreamData(StringRef Label, PDBFile &File, uint32_t StreamIdx, - StringRef StreamPurpose, uint32_t Offset, - uint32_t Size) { + StringRef StreamPurpose, uint64_t Offset, + uint64_t Size) { if (StreamIdx >= File.getNumStreams()) { formatLine("Stream {0}: Not present", StreamIdx); return; @@ -193,7 +194,7 @@ return; } - uint32_t End = + uint64_t End = (Size == 0) ? S->getLength() : std::min(Offset + Size, S->getLength()); Size = End - Offset; @@ -222,10 +223,10 @@ OS << "\n"; Run FoundRun; - uint32_t RunOffset; + uint64_t RunOffset; std::tie(FoundRun, RunOffset) = findRun(Substream.Offset, Runs); assert(FoundRun.ByteLen >= RunOffset); - uint32_t Len = FoundRun.ByteLen - RunOffset; + uint64_t Len = FoundRun.ByteLen - RunOffset; Len = std::min(Len, Reader.bytesRemaining()); uint64_t Base = FoundRun.Block * File.getBlockSize() + RunOffset; ArrayRef Data; @@ -246,13 +247,14 @@ void LinePrinter::formatMsfStreamBlocks( PDBFile &File, const msf::MSFStreamLayout &StreamLayout) { auto Blocks = makeArrayRef(StreamLayout.Blocks); - uint32_t L = StreamLayout.Length; + uint64_t L = StreamLayout.Length; while (L > 0) { NewLine(); assert(!Blocks.empty()); OS << formatv("Block {0} (\n", uint32_t(Blocks.front())); - uint32_t UsedBytes = std::min(L, File.getBlockSize()); + uint64_t UsedBytes = + std::min(L, static_cast(File.getBlockSize())); ArrayRef BlockData = cantFail(File.getBlockData(Blocks.front(), File.getBlockSize())); uint64_t BaseOffset = Blocks.front(); @@ -267,7 +269,7 @@ } } -bool LinePrinter::IsTypeExcluded(llvm::StringRef TypeName, uint32_t Size) { +bool LinePrinter::IsTypeExcluded(llvm::StringRef TypeName, uint64_t Size) { if (IsItemExcluded(TypeName, IncludeTypeFilters, ExcludeTypeFilters)) return true; if (Size < opts::pretty::SizeThreshold) Index: llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp =================================================================== --- llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp +++ llvm/unittests/DebugInfo/MSF/MappedBlockStreamTest.cpp @@ -36,7 +36,7 @@ endianness getEndian() const override { return little; } - Error readBytes(uint32_t Offset, uint32_t Size, + Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override { if (auto EC = checkOffsetForRead(Offset, Size)) return EC; @@ -44,7 +44,7 @@ return Error::success(); } - Error readLongestContiguousChunk(uint32_t Offset, + Error readLongestContiguousChunk(uint64_t Offset, ArrayRef &Buffer) override { if (auto EC = checkOffsetForRead(Offset, 1)) return EC; @@ -52,9 +52,9 @@ return Error::success(); } - uint32_t getLength() override { return Data.size(); } + uint64_t getLength() override { return Data.size(); } - Error writeBytes(uint32_t Offset, ArrayRef SrcData) override { + Error writeBytes(uint64_t Offset, ArrayRef SrcData) override { if (auto EC = checkOffsetForWrite(Offset, SrcData.size())) return EC; ::memcpy(&Data[Offset], SrcData.data(), SrcData.size()); Index: llvm/unittests/Support/BinaryStreamTest.cpp =================================================================== --- llvm/unittests/Support/BinaryStreamTest.cpp +++ llvm/unittests/Support/BinaryStreamTest.cpp @@ -25,25 +25,24 @@ class BrokenStream : public WritableBinaryStream { public: - BrokenStream(MutableArrayRef Data, endianness Endian, - uint32_t Align) + BrokenStream(MutableArrayRef Data, endianness Endian, uint32_t Align) : Data(Data), PartitionIndex(alignDown(Data.size() / 2, Align)), Endian(Endian) {} endianness getEndian() const override { return Endian; } - Error readBytes(uint32_t Offset, uint32_t Size, + Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef &Buffer) override { if (auto EC = checkOffsetForRead(Offset, Size)) return EC; - uint32_t S = startIndex(Offset); + uint64_t S = startIndex(Offset); auto Ref = Data.drop_front(S); if (Ref.size() >= Size) { Buffer = Ref.take_front(Size); return Error::success(); } - uint32_t BytesLeft = Size - Ref.size(); + uint64_t BytesLeft = Size - Ref.size(); uint8_t *Ptr = Allocator.Allocate(Size); ::memcpy(Ptr, Ref.data(), Ref.size()); ::memcpy(Ptr + Ref.size(), Data.data(), BytesLeft); @@ -51,24 +50,24 @@ return Error::success(); } - Error readLongestContiguousChunk(uint32_t Offset, + Error readLongestContiguousChunk(uint64_t Offset, ArrayRef &Buffer) override { if (auto EC = checkOffsetForRead(Offset, 1)) return EC; - uint32_t S = startIndex(Offset); + uint64_t S = startIndex(Offset); Buffer = Data.drop_front(S); return Error::success(); } - uint32_t getLength() override { return Data.size(); } + uint64_t getLength() override { return Data.size(); } - Error writeBytes(uint32_t Offset, ArrayRef SrcData) override { + Error writeBytes(uint64_t Offset, ArrayRef SrcData) override { if (auto EC = checkOffsetForWrite(Offset, SrcData.size())) return EC; if (SrcData.empty()) return Error::success(); - uint32_t S = startIndex(Offset); + uint64_t S = startIndex(Offset); MutableArrayRef Ref(Data); Ref = Ref.drop_front(S); if (Ref.size() >= SrcData.size()) { @@ -76,7 +75,7 @@ return Error::success(); } - uint32_t BytesLeft = SrcData.size() - Ref.size(); + uint64_t BytesLeft = SrcData.size() - Ref.size(); ::memcpy(Ref.data(), SrcData.data(), Ref.size()); ::memcpy(&Data[0], SrcData.data() + Ref.size(), BytesLeft); return Error::success(); @@ -84,11 +83,11 @@ Error commit() override { return Error::success(); } private: - uint32_t startIndex(uint32_t Offset) const { + uint64_t startIndex(uint64_t Offset) const { return (Offset + PartitionIndex) % Data.size(); } - uint32_t endIndex(uint32_t Offset, uint32_t Size) const { + uint64_t endIndex(uint64_t Offset, uint64_t Size) const { return (startIndex(Offset) + Size - 1) % Data.size(); } @@ -134,9 +133,9 @@ BrokenInputData.resize(InputData.size()); if (!Input.empty()) { - uint32_t PartitionIndex = alignDown(InputData.size() / 2, Align); - uint32_t RightBytes = InputData.size() - PartitionIndex; - uint32_t LeftBytes = PartitionIndex; + uint64_t PartitionIndex = alignDown(InputData.size() / 2, Align); + uint64_t RightBytes = InputData.size() - PartitionIndex; + uint64_t LeftBytes = PartitionIndex; if (RightBytes > 0) ::memcpy(&BrokenInputData[PartitionIndex], Input.data(), RightBytes); if (LeftBytes > 0) @@ -154,7 +153,7 @@ } } - void initializeOutput(uint32_t Size, uint32_t Align) { + void initializeOutput(uint64_t Size, uint32_t Align) { OutputData.resize(Size); BrokenOutputData.resize(Size); @@ -368,7 +367,7 @@ // from the middle. uint32_t Offsets[] = {0, 3}; for (auto Offset : Offsets) { - uint32_t ExpectedSize = Stream.Input->getLength() - Offset; + uint64_t ExpectedSize = Stream.Input->getLength() - Offset; // Read everything from Offset until the end of the input data. ArrayRef Data;