[ProfileData] Thread unique_ptr through the summary builder to avoid leaks.

llvm-svn: 270195
This commit is contained in:
Benjamin Kramer 2016-05-20 09:18:37 +00:00
parent 18d682df79
commit a123062071
6 changed files with 14 additions and 14 deletions

View File

@ -74,7 +74,7 @@ public:
InstrProfSummaryBuilder(std::vector<uint32_t> Cutoffs)
: ProfileSummaryBuilder(Cutoffs), MaxInternalBlockCount(0) {}
void addRecord(const InstrProfRecord &);
ProfileSummary *getSummary();
std::unique_ptr<ProfileSummary> getSummary();
};
class SampleProfileSummaryBuilder final : public ProfileSummaryBuilder {
@ -83,7 +83,7 @@ public:
void addRecord(const sampleprof::FunctionSamples &FS);
SampleProfileSummaryBuilder(std::vector<uint32_t> Cutoffs)
: ProfileSummaryBuilder(Cutoffs) {}
ProfileSummary *getSummary();
std::unique_ptr<ProfileSummary> getSummary();
};
// This is called when a count is seen in the profile.

View File

@ -617,7 +617,7 @@ IndexedInstrProfReader::readSummary(IndexedInstrProf::ProfVersion Version,
InstrProfSummaryBuilder Builder(ProfileSummaryBuilder::DefaultCutoffs);
// FIXME: This only computes an empty summary. Need to call addRecord for
// all InstrProfRecords to get the correct summary.
this->Summary.reset(Builder.getSummary());
this->Summary = Builder.getSummary();
return Cur;
}
}

View File

@ -259,7 +259,7 @@ void InstrProfWriter::writeImpl(ProfOStream &OS) {
IndexedInstrProf::allocSummary(SummarySize);
// Compute the Summary and copy the data to the data
// structure to be serialized out (to disk or buffer).
ProfileSummary *PS = ISB.getSummary();
std::unique_ptr<ProfileSummary> PS = ISB.getSummary();
setSummary(TheSummary.get(), *PS);
InfoObj->SummaryBuilder = 0;

View File

@ -86,18 +86,18 @@ void ProfileSummaryBuilder::computeDetailedSummary() {
}
}
ProfileSummary *SampleProfileSummaryBuilder::getSummary() {
std::unique_ptr<ProfileSummary> SampleProfileSummaryBuilder::getSummary() {
computeDetailedSummary();
return new ProfileSummary(ProfileSummary::PSK_Sample, DetailedSummary,
TotalCount, MaxCount, 0, MaxFunctionCount,
NumCounts, NumFunctions);
return llvm::make_unique<ProfileSummary>(
ProfileSummary::PSK_Sample, DetailedSummary, TotalCount, MaxCount, 0,
MaxFunctionCount, NumCounts, NumFunctions);
}
ProfileSummary *InstrProfSummaryBuilder::getSummary() {
std::unique_ptr<ProfileSummary> InstrProfSummaryBuilder::getSummary() {
computeDetailedSummary();
return new ProfileSummary(ProfileSummary::PSK_Instr, DetailedSummary,
TotalCount, MaxCount, MaxInternalBlockCount,
MaxFunctionCount, NumCounts, NumFunctions);
return llvm::make_unique<ProfileSummary>(
ProfileSummary::PSK_Instr, DetailedSummary, TotalCount, MaxCount,
MaxInternalBlockCount, MaxFunctionCount, NumCounts, NumFunctions);
}
void InstrProfSummaryBuilder::addEntryCount(uint64_t Count) {

View File

@ -798,5 +798,5 @@ void SampleProfileReader::computeSummary() {
const FunctionSamples &Profile = I.second;
Builder.addRecord(Profile);
}
Summary.reset(Builder.getSummary());
Summary = Builder.getSummary();
}

View File

@ -260,5 +260,5 @@ void SampleProfileWriter::computeSummary(
const FunctionSamples &Profile = I.second;
Builder.addRecord(Profile);
}
Summary.reset(Builder.getSummary());
Summary = Builder.getSummary();
}