#include "bolt/Profile/ProfileYAMLMapping.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/ThreadPool.h"
#include <algorithm>
#include <mutex>
#include <unordered_map>
usingnamespacellvm;
usingnamespacellvm::yaml::bolt;
namespace opts {
cl::OptionCategory MergeFdataCategory("merge-fdata options");
enum SortType : char { … };
static cl::list<std::string>
InputDataFilenames(
cl::Positional,
cl::CommaSeparated,
cl::desc("<fdata1> [<fdata2>]..."),
cl::OneOrMore,
cl::cat(MergeFdataCategory));
static cl::opt<SortType>
PrintFunctionList("print",
cl::desc("print the list of objects with count to stderr"),
cl::init(ST_NONE),
cl::values(clEnumValN(ST_NONE,
"none",
"do not print objects/functions"),
clEnumValN(ST_EXEC_COUNT,
"exec",
"print functions sorted by execution count"),
clEnumValN(ST_TOTAL_BRANCHES,
"branches",
"print functions sorted by total branch count")),
cl::cat(MergeFdataCategory));
static cl::opt<bool>
SuppressMergedDataOutput("q",
cl::desc("do not print merged data to stdout"),
cl::init(false),
cl::Optional,
cl::cat(MergeFdataCategory));
static cl::opt<std::string>
OutputFilePath("o",
cl::value_desc("file"),
cl::desc("Write output to <file>"),
cl::cat(MergeFdataCategory));
}
namespace {
static StringRef ToolName;
static void report_error(StringRef Message, std::error_code EC) { … }
static void report_error(Twine Message, StringRef CustomError) { … }
static raw_fd_ostream &output() { … }
void mergeProfileHeaders(BinaryProfileHeader &MergedHeader,
const BinaryProfileHeader &Header) { … }
void mergeBasicBlockProfile(BinaryBasicBlockProfile &MergedBB,
BinaryBasicBlockProfile &&BB,
const BinaryFunctionProfile &BF) { … }
void mergeFunctionProfile(BinaryFunctionProfile &MergedBF,
BinaryFunctionProfile &&BF) { … }
bool isYAML(const StringRef Filename) { … }
void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) { … }
}
int main(int argc, char **argv) { … }