[llvm] r365565 - [Profile] Support raw/indexed profiles larger than 4GB
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 9 15:01:05 PDT 2019
Author: vedantk
Date: Tue Jul 9 15:01:04 2019
New Revision: 365565
URL: http://llvm.org/viewvc/llvm-project?rev=365565&view=rev
Log:
[Profile] Support raw/indexed profiles larger than 4GB
rdar://45955976
Modified:
llvm/trunk/lib/ProfileData/InstrProfReader.cpp
llvm/trunk/unittests/ProfileData/InstrProfTest.cpp
Modified: llvm/trunk/lib/ProfileData/InstrProfReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProfReader.cpp?rev=365565&r1=365564&r2=365565&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProfReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProfReader.cpp Tue Jul 9 15:01:04 2019
@@ -62,7 +62,7 @@ InstrProfReader::create(const Twine &Pat
Expected<std::unique_ptr<InstrProfReader>>
InstrProfReader::create(std::unique_ptr<MemoryBuffer> Buffer) {
// Sanity check the buffer.
- if (uint64_t(Buffer->getBufferSize()) > std::numeric_limits<unsigned>::max())
+ if (uint64_t(Buffer->getBufferSize()) > std::numeric_limits<uint64_t>::max())
return make_error<InstrProfError>(instrprof_error::too_large);
if (Buffer->getBufferSize() == 0)
@@ -113,7 +113,7 @@ Expected<std::unique_ptr<IndexedInstrPro
IndexedInstrProfReader::create(std::unique_ptr<MemoryBuffer> Buffer,
std::unique_ptr<MemoryBuffer> RemappingBuffer) {
// Sanity check the buffer.
- if (uint64_t(Buffer->getBufferSize()) > std::numeric_limits<unsigned>::max())
+ if (uint64_t(Buffer->getBufferSize()) > std::numeric_limits<uint64_t>::max())
return make_error<InstrProfError>(instrprof_error::too_large);
// Create the reader.
Modified: llvm/trunk/unittests/ProfileData/InstrProfTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/InstrProfTest.cpp?rev=365565&r1=365564&r2=365565&view=diff
==============================================================================
--- llvm/trunk/unittests/ProfileData/InstrProfTest.cpp (original)
+++ llvm/trunk/unittests/ProfileData/InstrProfTest.cpp Tue Jul 9 15:01:04 2019
@@ -1044,4 +1044,25 @@ TEST_F(SparseInstrProfTest, preserve_no_
INSTANTIATE_TEST_CASE_P(MaybeSparse, MaybeSparseInstrProfTest,
::testing::Bool(),);
+#if defined(_LP64) && defined(EXPENSIVE_CHECKS)
+TEST(ProfileReaderTest, ReadsLargeFiles) {
+ const size_t LargeSize = 1ULL << 32; // 4GB
+
+ auto RawProfile = WritableMemoryBuffer::getNewUninitMemBuffer(LargeSize);
+ if (!RawProfile)
+ return;
+ auto RawProfileReaderOrErr = InstrProfReader::create(std::move(RawProfile));
+ ASSERT_TRUE(InstrProfError::take(RawProfileReaderOrErr.takeError()) ==
+ instrprof_error::unrecognized_format);
+
+ auto IndexedProfile = WritableMemoryBuffer::getNewUninitMemBuffer(LargeSize);
+ if (!IndexedProfile)
+ return;
+ auto IndexedReaderOrErr =
+ IndexedInstrProfReader::create(std::move(IndexedProfile), nullptr);
+ ASSERT_TRUE(InstrProfError::take(IndexedReaderOrErr.takeError()) ==
+ instrprof_error::bad_magic);
+}
+#endif
+
} // end anonymous namespace
More information about the llvm-commits
mailing list