[llvm] r358076 - [llvm-exegesis] Fix error propagation from yaml writing (from serialization)
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 05:19:57 PDT 2019
Author: lebedevri
Date: Wed Apr 10 05:19:57 2019
New Revision: 358076
URL: http://llvm.org/viewvc/llvm-project?rev=358076&view=rev
Log:
[llvm-exegesis] Fix error propagation from yaml writing (from serialization)
Investigating https://bugs.llvm.org/show_bug.cgi?id=41448
Modified:
llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp
llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h
Modified: llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp?rev=358076&r1=358075&r2=358076&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp Wed Apr 10 05:19:57 2019
@@ -365,27 +365,34 @@ InstructionBenchmark::readYamls(const LL
}
}
-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::writeY
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();
}
Modified: llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h?rev=358076&r1=358075&r2=358076&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.h Wed Apr 10 05:19:57 2019
@@ -79,10 +79,11 @@ struct InstructionBenchmark {
static llvm::Expected<std::vector<InstructionBenchmark>>
readYamls(const LLVMState &State, llvm::StringRef Filename);
- void readYamlFrom(const LLVMState &State, llvm::StringRef InputContent);
+ llvm::Error readYamlFrom(const LLVMState &State,
+ llvm::StringRef InputContent);
// Write functions, non-const because of YAML traits.
- void writeYamlTo(const LLVMState &State, llvm::raw_ostream &S);
+ llvm::Error writeYamlTo(const LLVMState &State, llvm::raw_ostream &S);
llvm::Error writeYaml(const LLVMState &State, const llvm::StringRef Filename);
};
More information about the llvm-commits
mailing list