File tree 2 files changed +11
-6
lines changed 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) {
320
320
}
321
321
322
322
void 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 ());
328
325
if (TemporalProfTraceStreamSize < TemporalProfTraceReservoirSize) {
329
326
// Simply append the trace if we have not yet hit our reservoir size limit.
330
327
TemporalProfTraces.push_back (std::move (Trace));
@@ -341,6 +338,10 @@ void InstrProfWriter::addTemporalProfileTrace(TemporalProfTraceTy Trace) {
341
338
342
339
void InstrProfWriter::addTemporalProfileTraces (
343
340
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 (); });
344
345
// Assume that the source has the same reservoir size as the destination to
345
346
// avoid needing to record it in the indexed profile format.
346
347
bool IsDestSampled =
Original file line number Diff line number Diff line change 1
1
# RUN: llvm-profdata merge --temporal-profile-max-trace-length=0 %s -o %t.profdata
2
2
# RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefix=NONE
3
3
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
+
4
8
# RUN: llvm-profdata merge --temporal-profile-max-trace-length=2 %s -o %t.profdata
5
9
# RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefixes=CHECK,SOME
6
10
7
11
# RUN: llvm-profdata merge --temporal-profile-max-trace-length=1000 %s -o %t.profdata
8
12
# RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefixes=CHECK,ALL
9
13
10
- # NONE: Temporal Profile Traces (samples=0 seen=0):
14
+ # NONE: Temporal Profile Traces (samples=0
11
15
# CHECK: Temporal Profile Traces (samples=1 seen=1):
12
16
# SOME: Trace 0 (weight=1 count=2):
13
17
# ALL: Trace 0 (weight=1 count=3):
You can’t perform that action at this time.
0 commit comments