summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2015-02-17 09:21:43 +0000
committerJustin Bogner <mail@justinbogner.com>2015-02-17 09:21:43 +0000
commit5b3ad88646df937ab5d45593fdfe2132eacc441e (patch)
tree1b7ed0ea0de6cc39f81cbaf3aa8c4e76438dd08c /llvm/lib
parentba8467251994e318dee34f48e00728b47fef9285 (diff)
downloadbcm5719-llvm-5b3ad88646df937ab5d45593fdfe2132eacc441e.tar.gz
bcm5719-llvm-5b3ad88646df937ab5d45593fdfe2132eacc441e.zip
Revert "InstrProf: Add unit tests for the profile reader and writer"
This added API to the InstrProfWriter to write to a string so I could write unittests without using temp files. This doesn't really work, since the format has tighter alignment requirements than a char. This reverts r229478 and its follow-up, r229481. llvm-svn: 229483
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ProfileData/InstrProfReader.cpp29
-rw-r--r--llvm/lib/ProfileData/InstrProfWriter.cpp30
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);
}
OpenPOWER on IntegriCloud