119 changes: 0 additions & 119 deletions llvm/test/tools/llvm-profdata/output-size-limit.test

This file was deleted.

21 changes: 3 additions & 18 deletions llvm/tools/llvm-profdata/llvm-profdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ mergeSampleProfile(const WeightedFileVector &Inputs, SymbolRemapper *Remapper,
bool UseMD5, bool GenPartialProfile, bool GenCSNestedProfile,
bool SampleMergeColdContext, bool SampleTrimColdContext,
bool SampleColdContextFrameDepth, FailureMode FailMode,
bool DropProfileSymbolList, size_t OutputSizeLimit) {
bool DropProfileSymbolList) {
using namespace sampleprof;
SampleProfileMap ProfileMap;
SmallVector<std::unique_ptr<sampleprof::SampleProfileReader>, 5> Readers;
Expand Down Expand Up @@ -1049,13 +1049,6 @@ mergeSampleProfile(const WeightedFileVector &Inputs, SymbolRemapper *Remapper,
ProfileIsCS = FunctionSamples::ProfileIsCS = false;
}

// If limiting the output size, write to a string buffer first, and drop
// functions if the output size exceeds limit. This iterates multiple times
// until the limit is satisfied.
SmallVector<char> StringBuffer;
std::unique_ptr<raw_ostream> BufferStream(
new raw_svector_ostream(StringBuffer));

auto WriterOrErr =
SampleProfileWriter::create(OutputFilename, FormatMap[OutputFormat]);
if (std::error_code EC = WriterOrErr.getError())
Expand All @@ -1067,9 +1060,7 @@ mergeSampleProfile(const WeightedFileVector &Inputs, SymbolRemapper *Remapper,
auto Buffer = getInputFileBuf(ProfileSymbolListFile);
handleExtBinaryWriter(*Writer, OutputFormat, Buffer.get(), WriterList,
CompressAllSections, UseMD5, GenPartialProfile);

if (std::error_code EC =
Writer->writeWithSizeLimit(ProfileMap, OutputSizeLimit))
if (std::error_code EC = Writer->write(ProfileMap))
exitWithErrorCode(std::move(EC));
}

Expand Down Expand Up @@ -1212,11 +1203,6 @@ static int merge_main(int argc, const char *argv[]) {
"sample-frame-depth-for-cold-context", cl::init(1),
cl::desc("Keep the last K frames while merging cold profile. 1 means the "
"context-less base profile"));
cl::opt<size_t> OutputSizeLimit(
"output-size-limit", cl::init(0), cl::Hidden,
cl::desc("Trim cold functions until profile size is below specified "
"limit in bytes. This uses a heursitic and functions may be "
"excessively trimmed"));
cl::opt<bool> GenPartialProfile(
"gen-partial-profile", cl::init(false), cl::Hidden,
cl::desc("Generate a partial profile (only meaningful for -extbinary)"));
Expand Down Expand Up @@ -1303,8 +1289,7 @@ static int merge_main(int argc, const char *argv[]) {
WeightedInputs, Remapper.get(), OutputFilename, OutputFormat,
ProfileSymbolListFile, CompressAllSections, UseMD5, GenPartialProfile,
GenCSNestedProfile, SampleMergeColdContext, SampleTrimColdContext,
SampleColdContextFrameDepth, FailureMode, DropProfileSymbolList,
OutputSizeLimit);
SampleColdContextFrameDepth, FailureMode, DropProfileSymbolList);
return 0;
}

Expand Down