llvm.org GIT mirror llvm / 254d549
[Profile] Support raw/indexed profiles larger than 4GB rdar://45955976 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365565 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 3 months ago
2 changed file(s) with 23 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
6161 Expected>
6262 InstrProfReader::create(std::unique_ptr Buffer) {
6363 // Sanity check the buffer.
64 if (uint64_t(Buffer->getBufferSize()) > std::numeric_limitsnsigned>::max())
64 if (uint64_t(Buffer->getBufferSize()) > std::numeric_limitsint64_t>::max())
6565 return make_error(instrprof_error::too_large);
6666
6767 if (Buffer->getBufferSize() == 0)
112112 IndexedInstrProfReader::create(std::unique_ptr Buffer,
113113 std::unique_ptr RemappingBuffer) {
114114 // Sanity check the buffer.
115 if (uint64_t(Buffer->getBufferSize()) > std::numeric_limitsnsigned>::max())
115 if (uint64_t(Buffer->getBufferSize()) > std::numeric_limitsint64_t>::max())
116116 return make_error(instrprof_error::too_large);
117117
118118 // Create the reader.
10431043 INSTANTIATE_TEST_CASE_P(MaybeSparse, MaybeSparseInstrProfTest,
10441044 ::testing::Bool(),);
10451045
1046 #if defined(_LP64) && defined(EXPENSIVE_CHECKS)
1047 TEST(ProfileReaderTest, ReadsLargeFiles) {
1048 const size_t LargeSize = 1ULL << 32; // 4GB
1049
1050 auto RawProfile = WritableMemoryBuffer::getNewUninitMemBuffer(LargeSize);
1051 if (!RawProfile)
1052 return;
1053 auto RawProfileReaderOrErr = InstrProfReader::create(std::move(RawProfile));
1054 ASSERT_TRUE(InstrProfError::take(RawProfileReaderOrErr.takeError()) ==
1055 instrprof_error::unrecognized_format);
1056
1057 auto IndexedProfile = WritableMemoryBuffer::getNewUninitMemBuffer(LargeSize);
1058 if (!IndexedProfile)
1059 return;
1060 auto IndexedReaderOrErr =
1061 IndexedInstrProfReader::create(std::move(IndexedProfile), nullptr);
1062 ASSERT_TRUE(InstrProfError::take(IndexedReaderOrErr.takeError()) ==
1063 instrprof_error::bad_magic);
1064 }
1065 #endif
1066
10461067 } // end anonymous namespace