mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:50:30 +00:00
[ProfileData] Thread unique_ptr through the summary builder to avoid leaks.
llvm-svn: 270195
This commit is contained in:
parent
18d682df79
commit
a123062071
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -798,5 +798,5 @@ void SampleProfileReader::computeSummary() {
|
||||
const FunctionSamples &Profile = I.second;
|
||||
Builder.addRecord(Profile);
|
||||
}
|
||||
Summary.reset(Builder.getSummary());
|
||||
Summary = Builder.getSummary();
|
||||
}
|
||||
|
@ -260,5 +260,5 @@ void SampleProfileWriter::computeSummary(
|
||||
const FunctionSamples &Profile = I.second;
|
||||
Builder.addRecord(Profile);
|
||||
}
|
||||
Summary.reset(Builder.getSummary());
|
||||
Summary = Builder.getSummary();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user