diff options
-rw-r--r-- | llvm/lib/ProfileData/InstrProf.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index 22c04fbf58e..d74c51b2bbc 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/lib/ProfileData/InstrProf.cpp @@ -247,8 +247,9 @@ void ValueProfData::deserializeTo(InstrProfRecord &Record, std::unique_ptr<ValueProfData> ValueProfData::serializeFrom(const InstrProfRecord &Record) { uint32_t TotalSize = getSize(Record); - std::unique_ptr<ValueProfData> VPD( - reinterpret_cast<ValueProfData *>(new char[TotalSize])); + void *RawMem = ::operator new(TotalSize); + ValueProfData *VPDMem = new (RawMem) ValueProfData(); + std::unique_ptr<ValueProfData> VPD(VPDMem); VPD->TotalSize = TotalSize; VPD->NumValueKinds = Record.getNumValueKinds(); |