diff options
author | Justin Bogner <mail@justinbogner.com> | 2015-02-16 23:31:07 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2015-02-16 23:31:07 +0000 |
commit | fcb2de694ae9d8c90f4f2b989d44a621e1c35a83 (patch) | |
tree | 0d6fa3b116ca4e8661d145e93edc1dd360e7f714 /llvm/lib | |
parent | f83e895fa79af04035916597204209112c8178c6 (diff) | |
download | bcm5719-llvm-fcb2de694ae9d8c90f4f2b989d44a621e1c35a83.tar.gz bcm5719-llvm-fcb2de694ae9d8c90f4f2b989d44a621e1c35a83.zip |
Revert "InstrProf: Add unit tests for the profile reader and writer"
Looks like the bots don't like my initializer lists.
This reverts r229455
llvm-svn: 229456
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/ProfileData/InstrProfReader.cpp | 29 | ||||
-rw-r--r-- | llvm/lib/ProfileData/InstrProfWriter.cpp | 30 |
2 files changed, 14 insertions, 45 deletions
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp index 01e199dcf0e..d13f27c3113 100644 --- a/llvm/lib/ProfileData/InstrProfReader.cpp +++ b/llvm/lib/ProfileData/InstrProfReader.cpp @@ -25,7 +25,12 @@ setupMemoryBuffer(std::string Path) { MemoryBuffer::getFileOrSTDIN(Path); if (std::error_code EC = BufferOrErr.getError()) return EC; - return std::move(BufferOrErr.get()); + auto Buffer = std::move(BufferOrErr.get()); + + // Sanity check the file. + if (Buffer->getBufferSize() > std::numeric_limits<unsigned>::max()) + return instrprof_error::too_large; + return std::move(Buffer); } static std::error_code initializeReader(InstrProfReader &Reader) { @@ -38,16 +43,10 @@ InstrProfReader::create(std::string Path) { auto BufferOrError = setupMemoryBuffer(Path); if (std::error_code EC = BufferOrError.getError()) return EC; - return InstrProfReader::create(std::move(BufferOrError.get())); -} - -ErrorOr<std::unique_ptr<InstrProfReader>> -InstrProfReader::create(std::unique_ptr<MemoryBuffer> Buffer) { - // Sanity check the buffer. - if (Buffer->getBufferSize() > std::numeric_limits<unsigned>::max()) - return instrprof_error::too_large; + auto Buffer = std::move(BufferOrError.get()); std::unique_ptr<InstrProfReader> Result; + // Create the reader. if (IndexedInstrProfReader::hasFormat(*Buffer)) Result.reset(new IndexedInstrProfReader(std::move(Buffer))); @@ -71,20 +70,14 @@ IndexedInstrProfReader::create(std::string Path) { auto BufferOrError = setupMemoryBuffer(Path); if (std::error_code EC = BufferOrError.getError()) return EC; - return IndexedInstrProfReader::create(std::move(BufferOrError.get())); -} - -ErrorOr<std::unique_ptr<IndexedInstrProfReader>> -IndexedInstrProfReader::create(std::unique_ptr<MemoryBuffer> Buffer) { - // Sanity check the buffer. - if (Buffer->getBufferSize() > std::numeric_limits<unsigned>::max()) - return instrprof_error::too_large; + auto Buffer = std::move(BufferOrError.get()); + std::unique_ptr<IndexedInstrProfReader> Result; // Create the reader. if (!IndexedInstrProfReader::hasFormat(*Buffer)) return instrprof_error::bad_magic; - auto Result = llvm::make_unique<IndexedInstrProfReader>(std::move(Buffer)); + Result.reset(new IndexedInstrProfReader(std::move(Buffer))); // Initialize the reader and return the result. if (std::error_code EC = initializeReader(*Result)) diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp index 2c72efe3faa..d4cde2e195d 100644 --- a/llvm/lib/ProfileData/InstrProfWriter.cpp +++ b/llvm/lib/ProfileData/InstrProfWriter.cpp @@ -106,7 +106,7 @@ InstrProfWriter::addFunctionCounts(StringRef FunctionName, return instrprof_error::success; } -std::pair<uint64_t, uint64_t> InstrProfWriter::writeImpl(raw_ostream &OS) { +void InstrProfWriter::write(raw_fd_ostream &OS) { OnDiskChainedHashTableGenerator<InstrProfRecordTrait> Generator; // Populate the hash table generator. @@ -128,31 +128,7 @@ std::pair<uint64_t, uint64_t> InstrProfWriter::writeImpl(raw_ostream &OS) { // Write the hash table. uint64_t HashTableStart = Generator.Emit(OS); - return std::make_pair(HashTableStartLoc, HashTableStart); -} - -void InstrProfWriter::write(raw_fd_ostream &OS) { - // Write the hash table. - auto TableStart = writeImpl(OS); - // Go back and fill in the hash table start. - using namespace support; - OS.seek(TableStart.first); - endian::Writer<little>(OS).write<uint64_t>(TableStart.second); -} - -std::string InstrProfWriter::writeString() { - std::string Result; - llvm::raw_string_ostream OS(Result); - // Write the hash table. - auto TableStart = writeImpl(OS); - OS.flush(); - - // Go back and fill in the hash table start. - using namespace support; - uint64_t Bytes = endian::byte_swap<uint64_t, little>(TableStart.second); - Result.replace(TableStart.first, sizeof(uint64_t), (const char *)&Bytes, - sizeof(uint64_t)); - - return Result; + OS.seek(HashTableStartLoc); + LE.write<uint64_t>(HashTableStart); } |