File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -320,11 +320,8 @@ void InstrProfWriter::addBinaryIds(ArrayRef<llvm::object::BuildID> BIs) {
320320}
321321
322322void InstrProfWriter::addTemporalProfileTrace (TemporalProfTraceTy Trace) {
323- if (Trace.FunctionNameRefs .size () > MaxTemporalProfTraceLength)
324- Trace.FunctionNameRefs .resize (MaxTemporalProfTraceLength);
325- if (Trace.FunctionNameRefs .empty ())
326- return ;
327-
323+ assert (Trace.FunctionNameRefs .size () <= MaxTemporalProfTraceLength);
324+ assert (!Trace.FunctionNameRefs .empty ());
328325 if (TemporalProfTraceStreamSize < TemporalProfTraceReservoirSize) {
329326 // Simply append the trace if we have not yet hit our reservoir size limit.
330327 TemporalProfTraces.push_back (std::move (Trace));
@@ -341,6 +338,10 @@ void InstrProfWriter::addTemporalProfileTrace(TemporalProfTraceTy Trace) {
341338
342339void InstrProfWriter::addTemporalProfileTraces (
343340 SmallVectorImpl<TemporalProfTraceTy> &SrcTraces, uint64_t SrcStreamSize) {
341+ for (auto &Trace : SrcTraces)
342+ if (Trace.FunctionNameRefs .size () > MaxTemporalProfTraceLength)
343+ Trace.FunctionNameRefs .resize (MaxTemporalProfTraceLength);
344+ llvm::erase_if (SrcTraces, [](auto &T) { return T.FunctionNameRefs .empty (); });
344345 // Assume that the source has the same reservoir size as the destination to
345346 // avoid needing to record it in the indexed profile format.
346347 bool IsDestSampled =
Original file line number Diff line number Diff line change 11# RUN: llvm-profdata merge --temporal-profile-max-trace-length=0 %s -o %t.profdata
22# RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefix=NONE
33
4+ # RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %s %s %s -o %t.profdata
5+ # RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 --temporal-profile-max-trace-length=0 %t.profdata -o %t.profdata
6+ # RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefix=NONE
7+
48# RUN: llvm-profdata merge --temporal-profile-max-trace-length=2 %s -o %t.profdata
59# RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefixes=CHECK,SOME
610
711# RUN: llvm-profdata merge --temporal-profile-max-trace-length=1000 %s -o %t.profdata
812# RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefixes=CHECK,ALL
913
10- # NONE: Temporal Profile Traces (samples=0 seen=0):
14+ # NONE: Temporal Profile Traces (samples=0
1115# CHECK: Temporal Profile Traces (samples=1 seen=1):
1216# SOME: Trace 0 (weight=1 count=2):
1317# ALL: Trace 0 (weight=1 count=3):
You can’t perform that action at this time.
0 commit comments