mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-30 05:24:22 +00:00
Use ErrorOr for the ::create factory on instrumented and sample profilers.
Summary: As discussed in http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20141027/242445.html, the creation of reader and writer instances is better done using ErrorOr. There are no functional changes, but several callers needed to be adjusted. Reviewers: bogner Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6076 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221120 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -49,10 +49,11 @@ void mergeInstrProfile(cl::list<std::string> Inputs, StringRef OutputFilename) {
|
||||
|
||||
InstrProfWriter Writer;
|
||||
for (const auto &Filename : Inputs) {
|
||||
std::unique_ptr<InstrProfReader> Reader;
|
||||
if (std::error_code ec = InstrProfReader::create(Filename, Reader))
|
||||
auto ReaderOrErr = InstrProfReader::create(Filename);
|
||||
if (std::error_code ec = ReaderOrErr.getError())
|
||||
exitWithError(ec.message(), Filename);
|
||||
|
||||
auto Reader = std::move(ReaderOrErr.get());
|
||||
for (const auto &I : *Reader)
|
||||
if (std::error_code EC =
|
||||
Writer.addFunctionCounts(I.Name, I.Hash, I.Counts))
|
||||
@ -66,18 +67,19 @@ void mergeInstrProfile(cl::list<std::string> Inputs, StringRef OutputFilename) {
|
||||
void mergeSampleProfile(cl::list<std::string> Inputs, StringRef OutputFilename,
|
||||
sampleprof::SampleProfileFormat OutputFormat) {
|
||||
using namespace sampleprof;
|
||||
std::unique_ptr<SampleProfileWriter> Writer;
|
||||
if (std::error_code EC = SampleProfileWriter::create(OutputFilename.data(),
|
||||
Writer, OutputFormat))
|
||||
auto WriterOrErr = SampleProfileWriter::create(OutputFilename, OutputFormat);
|
||||
if (std::error_code EC = WriterOrErr.getError())
|
||||
exitWithError(EC.message(), OutputFilename);
|
||||
|
||||
auto Writer = std::move(WriterOrErr.get());
|
||||
StringMap<FunctionSamples> ProfileMap;
|
||||
for (const auto &Filename : Inputs) {
|
||||
std::unique_ptr<SampleProfileReader> Reader;
|
||||
if (std::error_code EC =
|
||||
SampleProfileReader::create(Filename, Reader, getGlobalContext()))
|
||||
auto ReaderOrErr =
|
||||
SampleProfileReader::create(Filename, getGlobalContext());
|
||||
if (std::error_code EC = ReaderOrErr.getError())
|
||||
exitWithError(EC.message(), Filename);
|
||||
|
||||
auto Reader = std::move(ReaderOrErr.get());
|
||||
if (std::error_code EC = Reader->read())
|
||||
exitWithError(EC.message(), Filename);
|
||||
|
||||
@ -129,10 +131,11 @@ int merge_main(int argc, const char *argv[]) {
|
||||
int showInstrProfile(std::string Filename, bool ShowCounts,
|
||||
bool ShowAllFunctions, std::string ShowFunction,
|
||||
raw_fd_ostream &OS) {
|
||||
std::unique_ptr<InstrProfReader> Reader;
|
||||
if (std::error_code EC = InstrProfReader::create(Filename, Reader))
|
||||
auto ReaderOrErr = InstrProfReader::create(Filename);
|
||||
if (std::error_code EC = ReaderOrErr.getError())
|
||||
exitWithError(EC.message(), Filename);
|
||||
|
||||
auto Reader = std::move(ReaderOrErr.get());
|
||||
uint64_t MaxFunctionCount = 0, MaxBlockCount = 0;
|
||||
size_t ShownFunctions = 0, TotalFunctions = 0;
|
||||
for (const auto &Func : *Reader) {
|
||||
@ -182,11 +185,11 @@ int showSampleProfile(std::string Filename, bool ShowCounts,
|
||||
bool ShowAllFunctions, std::string ShowFunction,
|
||||
raw_fd_ostream &OS) {
|
||||
using namespace sampleprof;
|
||||
std::unique_ptr<SampleProfileReader> Reader;
|
||||
if (std::error_code EC =
|
||||
SampleProfileReader::create(Filename, Reader, getGlobalContext()))
|
||||
auto ReaderOrErr = SampleProfileReader::create(Filename, getGlobalContext());
|
||||
if (std::error_code EC = ReaderOrErr.getError())
|
||||
exitWithError(EC.message(), Filename);
|
||||
|
||||
auto Reader = std::move(ReaderOrErr.get());
|
||||
Reader->read();
|
||||
if (ShowAllFunctions || ShowFunction.empty())
|
||||
Reader->dump(OS);
|
||||
|
Reference in New Issue
Block a user