LLVM  14.0.0git
MappedBlockStream.cpp
Go to the documentation of this file.
1 //===- MappedBlockStream.cpp - Reads stream data from an MSF file ---------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #include "llvm/ADT/ArrayRef.h"
11 #include "llvm/ADT/STLExtras.h"
14 #include "llvm/Support/Endian.h"
15 #include "llvm/Support/Error.h"
17 #include <algorithm>
18 #include <cassert>
19 #include <cstdint>
20 #include <cstring>
21 #include <utility>
22 #include <vector>
23 
24 using namespace llvm;
25 using namespace llvm::msf;
26 
27 namespace {
28 
29 template <typename Base> class MappedBlockStreamImpl : public Base {
30 public:
31  template <typename... Args>
32  MappedBlockStreamImpl(Args &&... Params)
33  : Base(std::forward<Args>(Params)...) {}
34 };
35 
36 } // end anonymous namespace
37 
38 using Interval = std::pair<uint64_t, uint64_t>;
39 
40 static Interval intersect(const Interval &I1, const Interval &I2) {
41  return std::make_pair(std::max(I1.first, I2.first),
42  std::min(I1.second, I2.second));
43 }
44 
46  const MSFStreamLayout &Layout,
47  BinaryStreamRef MsfData,
49  : BlockSize(BlockSize), StreamLayout(Layout), MsfData(MsfData),
51 
52 std::unique_ptr<MappedBlockStream> MappedBlockStream::createStream(
53  uint32_t BlockSize, const MSFStreamLayout &Layout, BinaryStreamRef MsfData,
55  return std::make_unique<MappedBlockStreamImpl<MappedBlockStream>>(
56  BlockSize, Layout, MsfData, Allocator);
57 }
58 
59 std::unique_ptr<MappedBlockStream> MappedBlockStream::createIndexedStream(
60  const MSFLayout &Layout, BinaryStreamRef MsfData, uint32_t StreamIndex,
62  assert(StreamIndex < Layout.StreamMap.size() && "Invalid stream index");
63  MSFStreamLayout SL;
64  SL.Blocks = Layout.StreamMap[StreamIndex];
65  SL.Length = Layout.StreamSizes[StreamIndex];
66  return std::make_unique<MappedBlockStreamImpl<MappedBlockStream>>(
67  Layout.SB->BlockSize, SL, MsfData, Allocator);
68 }
69 
70 std::unique_ptr<MappedBlockStream>
72  BinaryStreamRef MsfData,
74  MSFStreamLayout SL;
75  SL.Blocks = Layout.DirectoryBlocks;
76  SL.Length = Layout.SB->NumDirectoryBytes;
77  return createStream(Layout.SB->BlockSize, SL, MsfData, Allocator);
78 }
79 
80 std::unique_ptr<MappedBlockStream>
82  BinaryStreamRef MsfData,
85  return createStream(Layout.SB->BlockSize, SL, MsfData, Allocator);
86 }
87 
89  ArrayRef<uint8_t> &Buffer) {
90  // Make sure we aren't trying to read beyond the end of the stream.
91  if (auto EC = checkOffsetForRead(Offset, Size))
92  return EC;
93 
94  if (tryReadContiguously(Offset, Size, Buffer))
95  return Error::success();
96 
97  auto CacheIter = CacheMap.find(Offset);
98  if (CacheIter != CacheMap.end()) {
99  // Try to find an alloc that was large enough for this request.
100  for (auto &Entry : CacheIter->second) {
101  if (Entry.size() >= Size) {
102  Buffer = Entry.slice(0, Size);
103  return Error::success();
104  }
105  }
106  }
107 
108  // We couldn't find a buffer that started at the correct offset (the most
109  // common scenario). Try to see if there is a buffer that starts at some
110  // other offset but overlaps the desired range.
111  for (auto &CacheItem : CacheMap) {
112  Interval RequestExtent = std::make_pair(Offset, Offset + Size);
113 
114  // We already checked this one on the fast path above.
115  if (CacheItem.first == Offset)
116  continue;
117  // If the initial extent of the cached item is beyond the ending extent
118  // of the request, there is no overlap.
119  if (CacheItem.first >= Offset + Size)
120  continue;
121 
122  // We really only have to check the last item in the list, since we append
123  // in order of increasing length.
124  if (CacheItem.second.empty())
125  continue;
126 
127  auto CachedAlloc = CacheItem.second.back();
128  // If the initial extent of the request is beyond the ending extent of
129  // the cached item, there is no overlap.
130  Interval CachedExtent =
131  std::make_pair(CacheItem.first, CacheItem.first + CachedAlloc.size());
132  if (RequestExtent.first >= CachedExtent.first + CachedExtent.second)
133  continue;
134 
135  Interval Intersection = intersect(CachedExtent, RequestExtent);
136  // Only use this if the entire request extent is contained in the cached
137  // extent.
138  if (Intersection != RequestExtent)
139  continue;
140 
141  uint64_t CacheRangeOffset =
142  AbsoluteDifference(CachedExtent.first, Intersection.first);
143  Buffer = CachedAlloc.slice(CacheRangeOffset, Size);
144  return Error::success();
145  }
146 
147  // Otherwise allocate a large enough buffer in the pool, memcpy the data
148  // into it, and return an ArrayRef to that. Do not touch existing pool
149  // allocations, as existing clients may be holding a pointer which must
150  // not be invalidated.
151  uint8_t *WriteBuffer = static_cast<uint8_t *>(Allocator.Allocate(Size, 8));
152  if (auto EC = readBytes(Offset, MutableArrayRef<uint8_t>(WriteBuffer, Size)))
153  return EC;
154 
155  if (CacheIter != CacheMap.end()) {
156  CacheIter->second.emplace_back(WriteBuffer, Size);
157  } else {
158  std::vector<CacheEntry> List;
159  List.emplace_back(WriteBuffer, Size);
160  CacheMap.insert(std::make_pair(Offset, List));
161  }
162  Buffer = ArrayRef<uint8_t>(WriteBuffer, Size);
163  return Error::success();
164 }
165 
167  ArrayRef<uint8_t> &Buffer) {
168  // Make sure we aren't trying to read beyond the end of the stream.
169  if (auto EC = checkOffsetForRead(Offset, 1))
170  return EC;
171 
172  uint64_t First = Offset / BlockSize;
173  uint64_t Last = First;
174 
175  while (Last < getNumBlocks() - 1) {
176  if (StreamLayout.Blocks[Last] != StreamLayout.Blocks[Last + 1] - 1)
177  break;
178  ++Last;
179  }
180 
181  uint64_t OffsetInFirstBlock = Offset % BlockSize;
182  uint64_t BytesFromFirstBlock = BlockSize - OffsetInFirstBlock;
183  uint64_t BlockSpan = Last - First + 1;
184  uint64_t ByteSpan = BytesFromFirstBlock + (BlockSpan - 1) * BlockSize;
185 
186  ArrayRef<uint8_t> BlockData;
187  uint64_t MsfOffset = blockToOffset(StreamLayout.Blocks[First], BlockSize);
188  if (auto EC = MsfData.readBytes(MsfOffset, BlockSize, BlockData))
189  return EC;
190 
191  BlockData = BlockData.drop_front(OffsetInFirstBlock);
192  Buffer = ArrayRef<uint8_t>(BlockData.data(), ByteSpan);
193  return Error::success();
194 }
195 
196 uint64_t MappedBlockStream::getLength() { return StreamLayout.Length; }
197 
198 bool MappedBlockStream::tryReadContiguously(uint64_t Offset, uint64_t Size,
199  ArrayRef<uint8_t> &Buffer) {
200  if (Size == 0) {
201  Buffer = ArrayRef<uint8_t>();
202  return true;
203  }
204  // Attempt to fulfill the request with a reference directly into the stream.
205  // This can work even if the request crosses a block boundary, provided that
206  // all subsequent blocks are contiguous. For example, a 10k read with a 4k
207  // block size can be filled with a reference if, from the starting offset,
208  // 3 blocks in a row are contiguous.
209  uint64_t BlockNum = Offset / BlockSize;
210  uint64_t OffsetInBlock = Offset % BlockSize;
211  uint64_t BytesFromFirstBlock = std::min(Size, BlockSize - OffsetInBlock);
212  uint64_t NumAdditionalBlocks =
213  alignTo(Size - BytesFromFirstBlock, BlockSize) / BlockSize;
214 
215  uint64_t RequiredContiguousBlocks = NumAdditionalBlocks + 1;
216  uint64_t E = StreamLayout.Blocks[BlockNum];
217  for (uint64_t I = 0; I < RequiredContiguousBlocks; ++I, ++E) {
218  if (StreamLayout.Blocks[I + BlockNum] != E)
219  return false;
220  }
221 
222  // Read out the entire block where the requested offset starts. Then drop
223  // bytes from the beginning so that the actual starting byte lines up with
224  // the requested starting byte. Then, since we know this is a contiguous
225  // cross-block span, explicitly resize the ArrayRef to cover the entire
226  // request length.
227  ArrayRef<uint8_t> BlockData;
228  uint64_t FirstBlockAddr = StreamLayout.Blocks[BlockNum];
229  uint64_t MsfOffset = blockToOffset(FirstBlockAddr, BlockSize);
230  if (auto EC = MsfData.readBytes(MsfOffset, BlockSize, BlockData)) {
231  consumeError(std::move(EC));
232  return false;
233  }
234  BlockData = BlockData.drop_front(OffsetInBlock);
235  Buffer = ArrayRef<uint8_t>(BlockData.data(), Size);
236  return true;
237 }
238 
240  MutableArrayRef<uint8_t> Buffer) {
241  uint64_t BlockNum = Offset / BlockSize;
242  uint64_t OffsetInBlock = Offset % BlockSize;
243 
244  // Make sure we aren't trying to read beyond the end of the stream.
245  if (auto EC = checkOffsetForRead(Offset, Buffer.size()))
246  return EC;
247 
248  uint64_t BytesLeft = Buffer.size();
249  uint64_t BytesWritten = 0;
250  uint8_t *WriteBuffer = Buffer.data();
251  while (BytesLeft > 0) {
252  uint64_t StreamBlockAddr = StreamLayout.Blocks[BlockNum];
253 
254  ArrayRef<uint8_t> BlockData;
255  uint64_t Offset = blockToOffset(StreamBlockAddr, BlockSize);
256  if (auto EC = MsfData.readBytes(Offset, BlockSize, BlockData))
257  return EC;
258 
259  const uint8_t *ChunkStart = BlockData.data() + OffsetInBlock;
260  uint64_t BytesInChunk = std::min(BytesLeft, BlockSize - OffsetInBlock);
261  ::memcpy(WriteBuffer + BytesWritten, ChunkStart, BytesInChunk);
262 
263  BytesWritten += BytesInChunk;
264  BytesLeft -= BytesInChunk;
265  ++BlockNum;
266  OffsetInBlock = 0;
267  }
268 
269  return Error::success();
270 }
271 
272 void MappedBlockStream::invalidateCache() { CacheMap.shrink_and_clear(); }
273 
274 void MappedBlockStream::fixCacheAfterWrite(uint64_t Offset,
275  ArrayRef<uint8_t> Data) const {
276  // If this write overlapped a read which previously came from the pool,
277  // someone may still be holding a pointer to that alloc which is now invalid.
278  // Compute the overlapping range and update the cache entry, so any
279  // outstanding buffers are automatically updated.
280  for (const auto &MapEntry : CacheMap) {
281  // If the end of the written extent precedes the beginning of the cached
282  // extent, ignore this map entry.
283  if (Offset + Data.size() < MapEntry.first)
284  continue;
285  for (const auto &Alloc : MapEntry.second) {
286  // If the end of the cached extent precedes the beginning of the written
287  // extent, ignore this alloc.
288  if (MapEntry.first + Alloc.size() < Offset)
289  continue;
290 
291  // If we get here, they are guaranteed to overlap.
292  Interval WriteInterval = std::make_pair(Offset, Offset + Data.size());
293  Interval CachedInterval =
294  std::make_pair(MapEntry.first, MapEntry.first + Alloc.size());
295  // If they overlap, we need to write the new data into the overlapping
296  // range.
297  auto Intersection = intersect(WriteInterval, CachedInterval);
298  assert(Intersection.first <= Intersection.second);
299 
300  uint64_t Length = Intersection.second - Intersection.first;
301  uint64_t SrcOffset =
302  AbsoluteDifference(WriteInterval.first, Intersection.first);
303  uint64_t DestOffset =
304  AbsoluteDifference(CachedInterval.first, Intersection.first);
305  ::memcpy(Alloc.data() + DestOffset, Data.data() + SrcOffset, Length);
306  }
307  }
308 }
309 
311  uint32_t BlockSize, const MSFStreamLayout &Layout,
313  : ReadInterface(BlockSize, Layout, MsfData, Allocator),
314  WriteInterface(MsfData) {}
315 
316 std::unique_ptr<WritableMappedBlockStream>
318  const MSFStreamLayout &Layout,
319  WritableBinaryStreamRef MsfData,
321  return std::make_unique<MappedBlockStreamImpl<WritableMappedBlockStream>>(
322  BlockSize, Layout, MsfData, Allocator);
323 }
324 
325 std::unique_ptr<WritableMappedBlockStream>
327  WritableBinaryStreamRef MsfData,
328  uint32_t StreamIndex,
330  assert(StreamIndex < Layout.StreamMap.size() && "Invalid stream index");
331  MSFStreamLayout SL;
332  SL.Blocks = Layout.StreamMap[StreamIndex];
333  SL.Length = Layout.StreamSizes[StreamIndex];
334  return createStream(Layout.SB->BlockSize, SL, MsfData, Allocator);
335 }
336 
337 std::unique_ptr<WritableMappedBlockStream>
339  const MSFLayout &Layout, WritableBinaryStreamRef MsfData,
341  MSFStreamLayout SL;
342  SL.Blocks = Layout.DirectoryBlocks;
343  SL.Length = Layout.SB->NumDirectoryBytes;
344  return createStream(Layout.SB->BlockSize, SL, MsfData, Allocator);
345 }
346 
347 std::unique_ptr<WritableMappedBlockStream>
349  WritableBinaryStreamRef MsfData,
351  bool AltFpm) {
352  // We only want to give the user a stream containing the bytes of the FPM that
353  // are actually valid, but we want to initialize all of the bytes, even those
354  // that come from reserved FPM blocks where the entire block is unused. To do
355  // this, we first create the full layout, which gives us a stream with all
356  // bytes and all blocks, and initialize everything to 0xFF (all blocks in the
357  // file are unused). Then we create the minimal layout (which contains only a
358  // subset of the bytes previously initialized), and return that to the user.
359  MSFStreamLayout MinLayout(getFpmStreamLayout(Layout, false, AltFpm));
360 
361  MSFStreamLayout FullLayout(getFpmStreamLayout(Layout, true, AltFpm));
362  auto Result =
363  createStream(Layout.SB->BlockSize, FullLayout, MsfData, Allocator);
364  if (!Result)
365  return Result;
366  std::vector<uint8_t> InitData(Layout.SB->BlockSize, 0xFF);
367  BinaryStreamWriter Initializer(*Result);
368  while (Initializer.bytesRemaining() > 0)
369  cantFail(Initializer.writeBytes(InitData));
370  return createStream(Layout.SB->BlockSize, MinLayout, MsfData, Allocator);
371 }
372 
374  ArrayRef<uint8_t> &Buffer) {
375  return ReadInterface.readBytes(Offset, Size, Buffer);
376 }
377 
379  uint64_t Offset, ArrayRef<uint8_t> &Buffer) {
380  return ReadInterface.readLongestContiguousChunk(Offset, Buffer);
381 }
382 
384  return ReadInterface.getLength();
385 }
386 
388  ArrayRef<uint8_t> Buffer) {
389  // Make sure we aren't trying to write beyond the end of the stream.
390  if (auto EC = checkOffsetForWrite(Offset, Buffer.size()))
391  return EC;
392 
393  uint64_t BlockNum = Offset / getBlockSize();
394  uint64_t OffsetInBlock = Offset % getBlockSize();
395 
396  uint64_t BytesLeft = Buffer.size();
397  uint64_t BytesWritten = 0;
398  while (BytesLeft > 0) {
399  uint64_t StreamBlockAddr = getStreamLayout().Blocks[BlockNum];
400  uint64_t BytesToWriteInChunk =
401  std::min(BytesLeft, getBlockSize() - OffsetInBlock);
402 
403  const uint8_t *Chunk = Buffer.data() + BytesWritten;
404  ArrayRef<uint8_t> ChunkData(Chunk, BytesToWriteInChunk);
405  uint64_t MsfOffset = blockToOffset(StreamBlockAddr, getBlockSize());
406  MsfOffset += OffsetInBlock;
407  if (auto EC = WriteInterface.writeBytes(MsfOffset, ChunkData))
408  return EC;
409 
410  BytesLeft -= BytesToWriteInChunk;
411  BytesWritten += BytesToWriteInChunk;
412  ++BlockNum;
413  OffsetInBlock = 0;
414  }
415 
416  ReadInterface.fixCacheAfterWrite(Offset, Buffer);
417 
418  return Error::success();
419 }
420 
421 Error WritableMappedBlockStream::commit() { return WriteInterface.commit(); }
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::alignTo
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:148
llvm::msf::WritableMappedBlockStream::readLongestContiguousChunk
Error readLongestContiguousChunk(uint64_t Offset, ArrayRef< uint8_t > &Buffer) override
Given an offset into the stream, read as much as possible without copying any data.
Definition: MappedBlockStream.cpp:378
llvm::msf::WritableMappedBlockStream::WritableMappedBlockStream
WritableMappedBlockStream(uint32_t BlockSize, const MSFStreamLayout &StreamLayout, WritableBinaryStreamRef MsfData, BumpPtrAllocator &Allocator)
Definition: MappedBlockStream.cpp:310
MathExtras.h
llvm::msf::MSFStreamLayout::Blocks
std::vector< support::ulittle32_t > Blocks
Definition: MSFCommon.h:80
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
BlockSize
static const int BlockSize
Definition: TarWriter.cpp:33
llvm::msf::MappedBlockStream::createDirectoryStream
static std::unique_ptr< MappedBlockStream > createDirectoryStream(const MSFLayout &Layout, BinaryStreamRef MsfData, BumpPtrAllocator &Allocator)
Definition: MappedBlockStream.cpp:71
llvm::msf::MSFLayout::DirectoryBlocks
ArrayRef< support::ulittle32_t > DirectoryBlocks
Definition: MSFCommon.h:66
llvm::msf::WritableMappedBlockStream::getLength
uint64_t getLength() override
Return the number of bytes of data in this stream.
Definition: MappedBlockStream.cpp:383
llvm::msf::WritableMappedBlockStream::getStreamLayout
const MSFStreamLayout & getStreamLayout() const
Definition: MappedBlockStream.h:138
llvm::BinaryStreamWriter
Provides write only access to a subclass of WritableBinaryStream.
Definition: BinaryStreamWriter.h:31
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::msf::SuperBlock::NumDirectoryBytes
support::ulittle32_t NumDirectoryBytes
Definition: MSFCommon.h:44
llvm::msf::blockToOffset
uint64_t blockToOffset(uint64_t BlockNumber, uint64_t BlockSize)
Definition: MSFCommon.h:112
Error.h
llvm::BinaryStream::checkOffsetForRead
Error checkOffsetForRead(uint64_t Offset, uint64_t DataSize)
Definition: BinaryStream.h:59
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
STLExtras.h
llvm::msf::getFpmStreamLayout
MSFStreamLayout getFpmStreamLayout(const MSFLayout &Msf, bool IncludeUnusedFpmData=false, bool AltFpm=false)
Determine the layout of the FPM stream, given the MSF layout.
Definition: MSFCommon.cpp:62
llvm::msf::MappedBlockStream::readBytes
Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef< uint8_t > &Buffer) override
Given an offset into the stream and a number of bytes, attempt to read the bytes and set the output A...
Definition: MappedBlockStream.cpp:88
llvm::WritableBinaryStreamRef::commit
Error commit()
For buffered streams, commits changes to the backing store.
Definition: BinaryStreamRef.cpp:129
llvm::consumeError
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:1035
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::msf
Definition: IMSFFile.h:18
llvm::ArrayRef::data
const T * data() const
Definition: ArrayRef.h:162
llvm::msf::MappedBlockStream::invalidateCache
void invalidateCache()
Definition: MappedBlockStream.cpp:272
llvm::msf::WritableMappedBlockStream::commit
Error commit() override
For buffered streams, commits changes to the backing store.
Definition: MappedBlockStream.cpp:421
llvm::MutableArrayRef< uint8_t >
llvm::BumpPtrAllocatorImpl::Allocate
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
Definition: Allocator.h:145
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::msf::WritableMappedBlockStream::createFpmStream
static std::unique_ptr< WritableMappedBlockStream > createFpmStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, BumpPtrAllocator &Allocator, bool AltFpm=false)
Definition: MappedBlockStream.cpp:348
llvm::msf::MSFLayout
Definition: MSFCommon.h:51
First
into llvm powi allowing the code generator to produce balanced multiplication trees First
Definition: README.txt:54
llvm::msf::WritableMappedBlockStream::createStream
static std::unique_ptr< WritableMappedBlockStream > createStream(uint32_t BlockSize, const MSFStreamLayout &Layout, WritableBinaryStreamRef MsfData, BumpPtrAllocator &Allocator)
Definition: MappedBlockStream.cpp:317
llvm::ArrayRef::slice
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Definition: ArrayRef.h:195
llvm::msf::WritableMappedBlockStream::readBytes
Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef< uint8_t > &Buffer) override
Given an offset into the stream and a number of bytes, attempt to read the bytes and set the output A...
Definition: MappedBlockStream.cpp:373
llvm::msf::MSFLayout::StreamSizes
ArrayRef< support::ulittle32_t > StreamSizes
Definition: MSFCommon.h:67
llvm::BinaryStreamWriter::bytesRemaining
uint64_t bytesRemaining() const
Definition: BinaryStreamWriter.h:186
llvm::ArrayRef::drop_front
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
Definition: ArrayRef.h:204
uint64_t
llvm::Interval
Interval Class - An Interval is a set of nodes defined such that every node in the interval has all o...
Definition: Interval.h:36
llvm::msf::WritableMappedBlockStream::createIndexedStream
static std::unique_ptr< WritableMappedBlockStream > createIndexedStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, uint32_t StreamIndex, BumpPtrAllocator &Allocator)
Definition: MappedBlockStream.cpp:326
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
llvm::msf::WritableMappedBlockStream::writeBytes
Error writeBytes(uint64_t Offset, ArrayRef< uint8_t > Buffer) override
Attempt to write the given bytes into the stream at the desired offset.
Definition: MappedBlockStream.cpp:387
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
I
#define I(x, y, z)
Definition: MD5.cpp:59
ArrayRef.h
MappedBlockStream.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
memcpy
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
llvm::codeview::CompileSym2Flags::EC
@ EC
llvm::msf::MappedBlockStream::getNumBlocks
uint32_t getNumBlocks() const
Definition: MappedBlockStream.h:73
llvm::ArrayRef< uint8_t >
llvm::min
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:357
llvm::BinaryStreamWriter::writeBytes
Error writeBytes(ArrayRef< uint8_t > Buffer)
Write the bytes specified in Buffer to the underlying stream.
Definition: BinaryStreamWriter.cpp:28
llvm::cantFail
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:737
uint32_t
MSFCommon.h
llvm::MutableArrayRef::data
T * data() const
Definition: ArrayRef.h:354
llvm::msf::MSFStreamLayout::Length
uint32_t Length
Definition: MSFCommon.h:79
std
Definition: BitVector.h:838
llvm::msf::SuperBlock::BlockSize
support::ulittle32_t BlockSize
Definition: MSFCommon.h:36
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::msf::MSFLayout::StreamMap
std::vector< ArrayRef< support::ulittle32_t > > StreamMap
Definition: MSFCommon.h:68
llvm::msf::MappedBlockStream::MappedBlockStream
MappedBlockStream(uint32_t BlockSize, const MSFStreamLayout &StreamLayout, BinaryStreamRef MsfData, BumpPtrAllocator &Allocator)
Definition: MappedBlockStream.cpp:45
intersect
static Interval intersect(const Interval &I1, const Interval &I2)
Definition: MappedBlockStream.cpp:40
llvm::WritableBinaryStreamRef::writeBytes
Error writeBytes(uint64_t Offset, ArrayRef< uint8_t > Data) const
Given an Offset into this WritableBinaryStreamRef and some input data, writes the data to the underly...
Definition: BinaryStreamRef.cpp:116
llvm::BinaryStreamRef::readBytes
Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef< uint8_t > &Buffer) const
Given an Offset into this StreamRef and a Size, return a reference to a buffer owned by the stream.
Definition: BinaryStreamRef.cpp:79
llvm::msf::MappedBlockStream::createIndexedStream
static std::unique_ptr< MappedBlockStream > createIndexedStream(const MSFLayout &Layout, BinaryStreamRef MsfData, uint32_t StreamIndex, BumpPtrAllocator &Allocator)
Definition: MappedBlockStream.cpp:59
llvm::msf::MappedBlockStream::createStream
static std::unique_ptr< MappedBlockStream > createStream(uint32_t BlockSize, const MSFStreamLayout &Layout, BinaryStreamRef MsfData, BumpPtrAllocator &Allocator)
Definition: MappedBlockStream.cpp:52
llvm::WritableBinaryStream::checkOffsetForWrite
Error checkOffsetForWrite(uint64_t Offset, uint64_t DataSize)
Definition: BinaryStream.h:89
Allocator
Basic Register Allocator
Definition: RegAllocBasic.cpp:146
List
const NodeList & List
Definition: RDFGraph.cpp:201
llvm::msf::MappedBlockStream::readLongestContiguousChunk
Error readLongestContiguousChunk(uint64_t Offset, ArrayRef< uint8_t > &Buffer) override
Given an offset into the stream, read as much as possible without copying any data.
Definition: MappedBlockStream.cpp:166
llvm::msf::WritableMappedBlockStream::createDirectoryStream
static std::unique_ptr< WritableMappedBlockStream > createDirectoryStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData, BumpPtrAllocator &Allocator)
Definition: MappedBlockStream.cpp:338
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:165
llvm::max
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:340
llvm::msf::MappedBlockStream::createFpmStream
static std::unique_ptr< MappedBlockStream > createFpmStream(const MSFLayout &Layout, BinaryStreamRef MsfData, BumpPtrAllocator &Allocator)
Definition: MappedBlockStream.cpp:81
llvm::msf::MSFLayout::SB
const SuperBlock * SB
Definition: MSFCommon.h:64
BinaryStreamWriter.h
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:389
Endian.h
llvm::msf::MappedBlockStream::getLength
uint64_t getLength() override
Return the number of bytes of data in this stream.
Definition: MappedBlockStream.cpp:196
llvm::WritableBinaryStreamRef
Definition: BinaryStreamRef.h:221
llvm::BinaryStreamRef
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Definition: BinaryStreamRef.h:156
llvm::sampleprof::Base
@ Base
Definition: Discriminator.h:58
llvm::AbsoluteDifference
std::enable_if_t< std::is_unsigned< T >::value, T > AbsoluteDifference(T X, T Y)
Subtract two unsigned integers, X and Y, of type T and return the absolute value of the result.
Definition: MathExtras.h:794
llvm::msf::WritableMappedBlockStream::getBlockSize
uint32_t getBlockSize() const
Definition: MappedBlockStream.h:142
llvm::msf::MSFStreamLayout
Describes the layout of a stream in an MSF layout.
Definition: MSFCommon.h:77