mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-03 11:24:18 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229483 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -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))
|
||||
|
Reference in New Issue
Block a user