forked from OSchip/llvm-project
unique_ptrify the AllocValueProfData helper function introduced in r252783
llvm-svn: 252799
This commit is contained in:
parent
bdce12a01b
commit
1070a09f17
|
@ -244,17 +244,16 @@ void ValueProfData::deserializeTo(InstrProfRecord &Record,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ValueProfData *AllocValueProfData(uint32_t TotalSize) {
|
static std::unique_ptr<ValueProfData> AllocValueProfData(uint32_t TotalSize) {
|
||||||
void *RawMem = ::operator new(TotalSize);
|
return std::unique_ptr<ValueProfData>(new (::operator new(TotalSize))
|
||||||
ValueProfData *VPDMem = new (RawMem) ValueProfData();
|
ValueProfData());
|
||||||
return VPDMem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<ValueProfData>
|
std::unique_ptr<ValueProfData>
|
||||||
ValueProfData::serializeFrom(const InstrProfRecord &Record) {
|
ValueProfData::serializeFrom(const InstrProfRecord &Record) {
|
||||||
uint32_t TotalSize = getSize(Record);
|
uint32_t TotalSize = getSize(Record);
|
||||||
|
|
||||||
std::unique_ptr<ValueProfData> VPD(AllocValueProfData(TotalSize));
|
std::unique_ptr<ValueProfData> VPD = AllocValueProfData(TotalSize);
|
||||||
|
|
||||||
VPD->TotalSize = TotalSize;
|
VPD->TotalSize = TotalSize;
|
||||||
VPD->NumValueKinds = Record.getNumValueKinds();
|
VPD->NumValueKinds = Record.getNumValueKinds();
|
||||||
|
@ -290,7 +289,7 @@ ValueProfData::getValueProfData(const unsigned char *D,
|
||||||
if (TotalSize % sizeof(uint64_t))
|
if (TotalSize % sizeof(uint64_t))
|
||||||
return instrprof_error::malformed;
|
return instrprof_error::malformed;
|
||||||
|
|
||||||
std::unique_ptr<ValueProfData> VPD(AllocValueProfData(TotalSize));
|
std::unique_ptr<ValueProfData> VPD = AllocValueProfData(TotalSize);
|
||||||
|
|
||||||
memcpy(VPD.get(), D, TotalSize);
|
memcpy(VPD.get(), D, TotalSize);
|
||||||
// Byte swap.
|
// Byte swap.
|
||||||
|
|
Loading…
Reference in New Issue