llvm.org GIT mirror llvm / e3bf664
[ProfileData] Thread unique_ptr through the summary builder to avoid leaks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270195 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 4 years ago
6 changed file(s) with 16 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
7373 InstrProfSummaryBuilder(std::vector Cutoffs)
7474 : ProfileSummaryBuilder(Cutoffs), MaxInternalBlockCount(0) {}
7575 void addRecord(const InstrProfRecord &);
76 ProfileSummary *getSummary();
76 std::unique_ptr getSummary();
7777 };
7878
7979 class SampleProfileSummaryBuilder final : public ProfileSummaryBuilder {
8282 void addRecord(const sampleprof::FunctionSamples &FS);
8383 SampleProfileSummaryBuilder(std::vector Cutoffs)
8484 : ProfileSummaryBuilder(Cutoffs) {}
85 ProfileSummary *getSummary();
85 std::unique_ptr getSummary();
8686 };
8787
8888 // This is called when a count is seen in the profile.
616616 InstrProfSummaryBuilder Builder(ProfileSummaryBuilder::DefaultCutoffs);
617617 // FIXME: This only computes an empty summary. Need to call addRecord for
618618 // all InstrProfRecords to get the correct summary.
619 this->Summary.reset(Builder.getSummary());
619 this->Summary = Builder.getSummary();
620620 return Cur;
621621 }
622622 }
258258 IndexedInstrProf::allocSummary(SummarySize);
259259 // Compute the Summary and copy the data to the data
260260 // structure to be serialized out (to disk or buffer).
261 ProfileSummary *PS = ISB.getSummary();
261 std::unique_ptr PS = ISB.getSummary();
262262 setSummary(TheSummary.get(), *PS);
263263 InfoObj->SummaryBuilder = 0;
264264
8585 }
8686 }
8787
88 ProfileSummary *SampleProfileSummaryBuilder::getSummary() {
88 std::unique_ptr SampleProfileSummaryBuilder::getSummary() {
8989 computeDetailedSummary();
90 return new ProfileSummary(ProfileSummary::PSK_Sample, DetailedSummary,
91 TotalCount, MaxCount, 0, MaxFunctionCount,
92 NumCounts, NumFunctions);
90 return llvm::make_unique(
91 ProfileSummary::PSK_Sample, DetailedSummary, TotalCount, MaxCount, 0,
92 MaxFunctionCount, NumCounts, NumFunctions);
9393 }
9494
95 ProfileSummary *InstrProfSummaryBuilder::getSummary() {
95 std::unique_ptr InstrProfSummaryBuilder::getSummary() {
9696 computeDetailedSummary();
97 return new ProfileSummary(ProfileSummary::PSK_Instr, DetailedSummary,
98 TotalCount, MaxCount, MaxInternalBlockCount,
99 MaxFunctionCount, NumCounts, NumFunctions);
97 return llvm::make_unique(
98 ProfileSummary::PSK_Instr, DetailedSummary, TotalCount, MaxCount,
99 MaxInternalBlockCount, MaxFunctionCount, NumCounts, NumFunctions);
100100 }
101101
102102 void InstrProfSummaryBuilder::addEntryCount(uint64_t Count) {
797797 const FunctionSamples &Profile = I.second;
798798 Builder.addRecord(Profile);
799799 }
800 Summary.reset(Builder.getSummary());
801 }
800 Summary = Builder.getSummary();
801 }
259259 const FunctionSamples &Profile = I.second;
260260 Builder.addRecord(Profile);
261261 }
262 Summary.reset(Builder.getSummary());
263 }
262 Summary = Builder.getSummary();
263 }