diff options
Diffstat (limited to 'contrib/llvm/tools/llvm-profdata/llvm-profdata.cpp')
-rw-r--r-- | contrib/llvm/tools/llvm-profdata/llvm-profdata.cpp | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/contrib/llvm/tools/llvm-profdata/llvm-profdata.cpp b/contrib/llvm/tools/llvm-profdata/llvm-profdata.cpp index 9afd0ae92eae..1a0b9e127bbc 100644 --- a/contrib/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/contrib/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -24,32 +24,42 @@ #include "llvm/Support/Errc.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Format.h" -#include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/InitLLVM.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" -#include "llvm/Support/PrettyStackTrace.h" -#include "llvm/Support/Signals.h" +#include "llvm/Support/WithColor.h" #include "llvm/Support/ThreadPool.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> using namespace llvm; -enum ProfileFormat { PF_None = 0, PF_Text, PF_Binary, PF_GCC }; +enum ProfileFormat { + PF_None = 0, + PF_Text, + PF_Compact_Binary, + PF_GCC, + PF_Binary +}; -static void warn(StringRef Prefix, Twine Message, std::string Whence = "", +static void warn(Twine Message, std::string Whence = "", std::string Hint = "") { - errs() << Prefix; + WithColor::warning(); if (!Whence.empty()) errs() << Whence << ": "; errs() << Message << "\n"; if (!Hint.empty()) - errs() << Hint << "\n"; + WithColor::note() << Hint << "\n"; } static void exitWithError(Twine Message, std::string Whence = "", std::string Hint = "") { - warn("error: ", Message, Whence, Hint); + WithColor::error(); + if (!Whence.empty()) + errs() << Whence << ": "; + errs() << Message << "\n"; + if (!Hint.empty()) + WithColor::note() << Hint << "\n"; ::exit(1); } @@ -232,7 +242,8 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs, if (OutputFilename.compare("-") == 0) exitWithError("Cannot write indexed profdata format to stdout."); - if (OutputFormat != PF_Binary && OutputFormat != PF_Text) + if (OutputFormat != PF_Binary && OutputFormat != PF_Compact_Binary && + OutputFormat != PF_Text) exitWithError("Unknown format is specified."); std::error_code EC; @@ -298,7 +309,7 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs, if (isFatalError(IPE)) exitWithError(make_error<InstrProfError>(IPE), WC->ErrWhence); else - warn("warning: ", toString(make_error<InstrProfError>(IPE)), + warn(toString(make_error<InstrProfError>(IPE)), WC->ErrWhence); } @@ -312,8 +323,8 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs, } static sampleprof::SampleProfileFormat FormatMap[] = { - sampleprof::SPF_None, sampleprof::SPF_Text, sampleprof::SPF_Binary, - sampleprof::SPF_GCC}; + sampleprof::SPF_None, sampleprof::SPF_Text, sampleprof::SPF_Compact_Binary, + sampleprof::SPF_GCC, sampleprof::SPF_Binary}; static void mergeSampleProfile(const WeightedFileVector &Inputs, StringRef OutputFilename, @@ -462,6 +473,8 @@ static int merge_main(int argc, const char *argv[]) { cl::opt<ProfileFormat> OutputFormat( cl::desc("Format of output profile"), cl::init(PF_Binary), cl::values(clEnumValN(PF_Binary, "binary", "Binary encoding (default)"), + clEnumValN(PF_Compact_Binary, "compbinary", + "Compact binary encoding"), clEnumValN(PF_Text, "text", "Text encoding"), clEnumValN(PF_GCC, "gcc", "GCC encoding (only meaningful for -sample)"))); @@ -787,7 +800,7 @@ static int show_main(int argc, const char *argv[]) { exitWithErrorCode(EC, OutputFilename); if (ShowAllFunctions && !ShowFunction.empty()) - errs() << "warning: -function argument ignored: showing all functions\n"; + WithColor::warning() << "-function argument ignored: showing all functions\n"; std::vector<uint32_t> Cutoffs(DetailedSummaryCutoffs.begin(), DetailedSummaryCutoffs.end()); @@ -802,10 +815,7 @@ static int show_main(int argc, const char *argv[]) { } int main(int argc, const char *argv[]) { - // Print a stack trace if we signal out. - sys::PrintStackTraceOnErrorSignal(argv[0]); - PrettyStackTraceProgram X(argc, argv); - llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. + InitLLVM X(argc, argv); StringRef ProgName(sys::path::filename(argv[0])); if (argc > 1) { |