diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2016-06-04 03:08:01 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2016-06-04 03:08:01 +0000 |
commit | 557c624777ffe24656aa082184847d53cae922b5 (patch) | |
tree | d49fc69ca392c441ed2315ed19fcaf9a1cd438a4 /tools/llvm-profdata | |
parent | ec59eedf3a1a5054ae02df517b76c8d1c9fdc0be (diff) |
[llvm-profdata] Revert r271709 and the 3 subsequent commits - the code
and/or tests aren't working on Windows currently.
There seems to be some problem with quoting the file paths. I don't
understand the test structure here or the code well enough to try to
come up with a way to correctly handle paths with back slashes in them,
and this has caused the Windows builds to be failing for 7 hours now, so
I'm reverting the whole thing to bring them back to life. Sorry for the
disruption, but a couple of these were bug fixes anyways that can be
folded into a fresh commit.
Reverts the following patches:
r271756: Clean up the way we create the input filenames buffer (NFC)
r271748: Fix use-after-free from discarded MemoryBuffer (NFC)
r271710: Fix option description (NFC)
r271709: Add option to ingest filepaths from a file
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271760 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-profdata')
-rw-r--r-- | tools/llvm-profdata/llvm-profdata.cpp | 61 |
1 files changed, 4 insertions, 57 deletions
diff --git a/tools/llvm-profdata/llvm-profdata.cpp b/tools/llvm-profdata/llvm-profdata.cpp index b9efd2ee5cd..20a167226a3 100644 --- a/tools/llvm-profdata/llvm-profdata.cpp +++ b/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); |