summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNathan Slingerland <slingn@gmail.com>2015-11-12 18:39:26 +0000
committerNathan Slingerland <slingn@gmail.com>2015-11-12 18:39:26 +0000
commit69c9ea3b396aa3b5dbfe1dea823bab81f7a704b9 (patch)
tree64013d5e211ae2bcc6d6616309f558e90cc2b091 /tools
parent13d37da28f1b6f51f02c8b4417d859970a3f14d9 (diff)
reverting r252916 to investigate test failure
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252921 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-profdata/llvm-profdata.cpp42
1 files changed, 13 insertions, 29 deletions
diff --git a/tools/llvm-profdata/llvm-profdata.cpp b/tools/llvm-profdata/llvm-profdata.cpp
index 1cd47dd5e84..48fc83c6971 100644
--- a/tools/llvm-profdata/llvm-profdata.cpp
+++ b/tools/llvm-profdata/llvm-profdata.cpp
@@ -29,32 +29,16 @@
using namespace llvm;
-static void exitWithError(const Twine &Message,
- StringRef Whence = "",
- StringRef Hint = "") {
+static void exitWithError(const Twine &Message, StringRef Whence = "") {
errs() << "error: ";
if (!Whence.empty())
errs() << Whence << ": ";
errs() << Message << "\n";
- if (!Hint.empty())
- errs() << Hint << "\n";
::exit(1);
}
-static void exitWithErrorCode(const std::error_code &Error, StringRef Whence = "") {
- if (Error.category() == instrprof_category()) {
- instrprof_error instrError = static_cast<instrprof_error>(Error.value());
- if (instrError == instrprof_error::unrecognized_format) {
- // Hint for common error of forgetting -sample for sample profiles.
- exitWithError(Error.message(), Whence,
- "Perhaps you forgot to use the -sample option?");
- }
- }
- exitWithError(Error.message(), Whence);
-}
-
namespace {
- enum ProfileKinds { instr, sample };
+enum ProfileKinds { instr, sample };
}
static void mergeInstrProfile(const cl::list<std::string> &Inputs,
@@ -65,20 +49,20 @@ static void mergeInstrProfile(const cl::list<std::string> &Inputs,
std::error_code EC;
raw_fd_ostream Output(OutputFilename.data(), EC, sys::fs::F_None);
if (EC)
- exitWithErrorCode(EC, OutputFilename);
+ exitWithError(EC.message(), OutputFilename);
InstrProfWriter Writer;
for (const auto &Filename : Inputs) {
auto ReaderOrErr = InstrProfReader::create(Filename);
if (std::error_code ec = ReaderOrErr.getError())
- exitWithErrorCode(ec, Filename);
+ exitWithError(ec.message(), Filename);
auto Reader = std::move(ReaderOrErr.get());
for (auto &I : *Reader)
if (std::error_code EC = Writer.addRecord(std::move(I)))
errs() << Filename << ": " << I.Name << ": " << EC.message() << "\n";
if (Reader->hasError())
- exitWithErrorCode(Reader->getError(), Filename);
+ exitWithError(Reader->getError().message(), Filename);
}
Writer.write(Output);
}
@@ -89,7 +73,7 @@ static void mergeSampleProfile(const cl::list<std::string> &Inputs,
using namespace sampleprof;
auto WriterOrErr = SampleProfileWriter::create(OutputFilename, OutputFormat);
if (std::error_code EC = WriterOrErr.getError())
- exitWithErrorCode(EC, OutputFilename);
+ exitWithError(EC.message(), OutputFilename);
auto Writer = std::move(WriterOrErr.get());
StringMap<FunctionSamples> ProfileMap;
@@ -98,7 +82,7 @@ static void mergeSampleProfile(const cl::list<std::string> &Inputs,
auto ReaderOrErr =
SampleProfileReader::create(Filename, getGlobalContext());
if (std::error_code EC = ReaderOrErr.getError())
- exitWithErrorCode(EC, Filename);
+ exitWithError(EC.message(), Filename);
// We need to keep the readers around until after all the files are
// read so that we do not lose the function names stored in each
@@ -107,7 +91,7 @@ static void mergeSampleProfile(const cl::list<std::string> &Inputs,
Readers.push_back(std::move(ReaderOrErr.get()));
const auto Reader = Readers.back().get();
if (std::error_code EC = Reader->read())
- exitWithErrorCode(EC, Filename);
+ exitWithError(EC.message(), Filename);
StringMap<FunctionSamples> &Profiles = Reader->getProfiles();
for (StringMap<FunctionSamples>::iterator I = Profiles.begin(),
@@ -159,7 +143,7 @@ static int showInstrProfile(std::string Filename, bool ShowCounts,
std::string ShowFunction, raw_fd_ostream &OS) {
auto ReaderOrErr = InstrProfReader::create(Filename);
if (std::error_code EC = ReaderOrErr.getError())
- exitWithErrorCode(EC, Filename);
+ exitWithError(EC.message(), Filename);
auto Reader = std::move(ReaderOrErr.get());
uint64_t MaxFunctionCount = 0, MaxBlockCount = 0;
@@ -214,7 +198,7 @@ static int showInstrProfile(std::string Filename, bool ShowCounts,
}
}
if (Reader->hasError())
- exitWithErrorCode(Reader->getError(), Filename);
+ exitWithError(Reader->getError().message(), Filename);
if (ShowAllFunctions || !ShowFunction.empty())
OS << "Functions shown: " << ShownFunctions << "\n";
@@ -230,11 +214,11 @@ static int showSampleProfile(std::string Filename, bool ShowCounts,
using namespace sampleprof;
auto ReaderOrErr = SampleProfileReader::create(Filename, getGlobalContext());
if (std::error_code EC = ReaderOrErr.getError())
- exitWithErrorCode(EC, Filename);
+ exitWithError(EC.message(), Filename);
auto Reader = std::move(ReaderOrErr.get());
if (std::error_code EC = Reader->read())
- exitWithErrorCode(EC, Filename);
+ exitWithError(EC.message(), Filename);
if (ShowAllFunctions || ShowFunction.empty())
Reader->dump(OS);
@@ -275,7 +259,7 @@ static int show_main(int argc, const char *argv[]) {
std::error_code EC;
raw_fd_ostream OS(OutputFilename.data(), EC, sys::fs::F_Text);
if (EC)
- exitWithErrorCode(EC, OutputFilename);
+ exitWithError(EC.message(), OutputFilename);
if (ShowAllFunctions && !ShowFunction.empty())
errs() << "warning: -function argument ignored: showing all functions\n";