diff options
| author | Vedant Kumar <vsk@apple.com> | 2016-06-06 23:43:56 +0000 |
|---|---|---|
| committer | Vedant Kumar <vsk@apple.com> | 2016-06-06 23:43:56 +0000 |
| commit | 8d0e861e9b6ac900de2a82929195ac4fe6f7b436 (patch) | |
| tree | 0454741446b2f7702b684c98a12dcbc930b94dc6 /llvm | |
| parent | e8a236fc2ea07304ee73ab02f6cbb00d086caef4 (diff) | |
| download | bcm5719-llvm-8d0e861e9b6ac900de2a82929195ac4fe6f7b436.tar.gz bcm5719-llvm-8d0e861e9b6ac900de2a82929195ac4fe6f7b436.zip | |
Revert "Retry^2 "[llvm-profdata] Add option to ingest filepaths from a file""
This reverts commit r271953. It's still breaking on Windows, though the
list initialization issue is fixed:
http://bb.pgr.jp/builders/ninja-clang-i686-msc19-R/builds/3751
llvm-svn: 271963
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 | 76 |
3 files changed, 13 insertions, 88 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 5d8d27b6dda..00000000000 --- a/llvm/test/tools/llvm-profdata/input-filenames.test +++ /dev/null @@ -1,16 +0,0 @@ -RUN: printf '# comment 1\n' > %t -RUN: printf ' # comment 2\n' >> %t - -RUN: printf 'bar\n' >> %t -RUN: printf ' baz\n' >> %t - -RUN: printf '2,%t.weighted\n' >> %t -RUN: printf ' ' > %t.weighted - -RUN: llvm-profdata merge -input-files %t -dump-input-file-list foo -o /dev/null | FileCheck %s -RUN: llvm-profdata merge -f %t -dump-input-file-list foo -o /dev/null | FileCheck %s - -CHECK: 1,foo -CHECK-NEXT: 1,bar -CHECK-NEXT: 1,baz -CHECK-NEXT: 2,{{.*}}.weighted diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index b5966a493ce..20a167226a3 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -108,12 +108,12 @@ static void handleMergeWriterError(Error E, StringRef WhenceFile = "", } struct WeightedFile { - std::string Filename; + StringRef Filename; uint64_t Weight; WeightedFile() {} - WeightedFile(std::string F, uint64_t W) : Filename(F), Weight(W) {} + WeightedFile(StringRef F, uint64_t W) : Filename{F}, Weight{W} {} }; typedef SmallVector<WeightedFile, 5> WeightedFileVector; @@ -208,53 +208,19 @@ static void mergeSampleProfile(const WeightedFileVector &Inputs, Writer->write(ProfileMap); } -static std::string canonicalizeFilePath(StringRef Filename) { - SmallString<256> CanonicalFilename; - sys::path::native(Filename, CanonicalFilename); - return StringRef(CanonicalFilename).str(); -} - static WeightedFile parseWeightedFile(const StringRef &WeightedFilename) { - StringRef WeightStr, FilenameStr; - std::tie(WeightStr, FilenameStr) = WeightedFilename.split(','); + StringRef WeightStr, FileName; + std::tie(WeightStr, FileName) = WeightedFilename.split(','); uint64_t Weight; if (WeightStr.getAsInteger(10, Weight) || Weight < 1) exitWithError("Input weight must be a positive integer."); - std::string CanonicalFilename = canonicalizeFilePath(FilenameStr); - - if (!sys::fs::exists(CanonicalFilename)) + if (!sys::fs::exists(FileName)) exitWithErrorCode(make_error_code(errc::no_such_file_or_directory), - CanonicalFilename); - - return WeightedFile(StringRef(CanonicalFilename).str(), Weight); -} + FileName); -static void parseInputFilenamesFile(const StringRef &InputFilenamesFile, - WeightedFileVector &WFV) { - if (InputFilenamesFile == "") - return; - - auto BufOrError = MemoryBuffer::getFileOrSTDIN(InputFilenamesFile); - if (!BufOrError) - exitWithErrorCode(BufOrError.getError(), InputFilenamesFile); - - auto Buffer = std::move(*BufOrError); - StringRef Data = Buffer->getBuffer(); - SmallVector<StringRef, 8> Entries; - 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.find(',') == StringRef::npos) - WFV.emplace_back(canonicalizeFilePath(SanitizedEntry), 1); - else - WFV.emplace_back(parseWeightedFile(SanitizedEntry)); - } + return WeightedFile(FileName, Weight); } static int merge_main(int argc, const char *argv[]) { @@ -262,15 +228,6 @@ static int merge_main(int argc, const char *argv[]) { 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")); @@ -292,22 +249,15 @@ static int merge_main(int argc, const char *argv[]) { cl::ParseCommandLineOptions(argc, argv, "LLVM profile data merger\n"); - WeightedFileVector WeightedInputs; - for (StringRef Filename : InputFilenames) - WeightedInputs.emplace_back(canonicalizeFilePath(Filename), 1); - for (StringRef WeightedFilename : WeightedInputFilenames) - WeightedInputs.emplace_back(parseWeightedFile(WeightedFilename)); - parseInputFilenamesFile(InputFilenamesFile, WeightedInputs); - - if (WeightedInputs.empty()) + if (InputFilenames.empty() && WeightedInputFilenames.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; - } + WeightedFileVector WeightedInputs; + for (StringRef Filename : InputFilenames) + WeightedInputs.push_back(WeightedFile(Filename, 1)); + for (StringRef WeightedFilename : WeightedInputFilenames) + WeightedInputs.push_back(parseWeightedFile(WeightedFilename)); if (ProfileKind == instr) mergeInstrProfile(WeightedInputs, OutputFilename, OutputFormat, |

