2014-02-18 07:22:49 +08:00
|
|
|
//===- llvm-profdata.cpp - LLVM profile data tool -------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// llvm-profdata merges .profdata files.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-11-19 01:10:24 +08:00
|
|
|
#include "llvm/ADT/SmallSet.h"
|
2015-12-16 01:37:09 +08:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2014-02-18 07:22:49 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2015-01-14 19:23:27 +08:00
|
|
|
#include "llvm/IR/LLVMContext.h"
|
2014-03-22 01:24:48 +08:00
|
|
|
#include "llvm/ProfileData/InstrProfReader.h"
|
2014-03-22 01:46:22 +08:00
|
|
|
#include "llvm/ProfileData/InstrProfWriter.h"
|
2016-02-05 07:34:31 +08:00
|
|
|
#include "llvm/ProfileData/ProfileCommon.h"
|
2014-11-01 08:56:55 +08:00
|
|
|
#include "llvm/ProfileData/SampleProfReader.h"
|
|
|
|
#include "llvm/ProfileData/SampleProfWriter.h"
|
2014-02-18 07:22:49 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2015-12-16 01:37:09 +08:00
|
|
|
#include "llvm/Support/Errc.h"
|
2014-04-30 07:26:49 +08:00
|
|
|
#include "llvm/Support/FileSystem.h"
|
2014-03-24 04:43:50 +08:00
|
|
|
#include "llvm/Support/Format.h"
|
2014-02-18 07:22:49 +08:00
|
|
|
#include "llvm/Support/ManagedStatic.h"
|
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
2015-03-24 02:07:13 +08:00
|
|
|
#include "llvm/Support/Path.h"
|
2014-02-18 07:22:49 +08:00
|
|
|
#include "llvm/Support/PrettyStackTrace.h"
|
|
|
|
#include "llvm/Support/Signals.h"
|
2016-07-19 09:17:20 +08:00
|
|
|
#include "llvm/Support/ThreadPool.h"
|
2014-02-18 07:22:49 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2015-12-16 01:37:09 +08:00
|
|
|
#include <algorithm>
|
2014-02-18 07:22:49 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2015-11-24 04:47:38 +08:00
|
|
|
enum ProfileFormat { PF_None = 0, PF_Text, PF_Binary, PF_GCC };
|
|
|
|
|
2015-12-15 04:37:15 +08:00
|
|
|
static void exitWithError(const Twine &Message, StringRef Whence = "",
|
2015-11-13 11:47:58 +08:00
|
|
|
StringRef Hint = "") {
|
2014-03-22 01:24:48 +08:00
|
|
|
errs() << "error: ";
|
|
|
|
if (!Whence.empty())
|
|
|
|
errs() << Whence << ": ";
|
|
|
|
errs() << Message << "\n";
|
2015-11-13 11:47:58 +08:00
|
|
|
if (!Hint.empty())
|
|
|
|
errs() << Hint << "\n";
|
2014-03-13 06:00:57 +08:00
|
|
|
::exit(1);
|
2014-02-18 07:22:49 +08:00
|
|
|
}
|
|
|
|
|
2016-05-19 11:54:45 +08:00
|
|
|
static void exitWithError(Error E, StringRef Whence = "") {
|
|
|
|
if (E.isA<InstrProfError>()) {
|
|
|
|
handleAllErrors(std::move(E), [&](const InstrProfError &IPE) {
|
|
|
|
instrprof_error instrError = IPE.get();
|
|
|
|
StringRef Hint = "";
|
|
|
|
if (instrError == instrprof_error::unrecognized_format) {
|
|
|
|
// Hint for common error of forgetting -sample for sample profiles.
|
|
|
|
Hint = "Perhaps you forgot to use the -sample option?";
|
|
|
|
}
|
|
|
|
exitWithError(IPE.message(), Whence, Hint);
|
|
|
|
});
|
2015-11-13 11:47:58 +08:00
|
|
|
}
|
2016-05-19 11:54:45 +08:00
|
|
|
|
|
|
|
exitWithError(toString(std::move(E)), Whence);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void exitWithErrorCode(std::error_code EC, StringRef Whence = "") {
|
|
|
|
exitWithError(EC.message(), Whence);
|
2015-11-13 11:47:58 +08:00
|
|
|
}
|
|
|
|
|
2015-06-16 08:43:04 +08:00
|
|
|
namespace {
|
2015-12-15 04:37:15 +08:00
|
|
|
enum ProfileKinds { instr, sample };
|
2015-06-16 08:43:04 +08:00
|
|
|
}
|
2014-02-18 07:22:49 +08:00
|
|
|
|
2016-05-19 11:54:45 +08:00
|
|
|
static void handleMergeWriterError(Error E, StringRef WhenceFile = "",
|
2015-11-18 06:08:53 +08:00
|
|
|
StringRef WhenceFunction = "",
|
2015-12-15 04:37:15 +08:00
|
|
|
bool ShowHint = true) {
|
2015-11-18 06:08:53 +08:00
|
|
|
if (!WhenceFile.empty())
|
|
|
|
errs() << WhenceFile << ": ";
|
|
|
|
if (!WhenceFunction.empty())
|
|
|
|
errs() << WhenceFunction << ": ";
|
2016-05-19 11:54:45 +08:00
|
|
|
|
|
|
|
auto IPE = instrprof_error::success;
|
|
|
|
E = handleErrors(std::move(E),
|
|
|
|
[&IPE](std::unique_ptr<InstrProfError> E) -> Error {
|
|
|
|
IPE = E->get();
|
|
|
|
return Error(std::move(E));
|
|
|
|
});
|
|
|
|
errs() << toString(std::move(E)) << "\n";
|
2015-11-18 06:08:53 +08:00
|
|
|
|
|
|
|
if (ShowHint) {
|
|
|
|
StringRef Hint = "";
|
2016-05-19 11:54:45 +08:00
|
|
|
if (IPE != instrprof_error::success) {
|
|
|
|
switch (IPE) {
|
2015-11-18 07:37:09 +08:00
|
|
|
case instrprof_error::hash_mismatch:
|
|
|
|
case instrprof_error::count_mismatch:
|
|
|
|
case instrprof_error::value_site_count_mismatch:
|
2015-12-15 04:37:15 +08:00
|
|
|
Hint = "Make sure that all profile data to be merged is generated "
|
2015-11-18 06:08:53 +08:00
|
|
|
"from the same binary.";
|
2015-11-18 07:37:09 +08:00
|
|
|
break;
|
2015-11-18 08:52:45 +08:00
|
|
|
default:
|
|
|
|
break;
|
2015-11-18 06:08:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Hint.empty())
|
|
|
|
errs() << Hint << "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-16 01:37:09 +08:00
|
|
|
struct WeightedFile {
|
2016-07-21 06:24:52 +08:00
|
|
|
std::string Filename;
|
2015-12-16 01:37:09 +08:00
|
|
|
uint64_t Weight;
|
|
|
|
};
|
|
|
|
typedef SmallVector<WeightedFile, 5> WeightedFileVector;
|
|
|
|
|
2016-07-19 09:17:20 +08:00
|
|
|
/// Keep track of merged data and reported errors.
|
|
|
|
struct WriterContext {
|
|
|
|
std::mutex Lock;
|
|
|
|
InstrProfWriter Writer;
|
|
|
|
Error Err;
|
|
|
|
StringRef ErrWhence;
|
|
|
|
std::mutex &ErrLock;
|
|
|
|
SmallSet<instrprof_error, 4> &WriterErrorCodes;
|
|
|
|
|
|
|
|
WriterContext(bool IsSparse, std::mutex &ErrLock,
|
|
|
|
SmallSet<instrprof_error, 4> &WriterErrorCodes)
|
|
|
|
: Lock(), Writer(IsSparse), Err(Error::success()), ErrWhence(""),
|
|
|
|
ErrLock(ErrLock), WriterErrorCodes(WriterErrorCodes) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Load an input into a writer context.
|
|
|
|
static void loadInput(const WeightedFile &Input, WriterContext *WC) {
|
|
|
|
std::unique_lock<std::mutex> CtxGuard{WC->Lock};
|
|
|
|
|
|
|
|
// If there's a pending hard error, don't do more work.
|
|
|
|
if (WC->Err)
|
|
|
|
return;
|
|
|
|
|
|
|
|
WC->ErrWhence = Input.Filename;
|
|
|
|
|
|
|
|
auto ReaderOrErr = InstrProfReader::create(Input.Filename);
|
2016-10-20 06:51:17 +08:00
|
|
|
if (Error E = ReaderOrErr.takeError()) {
|
|
|
|
// Skip the empty profiles by returning sliently.
|
|
|
|
instrprof_error IPE = InstrProfError::take(std::move(E));
|
|
|
|
if (IPE != instrprof_error::empty_raw_profile)
|
|
|
|
WC->Err = make_error<InstrProfError>(IPE);
|
2016-07-19 09:17:20 +08:00
|
|
|
return;
|
2016-10-20 06:51:17 +08:00
|
|
|
}
|
2016-07-19 09:17:20 +08:00
|
|
|
|
|
|
|
auto Reader = std::move(ReaderOrErr.get());
|
|
|
|
bool IsIRProfile = Reader->isIRLevelProfile();
|
|
|
|
if (WC->Writer.setIsIRLevelProfile(IsIRProfile)) {
|
|
|
|
WC->Err = make_error<StringError>(
|
|
|
|
"Merge IR generated profile with Clang generated profile.",
|
|
|
|
std::error_code());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto &I : *Reader) {
|
2016-10-20 07:31:59 +08:00
|
|
|
const StringRef FuncName = I.Name;
|
2016-07-19 09:17:20 +08:00
|
|
|
if (Error E = WC->Writer.addRecord(std::move(I), Input.Weight)) {
|
|
|
|
// Only show hint the first time an error occurs.
|
|
|
|
instrprof_error IPE = InstrProfError::take(std::move(E));
|
|
|
|
std::unique_lock<std::mutex> ErrGuard{WC->ErrLock};
|
|
|
|
bool firstTime = WC->WriterErrorCodes.insert(IPE).second;
|
|
|
|
handleMergeWriterError(make_error<InstrProfError>(IPE), Input.Filename,
|
2016-10-20 07:31:59 +08:00
|
|
|
FuncName, firstTime);
|
2016-07-19 09:17:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Reader->hasError())
|
|
|
|
WC->Err = Reader->getError();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Merge the \p Src writer context into \p Dst.
|
|
|
|
static void mergeWriterContexts(WriterContext *Dst, WriterContext *Src) {
|
|
|
|
if (Error E = Dst->Writer.mergeRecordsFromWriter(std::move(Src->Writer)))
|
|
|
|
Dst->Err = std::move(E);
|
|
|
|
}
|
|
|
|
|
2015-12-16 01:37:09 +08:00
|
|
|
static void mergeInstrProfile(const WeightedFileVector &Inputs,
|
2015-11-24 04:47:38 +08:00
|
|
|
StringRef OutputFilename,
|
2016-07-19 09:17:20 +08:00
|
|
|
ProfileFormat OutputFormat, bool OutputSparse,
|
|
|
|
unsigned NumThreads) {
|
2014-04-19 05:48:40 +08:00
|
|
|
if (OutputFilename.compare("-") == 0)
|
|
|
|
exitWithError("Cannot write indexed profdata format to stdout.");
|
2014-02-18 07:22:49 +08:00
|
|
|
|
2015-11-24 04:47:38 +08:00
|
|
|
if (OutputFormat != PF_Binary && OutputFormat != PF_Text)
|
|
|
|
exitWithError("Unknown format is specified.");
|
|
|
|
|
2014-08-26 02:16:47 +08:00
|
|
|
std::error_code EC;
|
|
|
|
raw_fd_ostream Output(OutputFilename.data(), EC, sys::fs::F_None);
|
|
|
|
if (EC)
|
2015-11-13 11:47:58 +08:00
|
|
|
exitWithErrorCode(EC, OutputFilename);
|
2014-02-18 07:22:49 +08:00
|
|
|
|
2016-07-19 09:17:20 +08:00
|
|
|
std::mutex ErrorLock;
|
2016-05-19 11:54:45 +08:00
|
|
|
SmallSet<instrprof_error, 4> WriterErrorCodes;
|
2016-07-19 09:17:20 +08:00
|
|
|
|
|
|
|
// If NumThreads is not specified, auto-detect a good default.
|
|
|
|
if (NumThreads == 0)
|
|
|
|
NumThreads = std::max(1U, std::min(std::thread::hardware_concurrency(),
|
|
|
|
unsigned(Inputs.size() / 2)));
|
|
|
|
|
|
|
|
// Initialize the writer contexts.
|
|
|
|
SmallVector<std::unique_ptr<WriterContext>, 4> Contexts;
|
|
|
|
for (unsigned I = 0; I < NumThreads; ++I)
|
|
|
|
Contexts.emplace_back(llvm::make_unique<WriterContext>(
|
|
|
|
OutputSparse, ErrorLock, WriterErrorCodes));
|
|
|
|
|
|
|
|
if (NumThreads == 1) {
|
|
|
|
for (const auto &Input : Inputs)
|
|
|
|
loadInput(Input, Contexts[0].get());
|
|
|
|
} else {
|
|
|
|
ThreadPool Pool(NumThreads);
|
|
|
|
|
|
|
|
// Load the inputs in parallel (N/NumThreads serial steps).
|
|
|
|
unsigned Ctx = 0;
|
|
|
|
for (const auto &Input : Inputs) {
|
|
|
|
Pool.async(loadInput, Input, Contexts[Ctx].get());
|
|
|
|
Ctx = (Ctx + 1) % NumThreads;
|
2015-11-18 06:08:53 +08:00
|
|
|
}
|
2016-07-19 09:17:20 +08:00
|
|
|
Pool.wait();
|
|
|
|
|
|
|
|
// Merge the writer contexts together (~ lg(NumThreads) serial steps).
|
|
|
|
unsigned Mid = Contexts.size() / 2;
|
|
|
|
unsigned End = Contexts.size();
|
|
|
|
assert(Mid > 0 && "Expected more than one context");
|
|
|
|
do {
|
|
|
|
for (unsigned I = 0; I < Mid; ++I)
|
|
|
|
Pool.async(mergeWriterContexts, Contexts[I].get(),
|
|
|
|
Contexts[I + Mid].get());
|
|
|
|
Pool.wait();
|
|
|
|
if (End & 1) {
|
|
|
|
Pool.async(mergeWriterContexts, Contexts[0].get(),
|
|
|
|
Contexts[End - 1].get());
|
|
|
|
Pool.wait();
|
|
|
|
}
|
|
|
|
End = Mid;
|
|
|
|
Mid /= 2;
|
|
|
|
} while (Mid > 0);
|
2014-03-13 06:00:57 +08:00
|
|
|
}
|
2016-07-19 09:17:20 +08:00
|
|
|
|
|
|
|
// Handle deferred hard errors encountered during merging.
|
|
|
|
for (std::unique_ptr<WriterContext> &WC : Contexts)
|
|
|
|
if (WC->Err)
|
|
|
|
exitWithError(std::move(WC->Err), WC->ErrWhence);
|
|
|
|
|
|
|
|
InstrProfWriter &Writer = Contexts[0]->Writer;
|
2015-11-24 04:47:38 +08:00
|
|
|
if (OutputFormat == PF_Text)
|
|
|
|
Writer.writeText(Output);
|
|
|
|
else
|
|
|
|
Writer.write(Output);
|
2014-02-18 07:22:49 +08:00
|
|
|
}
|
2014-03-19 10:20:46 +08:00
|
|
|
|
2015-11-24 04:47:38 +08:00
|
|
|
static sampleprof::SampleProfileFormat FormatMap[] = {
|
|
|
|
sampleprof::SPF_None, sampleprof::SPF_Text, sampleprof::SPF_Binary,
|
|
|
|
sampleprof::SPF_GCC};
|
|
|
|
|
2015-12-16 01:37:09 +08:00
|
|
|
static void mergeSampleProfile(const WeightedFileVector &Inputs,
|
2015-03-10 00:23:46 +08:00
|
|
|
StringRef OutputFilename,
|
2015-11-24 04:47:38 +08:00
|
|
|
ProfileFormat OutputFormat) {
|
2014-11-01 08:56:55 +08:00
|
|
|
using namespace sampleprof;
|
2015-11-24 04:47:38 +08:00
|
|
|
auto WriterOrErr =
|
|
|
|
SampleProfileWriter::create(OutputFilename, FormatMap[OutputFormat]);
|
2014-11-03 08:51:45 +08:00
|
|
|
if (std::error_code EC = WriterOrErr.getError())
|
2015-11-13 11:47:58 +08:00
|
|
|
exitWithErrorCode(EC, OutputFilename);
|
2014-03-22 01:29:44 +08:00
|
|
|
|
2014-11-03 08:51:45 +08:00
|
|
|
auto Writer = std::move(WriterOrErr.get());
|
2014-11-01 08:56:55 +08:00
|
|
|
StringMap<FunctionSamples> ProfileMap;
|
2015-10-09 03:40:37 +08:00
|
|
|
SmallVector<std::unique_ptr<sampleprof::SampleProfileReader>, 5> Readers;
|
2016-04-15 05:59:01 +08:00
|
|
|
LLVMContext Context;
|
2015-12-16 01:37:09 +08:00
|
|
|
for (const auto &Input : Inputs) {
|
2016-04-15 05:59:01 +08:00
|
|
|
auto ReaderOrErr = SampleProfileReader::create(Input.Filename, Context);
|
2014-11-03 08:51:45 +08:00
|
|
|
if (std::error_code EC = ReaderOrErr.getError())
|
2015-12-16 01:37:09 +08:00
|
|
|
exitWithErrorCode(EC, Input.Filename);
|
2014-11-01 08:56:55 +08:00
|
|
|
|
2015-10-09 03:40:37 +08:00
|
|
|
// 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
|
|
|
|
// reader's memory. The function names are needed to write out the
|
|
|
|
// merged profile map.
|
|
|
|
Readers.push_back(std::move(ReaderOrErr.get()));
|
|
|
|
const auto Reader = Readers.back().get();
|
2014-11-01 08:56:55 +08:00
|
|
|
if (std::error_code EC = Reader->read())
|
2015-12-16 01:37:09 +08:00
|
|
|
exitWithErrorCode(EC, Input.Filename);
|
2014-11-01 08:56:55 +08:00
|
|
|
|
|
|
|
StringMap<FunctionSamples> &Profiles = Reader->getProfiles();
|
|
|
|
for (StringMap<FunctionSamples>::iterator I = Profiles.begin(),
|
|
|
|
E = Profiles.end();
|
|
|
|
I != E; ++I) {
|
|
|
|
StringRef FName = I->first();
|
|
|
|
FunctionSamples &Samples = I->second;
|
2015-12-17 05:45:43 +08:00
|
|
|
sampleprof_error Result = ProfileMap[FName].merge(Samples, Input.Weight);
|
|
|
|
if (Result != sampleprof_error::success) {
|
|
|
|
std::error_code EC = make_error_code(Result);
|
2016-05-19 11:54:45 +08:00
|
|
|
handleMergeWriterError(errorCodeToError(EC), Input.Filename, FName);
|
2015-12-17 05:45:43 +08:00
|
|
|
}
|
2014-11-01 08:56:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Writer->write(ProfileMap);
|
|
|
|
}
|
|
|
|
|
2015-12-16 01:37:09 +08:00
|
|
|
static WeightedFile parseWeightedFile(const StringRef &WeightedFilename) {
|
2016-06-07 07:43:56 +08:00
|
|
|
StringRef WeightStr, FileName;
|
|
|
|
std::tie(WeightStr, FileName) = WeightedFilename.split(',');
|
2015-12-16 01:37:09 +08:00
|
|
|
|
|
|
|
uint64_t Weight;
|
|
|
|
if (WeightStr.getAsInteger(10, Weight) || Weight < 1)
|
|
|
|
exitWithError("Input weight must be a positive integer.");
|
|
|
|
|
2016-07-21 22:29:11 +08:00
|
|
|
return {FileName, Weight};
|
2015-12-16 01:37:09 +08:00
|
|
|
}
|
|
|
|
|
2016-06-08 06:47:31 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-07-21 06:24:52 +08:00
|
|
|
static void addWeightedInput(WeightedFileVector &WNI, const WeightedFile &WF) {
|
|
|
|
StringRef Filename = WF.Filename;
|
|
|
|
uint64_t Weight = WF.Weight;
|
2016-07-22 20:39:55 +08:00
|
|
|
|
|
|
|
// If it's STDIN just pass it on.
|
|
|
|
if (Filename == "-") {
|
|
|
|
WNI.push_back({Filename, Weight});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-21 06:24:52 +08:00
|
|
|
llvm::sys::fs::file_status Status;
|
|
|
|
llvm::sys::fs::status(Filename, Status);
|
|
|
|
if (!llvm::sys::fs::exists(Status))
|
|
|
|
exitWithErrorCode(make_error_code(errc::no_such_file_or_directory),
|
|
|
|
Filename);
|
|
|
|
// If it's a source file, collect it.
|
|
|
|
if (llvm::sys::fs::is_regular_file(Status)) {
|
2016-07-21 22:29:11 +08:00
|
|
|
WNI.push_back({Filename, Weight});
|
2016-07-21 06:24:52 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (llvm::sys::fs::is_directory(Status)) {
|
|
|
|
std::error_code EC;
|
|
|
|
for (llvm::sys::fs::recursive_directory_iterator F(Filename, EC), E;
|
|
|
|
F != E && !EC; F.increment(EC)) {
|
|
|
|
if (llvm::sys::fs::is_regular_file(F->path())) {
|
|
|
|
addWeightedInput(WNI, {F->path(), Weight});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (EC)
|
|
|
|
exitWithErrorCode(EC, Filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-08 06:47:31 +08:00
|
|
|
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.find(',') == StringRef::npos)
|
2016-07-21 06:24:52 +08:00
|
|
|
addWeightedInput(WFV, {SanitizedEntry, 1});
|
2016-06-08 06:47:31 +08:00
|
|
|
else
|
2016-07-21 06:24:52 +08:00
|
|
|
addWeightedInput(WFV, parseWeightedFile(SanitizedEntry));
|
2016-06-08 06:47:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-16 01:37:09 +08:00
|
|
|
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>"));
|
2016-06-08 06:47:31 +08:00
|
|
|
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"));
|
2014-03-22 01:29:44 +08:00
|
|
|
cl::opt<std::string> OutputFilename("output", cl::value_desc("output"),
|
2014-11-01 08:56:55 +08:00
|
|
|
cl::init("-"), cl::Required,
|
2014-03-22 01:29:44 +08:00
|
|
|
cl::desc("Output file"));
|
|
|
|
cl::alias OutputFilenameA("o", cl::desc("Alias for --output"),
|
|
|
|
cl::aliasopt(OutputFilename));
|
2014-11-01 08:56:55 +08:00
|
|
|
cl::opt<ProfileKinds> ProfileKind(
|
|
|
|
cl::desc("Profile kind:"), cl::init(instr),
|
|
|
|
cl::values(clEnumVal(instr, "Instrumentation profile (default)"),
|
2016-10-09 03:41:06 +08:00
|
|
|
clEnumVal(sample, "Sample profile")));
|
2015-11-24 04:47:38 +08:00
|
|
|
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_Text, "text", "Text encoding"),
|
|
|
|
clEnumValN(PF_GCC, "gcc",
|
2016-10-09 03:41:06 +08:00
|
|
|
"GCC encoding (only meaningful for -sample)")));
|
2016-01-30 06:54:45 +08:00
|
|
|
cl::opt<bool> OutputSparse("sparse", cl::init(false),
|
|
|
|
cl::desc("Generate a sparse profile (only meaningful for -instr)"));
|
2016-07-19 09:17:20 +08:00
|
|
|
cl::opt<unsigned> NumThreads(
|
|
|
|
"num-threads", cl::init(0),
|
|
|
|
cl::desc("Number of merge threads to use (default: autodetect)"));
|
|
|
|
cl::alias NumThreadsA("j", cl::desc("Alias for --num-threads"),
|
|
|
|
cl::aliasopt(NumThreads));
|
2016-01-30 06:54:45 +08:00
|
|
|
|
2014-11-01 08:56:55 +08:00
|
|
|
cl::ParseCommandLineOptions(argc, argv, "LLVM profile data merger\n");
|
|
|
|
|
2016-06-07 07:43:56 +08:00
|
|
|
WeightedFileVector WeightedInputs;
|
|
|
|
for (StringRef Filename : InputFilenames)
|
2016-07-21 06:24:52 +08:00
|
|
|
addWeightedInput(WeightedInputs, {Filename, 1});
|
2016-06-07 07:43:56 +08:00
|
|
|
for (StringRef WeightedFilename : WeightedInputFilenames)
|
2016-07-21 06:24:52 +08:00
|
|
|
addWeightedInput(WeightedInputs, parseWeightedFile(WeightedFilename));
|
2016-06-08 06:47:31 +08:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
2016-06-04 08:36:28 +08:00
|
|
|
|
2014-11-01 08:56:55 +08:00
|
|
|
if (ProfileKind == instr)
|
2016-01-30 06:54:45 +08:00
|
|
|
mergeInstrProfile(WeightedInputs, OutputFilename, OutputFormat,
|
2016-07-19 09:17:20 +08:00
|
|
|
OutputSparse, NumThreads);
|
2014-11-01 08:56:55 +08:00
|
|
|
else
|
2015-12-16 01:37:09 +08:00
|
|
|
mergeSampleProfile(WeightedInputs, OutputFilename, OutputFormat);
|
2014-11-01 08:56:55 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2014-03-22 01:29:44 +08:00
|
|
|
|
2016-06-18 04:41:14 +08:00
|
|
|
static int showInstrProfile(const std::string &Filename, bool ShowCounts,
|
2016-01-14 05:44:36 +08:00
|
|
|
bool ShowIndirectCallTargets,
|
|
|
|
bool ShowDetailedSummary,
|
|
|
|
std::vector<uint32_t> DetailedSummaryCutoffs,
|
2016-06-18 04:41:14 +08:00
|
|
|
bool ShowAllFunctions,
|
|
|
|
const std::string &ShowFunction, bool TextFormat,
|
|
|
|
raw_fd_ostream &OS) {
|
2014-11-03 08:51:45 +08:00
|
|
|
auto ReaderOrErr = InstrProfReader::create(Filename);
|
2016-06-18 04:41:14 +08:00
|
|
|
std::vector<uint32_t> Cutoffs = std::move(DetailedSummaryCutoffs);
|
|
|
|
if (ShowDetailedSummary && Cutoffs.empty()) {
|
2016-01-14 05:44:36 +08:00
|
|
|
Cutoffs = {800000, 900000, 950000, 990000, 999000, 999900, 999990};
|
|
|
|
}
|
2016-06-18 04:41:14 +08:00
|
|
|
InstrProfSummaryBuilder Builder(std::move(Cutoffs));
|
2016-05-19 11:54:45 +08:00
|
|
|
if (Error E = ReaderOrErr.takeError())
|
|
|
|
exitWithError(std::move(E), Filename);
|
2014-03-22 01:29:44 +08:00
|
|
|
|
2014-11-03 08:51:45 +08:00
|
|
|
auto Reader = std::move(ReaderOrErr.get());
|
2016-02-11 01:18:30 +08:00
|
|
|
bool IsIRInstr = Reader->isIRLevelProfile();
|
2016-01-14 05:44:36 +08:00
|
|
|
size_t ShownFunctions = 0;
|
2016-05-24 00:36:11 +08:00
|
|
|
uint64_t TotalNumValueSites = 0;
|
|
|
|
uint64_t TotalNumValueSitesWithValueProfile = 0;
|
|
|
|
uint64_t TotalNumValues = 0;
|
2016-09-21 05:04:22 +08:00
|
|
|
std::vector<unsigned> ICHistogram;
|
2014-03-22 01:29:44 +08:00
|
|
|
for (const auto &Func : *Reader) {
|
2014-11-01 08:56:55 +08:00
|
|
|
bool Show =
|
|
|
|
ShowAllFunctions || (!ShowFunction.empty() &&
|
|
|
|
Func.Name.find(ShowFunction) != Func.Name.npos);
|
2014-03-22 01:29:44 +08:00
|
|
|
|
2015-11-24 04:47:38 +08:00
|
|
|
bool doTextFormatDump = (Show && ShowCounts && TextFormat);
|
|
|
|
|
|
|
|
if (doTextFormatDump) {
|
2015-12-20 14:22:13 +08:00
|
|
|
InstrProfSymtab &Symtab = Reader->getSymtab();
|
|
|
|
InstrProfWriter::writeRecordInText(Func, Symtab, OS);
|
2015-11-24 04:47:38 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-04-25 10:45:33 +08:00
|
|
|
assert(Func.Counts.size() > 0 && "function missing entry counter");
|
2016-05-20 05:07:12 +08:00
|
|
|
Builder.addRecord(Func);
|
2015-11-24 04:47:38 +08:00
|
|
|
|
2014-03-22 01:29:44 +08:00
|
|
|
if (Show) {
|
2015-11-24 04:47:38 +08:00
|
|
|
|
2014-03-22 01:29:44 +08:00
|
|
|
if (!ShownFunctions)
|
|
|
|
OS << "Counters:\n";
|
2015-11-24 04:47:38 +08:00
|
|
|
|
2014-03-22 01:29:44 +08:00
|
|
|
++ShownFunctions;
|
|
|
|
|
|
|
|
OS << " " << Func.Name << ":\n"
|
2014-03-24 04:43:50 +08:00
|
|
|
<< " Hash: " << format("0x%016" PRIx64, Func.Hash) << "\n"
|
2016-02-11 01:18:30 +08:00
|
|
|
<< " Counters: " << Func.Counts.size() << "\n";
|
|
|
|
if (!IsIRInstr)
|
|
|
|
OS << " Function count: " << Func.Counts[0] << "\n";
|
2015-11-24 04:47:38 +08:00
|
|
|
|
2015-09-30 06:13:58 +08:00
|
|
|
if (ShowIndirectCallTargets)
|
2015-11-02 13:08:23 +08:00
|
|
|
OS << " Indirect Call Site Count: "
|
|
|
|
<< Func.getNumValueSites(IPVK_IndirectCallTarget) << "\n";
|
2014-03-22 01:29:44 +08:00
|
|
|
|
2015-11-24 04:47:38 +08:00
|
|
|
if (ShowCounts) {
|
|
|
|
OS << " Block counts: [";
|
2016-02-11 01:18:30 +08:00
|
|
|
size_t Start = (IsIRInstr ? 0 : 1);
|
|
|
|
for (size_t I = Start, E = Func.Counts.size(); I < E; ++I) {
|
|
|
|
OS << (I == Start ? "" : ", ") << Func.Counts[I];
|
2015-11-24 04:47:38 +08:00
|
|
|
}
|
|
|
|
OS << "]\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ShowIndirectCallTargets) {
|
2015-12-20 14:22:13 +08:00
|
|
|
InstrProfSymtab &Symtab = Reader->getSymtab();
|
2015-11-24 04:47:38 +08:00
|
|
|
uint32_t NS = Func.getNumValueSites(IPVK_IndirectCallTarget);
|
|
|
|
OS << " Indirect Target Results: \n";
|
2016-05-24 00:36:11 +08:00
|
|
|
TotalNumValueSites += NS;
|
2015-11-24 04:47:38 +08:00
|
|
|
for (size_t I = 0; I < NS; ++I) {
|
|
|
|
uint32_t NV = Func.getNumValueDataForSite(IPVK_IndirectCallTarget, I);
|
|
|
|
std::unique_ptr<InstrProfValueData[]> VD =
|
|
|
|
Func.getValueForSite(IPVK_IndirectCallTarget, I);
|
2016-05-24 00:36:11 +08:00
|
|
|
TotalNumValues += NV;
|
2016-09-21 05:04:22 +08:00
|
|
|
if (NV) {
|
2016-05-24 00:36:11 +08:00
|
|
|
TotalNumValueSitesWithValueProfile++;
|
2016-09-21 05:04:22 +08:00
|
|
|
if (NV > ICHistogram.size())
|
|
|
|
ICHistogram.resize(NV, 0);
|
|
|
|
ICHistogram[NV - 1]++;
|
|
|
|
}
|
2015-11-24 04:47:38 +08:00
|
|
|
for (uint32_t V = 0; V < NV; V++) {
|
|
|
|
OS << "\t[ " << I << ", ";
|
2015-12-20 14:22:13 +08:00
|
|
|
OS << Symtab.getFuncName(VD[V].Value) << ", " << VD[V].Count
|
|
|
|
<< " ]\n";
|
2015-11-24 04:47:38 +08:00
|
|
|
}
|
2015-09-30 06:13:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-22 01:29:44 +08:00
|
|
|
}
|
2014-03-24 04:55:53 +08:00
|
|
|
if (Reader->hasError())
|
2016-05-19 11:54:45 +08:00
|
|
|
exitWithError(Reader->getError(), Filename);
|
2014-03-22 01:29:44 +08:00
|
|
|
|
2015-11-24 04:47:38 +08:00
|
|
|
if (ShowCounts && TextFormat)
|
|
|
|
return 0;
|
2016-05-20 05:53:28 +08:00
|
|
|
std::unique_ptr<ProfileSummary> PS(Builder.getSummary());
|
2014-03-22 01:29:44 +08:00
|
|
|
if (ShowAllFunctions || !ShowFunction.empty())
|
|
|
|
OS << "Functions shown: " << ShownFunctions << "\n";
|
2016-05-20 05:07:12 +08:00
|
|
|
OS << "Total functions: " << PS->getNumFunctions() << "\n";
|
|
|
|
OS << "Maximum function count: " << PS->getMaxFunctionCount() << "\n";
|
2016-05-20 05:53:28 +08:00
|
|
|
OS << "Maximum internal block count: " << PS->getMaxInternalCount() << "\n";
|
2016-05-24 00:36:11 +08:00
|
|
|
if (ShownFunctions && ShowIndirectCallTargets) {
|
|
|
|
OS << "Total Number of Indirect Call Sites : " << TotalNumValueSites
|
|
|
|
<< "\n";
|
|
|
|
OS << "Total Number of Sites With Values : "
|
|
|
|
<< TotalNumValueSitesWithValueProfile << "\n";
|
|
|
|
OS << "Total Number of Profiled Values : " << TotalNumValues << "\n";
|
2016-09-21 05:04:22 +08:00
|
|
|
|
|
|
|
OS << "IC Value histogram : \n\tNumTargets, SiteCount\n";
|
|
|
|
for (unsigned I = 0; I < ICHistogram.size(); I++) {
|
|
|
|
OS << "\t" << I + 1 << ", " << ICHistogram[I] << "\n";
|
|
|
|
}
|
2016-05-24 00:36:11 +08:00
|
|
|
}
|
2016-01-14 05:44:36 +08:00
|
|
|
|
|
|
|
if (ShowDetailedSummary) {
|
|
|
|
OS << "Detailed summary:\n";
|
2016-05-20 05:53:28 +08:00
|
|
|
OS << "Total number of blocks: " << PS->getNumCounts() << "\n";
|
2016-05-20 05:07:12 +08:00
|
|
|
OS << "Total count: " << PS->getTotalCount() << "\n";
|
|
|
|
for (auto Entry : PS->getDetailedSummary()) {
|
2016-02-18 02:18:47 +08:00
|
|
|
OS << Entry.NumCounts << " blocks with count >= " << Entry.MinCount
|
2016-01-14 05:44:36 +08:00
|
|
|
<< " account for "
|
|
|
|
<< format("%0.6g", (float)Entry.Cutoff / ProfileSummary::Scale * 100)
|
|
|
|
<< " percentage of the total counts.\n";
|
|
|
|
}
|
|
|
|
}
|
2014-03-22 01:29:44 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-06-18 04:41:14 +08:00
|
|
|
static int showSampleProfile(const std::string &Filename, bool ShowCounts,
|
|
|
|
bool ShowAllFunctions,
|
|
|
|
const std::string &ShowFunction,
|
2015-03-10 00:23:46 +08:00
|
|
|
raw_fd_ostream &OS) {
|
2014-11-01 08:56:55 +08:00
|
|
|
using namespace sampleprof;
|
2016-04-15 05:59:01 +08:00
|
|
|
LLVMContext Context;
|
|
|
|
auto ReaderOrErr = SampleProfileReader::create(Filename, Context);
|
2014-11-03 08:51:45 +08:00
|
|
|
if (std::error_code EC = ReaderOrErr.getError())
|
2015-11-13 11:47:58 +08:00
|
|
|
exitWithErrorCode(EC, Filename);
|
2014-11-01 08:56:55 +08:00
|
|
|
|
2014-11-03 08:51:45 +08:00
|
|
|
auto Reader = std::move(ReaderOrErr.get());
|
2015-09-17 08:17:21 +08:00
|
|
|
if (std::error_code EC = Reader->read())
|
2015-11-13 11:47:58 +08:00
|
|
|
exitWithErrorCode(EC, Filename);
|
2015-09-17 08:17:21 +08:00
|
|
|
|
2014-11-01 08:56:55 +08:00
|
|
|
if (ShowAllFunctions || ShowFunction.empty())
|
|
|
|
Reader->dump(OS);
|
|
|
|
else
|
|
|
|
Reader->dumpFunctionProfile(ShowFunction, OS);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-10 00:23:46 +08:00
|
|
|
static int show_main(int argc, const char *argv[]) {
|
2014-11-01 08:56:55 +08:00
|
|
|
cl::opt<std::string> Filename(cl::Positional, cl::Required,
|
|
|
|
cl::desc("<profdata-file>"));
|
|
|
|
|
|
|
|
cl::opt<bool> ShowCounts("counts", cl::init(false),
|
|
|
|
cl::desc("Show counter values for shown functions"));
|
2015-11-24 04:47:38 +08:00
|
|
|
cl::opt<bool> TextFormat(
|
|
|
|
"text", cl::init(false),
|
|
|
|
cl::desc("Show instr profile data in text dump format"));
|
2015-09-30 06:13:58 +08:00
|
|
|
cl::opt<bool> ShowIndirectCallTargets(
|
|
|
|
"ic-targets", cl::init(false),
|
|
|
|
cl::desc("Show indirect call site target values for shown functions"));
|
2016-01-14 05:44:36 +08:00
|
|
|
cl::opt<bool> ShowDetailedSummary("detailed-summary", cl::init(false),
|
|
|
|
cl::desc("Show detailed profile summary"));
|
|
|
|
cl::list<uint32_t> DetailedSummaryCutoffs(
|
|
|
|
cl::CommaSeparated, "detailed-summary-cutoffs",
|
|
|
|
cl::desc(
|
|
|
|
"Cutoff percentages (times 10000) for generating detailed summary"),
|
|
|
|
cl::value_desc("800000,901000,999999"));
|
2014-11-01 08:56:55 +08:00
|
|
|
cl::opt<bool> ShowAllFunctions("all-functions", cl::init(false),
|
|
|
|
cl::desc("Details for every function"));
|
|
|
|
cl::opt<std::string> ShowFunction("function",
|
|
|
|
cl::desc("Details for matching functions"));
|
|
|
|
|
|
|
|
cl::opt<std::string> OutputFilename("output", cl::value_desc("output"),
|
|
|
|
cl::init("-"), cl::desc("Output file"));
|
|
|
|
cl::alias OutputFilenameA("o", cl::desc("Alias for --output"),
|
|
|
|
cl::aliasopt(OutputFilename));
|
|
|
|
cl::opt<ProfileKinds> ProfileKind(
|
|
|
|
cl::desc("Profile kind:"), cl::init(instr),
|
|
|
|
cl::values(clEnumVal(instr, "Instrumentation profile (default)"),
|
2016-10-09 03:41:06 +08:00
|
|
|
clEnumVal(sample, "Sample profile")));
|
2014-11-01 08:56:55 +08:00
|
|
|
|
|
|
|
cl::ParseCommandLineOptions(argc, argv, "LLVM profile data summary\n");
|
|
|
|
|
|
|
|
if (OutputFilename.empty())
|
|
|
|
OutputFilename = "-";
|
|
|
|
|
|
|
|
std::error_code EC;
|
|
|
|
raw_fd_ostream OS(OutputFilename.data(), EC, sys::fs::F_Text);
|
|
|
|
if (EC)
|
2015-11-24 04:47:38 +08:00
|
|
|
exitWithErrorCode(EC, OutputFilename);
|
2014-11-01 08:56:55 +08:00
|
|
|
|
|
|
|
if (ShowAllFunctions && !ShowFunction.empty())
|
|
|
|
errs() << "warning: -function argument ignored: showing all functions\n";
|
|
|
|
|
2016-01-14 05:44:36 +08:00
|
|
|
std::vector<uint32_t> Cutoffs(DetailedSummaryCutoffs.begin(),
|
|
|
|
DetailedSummaryCutoffs.end());
|
2014-11-01 08:56:55 +08:00
|
|
|
if (ProfileKind == instr)
|
2015-09-30 06:13:58 +08:00
|
|
|
return showInstrProfile(Filename, ShowCounts, ShowIndirectCallTargets,
|
2016-01-14 05:44:36 +08:00
|
|
|
ShowDetailedSummary, DetailedSummaryCutoffs,
|
2015-11-24 04:47:38 +08:00
|
|
|
ShowAllFunctions, ShowFunction, TextFormat, OS);
|
2014-11-01 08:56:55 +08:00
|
|
|
else
|
|
|
|
return showSampleProfile(Filename, ShowCounts, ShowAllFunctions,
|
|
|
|
ShowFunction, OS);
|
|
|
|
}
|
|
|
|
|
2014-03-19 10:20:46 +08:00
|
|
|
int main(int argc, const char *argv[]) {
|
|
|
|
// Print a stack trace if we signal out.
|
2016-06-09 08:53:21 +08:00
|
|
|
sys::PrintStackTraceOnErrorSignal(argv[0]);
|
2014-03-19 10:20:46 +08:00
|
|
|
PrettyStackTraceProgram X(argc, argv);
|
|
|
|
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
|
|
|
|
|
|
|
|
StringRef ProgName(sys::path::filename(argv[0]));
|
|
|
|
if (argc > 1) {
|
2014-04-25 12:24:47 +08:00
|
|
|
int (*func)(int, const char *[]) = nullptr;
|
2014-03-19 10:20:46 +08:00
|
|
|
|
|
|
|
if (strcmp(argv[1], "merge") == 0)
|
|
|
|
func = merge_main;
|
2014-03-22 01:29:44 +08:00
|
|
|
else if (strcmp(argv[1], "show") == 0)
|
|
|
|
func = show_main;
|
2014-03-19 10:20:46 +08:00
|
|
|
|
|
|
|
if (func) {
|
|
|
|
std::string Invocation(ProgName.str() + " " + argv[1]);
|
|
|
|
argv[1] = Invocation.c_str();
|
|
|
|
return func(argc - 1, argv + 1);
|
|
|
|
}
|
|
|
|
|
2015-12-15 04:37:15 +08:00
|
|
|
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "-help") == 0 ||
|
2014-03-19 10:20:46 +08:00
|
|
|
strcmp(argv[1], "--help") == 0) {
|
|
|
|
|
|
|
|
errs() << "OVERVIEW: LLVM profile data tools\n\n"
|
|
|
|
<< "USAGE: " << ProgName << " <command> [args...]\n"
|
|
|
|
<< "USAGE: " << ProgName << " <command> -help\n\n"
|
2016-08-04 07:10:51 +08:00
|
|
|
<< "See each individual command --help for more details.\n"
|
2014-03-22 01:29:44 +08:00
|
|
|
<< "Available commands: merge, show\n";
|
2014-03-19 10:20:46 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc < 2)
|
|
|
|
errs() << ProgName << ": No command specified!\n";
|
|
|
|
else
|
|
|
|
errs() << ProgName << ": Unknown command!\n";
|
|
|
|
|
2014-03-22 01:29:44 +08:00
|
|
|
errs() << "USAGE: " << ProgName << " <merge|show> [args...]\n";
|
2014-03-19 10:20:46 +08:00
|
|
|
return 1;
|
|
|
|
}
|