[x86] enable machine combiner reassociations for scalar 'and' insts
[oota-llvm.git] / lib / ProfileData / InstrProfWriter.cpp
index 2c72efe3faa92fcd79667e4fef38afdb449f8b07..2188543ed61c3002f93825dddca18940026b8534 100644 (file)
@@ -141,9 +141,9 @@ void InstrProfWriter::write(raw_fd_ostream &OS) {
   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();
@@ -151,8 +151,9 @@ std::string InstrProfWriter::writeString() {
   // 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);
 }