summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-lto2/llvm-lto2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-lto2/llvm-lto2.cpp')
-rw-r--r--llvm/tools/llvm-lto2/llvm-lto2.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index b9300b93990..370c7086af7 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -74,6 +74,22 @@ template <typename T> static T check(ErrorOr<T> E, std::string Msg) {
return T();
}
+namespace {
+// Define the LTOOutput handling
+class LTOOutput : public lto::NativeObjectOutput {
+ StringRef Path;
+
+public:
+ LTOOutput(StringRef Path) : Path(Path) {}
+ std::unique_ptr<raw_pwrite_stream> getStream() override {
+ std::error_code EC;
+ auto S = llvm::make_unique<raw_fd_ostream>(Path, EC, sys::fs::F_None);
+ check(EC, Path);
+ return std::move(S);
+ }
+};
+}
+
int main(int argc, char **argv) {
InitializeAllTargets();
InitializeAllTargetMCs();
@@ -156,13 +172,10 @@ int main(int argc, char **argv) {
if (HasErrors)
return 1;
- auto AddStream = [&](size_t Task) {
+ auto AddOutput = [&](size_t Task) {
std::string Path = OutputFilename + "." + utostr(Task);
- std::error_code EC;
- auto S = llvm::make_unique<raw_fd_ostream>(Path, EC, sys::fs::F_None);
- check(EC, Path);
- return S;
+ return llvm::make_unique<LTOOutput>(Path);
};
- check(Lto.run(AddStream), "LTO::run failed");
+ check(Lto.run(AddOutput), "LTO::run failed");
}
OpenPOWER on IntegriCloud