diff options
| author | Roman Lebedev <lebedev.ri@gmail.com> | 2019-04-10 12:19:57 +0000 |
|---|---|---|
| committer | Roman Lebedev <lebedev.ri@gmail.com> | 2019-04-10 12:19:57 +0000 |
| commit | 628f1ae504207fec96529426fa42d7854c581230 (patch) | |
| tree | e00ce0f9d5b86a76a79438e7113b84cb4a30fc3b /llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp | |
| parent | 9b765de6dd1722e23d02feb98a3624474a57c680 (diff) | |
| download | bcm5719-llvm-628f1ae504207fec96529426fa42d7854c581230.tar.gz bcm5719-llvm-628f1ae504207fec96529426fa42d7854c581230.zip | |
[llvm-exegesis] Fix error propagation from yaml writing (from serialization)
Investigating https://bugs.llvm.org/show_bug.cgi?id=41448
llvm-svn: 358076
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp')
| -rw-r--r-- | llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp index c7a0c8470bb..ed8531f4400 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp @@ -365,27 +365,34 @@ InstructionBenchmark::readYamls(const LLVMState &State, } } -void InstructionBenchmark::writeYamlTo(const LLVMState &State, - llvm::raw_ostream &OS) { +llvm::Error InstructionBenchmark::writeYamlTo(const LLVMState &State, + llvm::raw_ostream &OS) { llvm::yaml::Output Yout(OS, nullptr /*Ctx*/, 200 /*WrapColumn*/); YamlContext Context(State); Yout.beginDocuments(); llvm::yaml::yamlize(Yout, *this, /*unused*/ true, Context); + if (!Context.getLastError().empty()) + return llvm::make_error<BenchmarkFailure>(Context.getLastError()); Yout.endDocuments(); + return Error::success(); } -void InstructionBenchmark::readYamlFrom(const LLVMState &State, - llvm::StringRef InputContent) { +llvm::Error InstructionBenchmark::readYamlFrom(const LLVMState &State, + llvm::StringRef InputContent) { llvm::yaml::Input Yin(InputContent); YamlContext Context(State); if (Yin.setCurrentDocument()) llvm::yaml::yamlize(Yin, *this, /*unused*/ true, Context); + if (!Context.getLastError().empty()) + return llvm::make_error<BenchmarkFailure>(Context.getLastError()); + return Error::success(); } llvm::Error InstructionBenchmark::writeYaml(const LLVMState &State, const llvm::StringRef Filename) { if (Filename == "-") { - writeYamlTo(State, llvm::outs()); + if (auto Err = writeYamlTo(State, llvm::outs())) + return std::move(Err); } else { int ResultFD = 0; if (auto E = llvm::errorCodeToError( @@ -394,7 +401,8 @@ llvm::Error InstructionBenchmark::writeYaml(const LLVMState &State, return E; } llvm::raw_fd_ostream Ostr(ResultFD, true /*shouldClose*/); - writeYamlTo(State, Ostr); + if (auto Err = writeYamlTo(State, Ostr)) + return std::move(Err); } return llvm::Error::success(); } |

