diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/docs/CommandGuide/llvm-profdata.rst | 9 | ||||
-rw-r--r-- | llvm/test/tools/llvm-profdata/input-filenames.test | 16 | ||||
-rw-r--r-- | llvm/tools/llvm-profdata/llvm-profdata.cpp | 61 |
3 files changed, 4 insertions, 82 deletions
diff --git a/llvm/docs/CommandGuide/llvm-profdata.rst b/llvm/docs/CommandGuide/llvm-profdata.rst index 2742fd3d75d..12f2771bd00 100644 --- a/llvm/docs/CommandGuide/llvm-profdata.rst +++ b/llvm/docs/CommandGuide/llvm-profdata.rst @@ -44,9 +44,6 @@ interpreted as relatively more important than a shorter run. Depending on the nature of the training runs it may be useful to adjust the weight given to each input file by using the ``-weighted-input`` option. -Profiles passed in via ``-weighted-input``, ``-input-files``, or via positional -arguments are processed once for each time they are seen. - OPTIONS ^^^^^^^ @@ -68,12 +65,6 @@ OPTIONS Input files specified without using this option are assigned a default weight of 1. Examples are shown below. -.. option:: -input-files=path, -f=path - - Specify a file which contains a list of files to merge. The entries in this - file are newline-separated. Lines starting with '#' are skipped. Entries may - be of the form <filename> or <weight>,<filename>. - .. option:: -instr (default) Specify that the input profile is an instrumentation-based profile. diff --git a/llvm/test/tools/llvm-profdata/input-filenames.test b/llvm/test/tools/llvm-profdata/input-filenames.test deleted file mode 100644 index 65b3c9e06bd..00000000000 --- a/llvm/test/tools/llvm-profdata/input-filenames.test +++ /dev/null @@ -1,16 +0,0 @@ -# Create an input file. -RUN: printf '# comment 1\n' > %t.input -RUN: printf ' # comment 2\n' >> %t.input -RUN: printf 'foo\n' >> %t.input -RUN: printf ' bar\n' >> %t.input -RUN: printf "2,%t.weighted\n" >> %t.input - -# Create the weighted file, since these actually need to exist. -RUN: printf ' ' > %t.weighted - -# RUN: llvm-profdata merge -f %t.input -dump-input-file-list -o /dev/null | FileCheck %s -# RUN: llvm-profdata merge -input-files %t.input -dump-input-file-list -o /dev/null | FileCheck %s - -# CHECK: 1,foo -# CHECK-NEXT: 1,bar -# CHECK-NEXT: 2,{{.*}}.weighted diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index b9efd2ee5cd..20a167226a3 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -223,53 +223,11 @@ static WeightedFile parseWeightedFile(const StringRef &WeightedFilename) { return WeightedFile(FileName, Weight); } -static std::unique_ptr<MemoryBuffer> -getInputFilenamesFileBuf(const StringRef &InputFilenamesFile) { - if (InputFilenamesFile == "") - return {}; - - auto BufOrError = MemoryBuffer::getFileOrSTDIN(InputFilenamesFile); - if (!BufOrError) - exitWithErrorCode(BufOrError.getError(), InputFilenamesFile); - - return std::move(*BufOrError); -} - -static void parseInputFilenamesFile(MemoryBuffer *Buffer, - WeightedFileVector &WFV) { - if (!Buffer) - return; - - SmallVector<StringRef, 8> Entries; - StringRef Data = Buffer->getBuffer(); - Data.split(Entries, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false); - for (const StringRef &FileWeightEntry : Entries) { - StringRef SanitizedEntry = FileWeightEntry.trim(" \t\v\f\r"); - // Skip comments. - if (SanitizedEntry.startswith("#")) - continue; - // If there's no comma, it's an unweighted profile. - else if (SanitizedEntry.rfind(',') == StringRef::npos) - WFV.emplace_back(SanitizedEntry, 1); - else - WFV.emplace_back(parseWeightedFile(SanitizedEntry)); - } -} - static int merge_main(int argc, const char *argv[]) { cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<filename...>")); cl::list<std::string> WeightedInputFilenames("weighted-input", cl::desc("<weight>,<filename>")); - cl::opt<std::string> InputFilenamesFile( - "input-files", cl::init(""), - cl::desc("Path to file containing newline-separated " - "[<weight>,]<filename> entries")); - cl::alias InputFilenamesFileA("f", cl::desc("Alias for --input-files"), - cl::aliasopt(InputFilenamesFile)); - cl::opt<bool> DumpInputFileList( - "dump-input-file-list", cl::init(false), cl::Hidden, - cl::desc("Dump the list of input files and their weights, then exit")); cl::opt<std::string> OutputFilename("output", cl::value_desc("output"), cl::init("-"), cl::Required, cl::desc("Output file")); @@ -291,27 +249,16 @@ static int merge_main(int argc, const char *argv[]) { cl::ParseCommandLineOptions(argc, argv, "LLVM profile data merger\n"); + if (InputFilenames.empty() && WeightedInputFilenames.empty()) + exitWithError("No input files specified. See " + + sys::path::filename(argv[0]) + " -help"); + WeightedFileVector WeightedInputs; for (StringRef Filename : InputFilenames) WeightedInputs.push_back(WeightedFile(Filename, 1)); for (StringRef WeightedFilename : WeightedInputFilenames) WeightedInputs.push_back(parseWeightedFile(WeightedFilename)); - // Make sure that the file buffer stays alive for the duration of the - // weighted input vector's lifetime. - auto Buffer = getInputFilenamesFileBuf(InputFilenamesFile); - parseInputFilenamesFile(Buffer.get(), WeightedInputs); - - if (WeightedInputs.empty()) - exitWithError("No input files specified. See " + - sys::path::filename(argv[0]) + " -help"); - - if (DumpInputFileList) { - for (auto &WF : WeightedInputs) - outs() << WF.Weight << "," << WF.Filename << "\n"; - return 0; - } - if (ProfileKind == instr) mergeInstrProfile(WeightedInputs, OutputFilename, OutputFormat, OutputSparse); |