endian::Writer<little>(OS).write<uint64_t>(TableStart.second);
}
-std::string InstrProfWriter::writeString() {
- std::string Result;
- llvm::raw_string_ostream OS(Result);
+std::unique_ptr<MemoryBuffer> InstrProfWriter::writeBuffer() {
+ std::string Data;
+ llvm::raw_string_ostream OS(Data);
// 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));
+ Data.replace(TableStart.first, sizeof(uint64_t), (const char *)&Bytes,
+ sizeof(uint64_t));
- return Result;
+ // Return this in an aligned memory buffer.
+ return MemoryBuffer::getMemBufferCopy(Data);
}