- // return buffer, unless error
- if (NativeObjectFile == NULL)
- return NULL;
- *length = NativeObjectFile->getBufferSize();
- return NativeObjectFile->getBufferStart();
+ return std::move(*BufferOrErr);
+}
+
+bool LTOCodeGenerator::compile_to_file(const char **Name, bool DisableVerify,
+ bool DisableInline,
+ bool DisableGVNLoadPRE,
+ bool DisableVectorization,
+ std::string &ErrMsg) {
+ if (!optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
+ DisableVectorization, ErrMsg))
+ return false;
+
+ return compileOptimizedToFile(Name, ErrMsg);
+}
+
+std::unique_ptr<MemoryBuffer>
+LTOCodeGenerator::compile(bool DisableVerify, bool DisableInline,
+ bool DisableGVNLoadPRE, bool DisableVectorization,
+ std::string &ErrMsg) {
+ if (!optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
+ DisableVectorization, ErrMsg))
+ return nullptr;
+
+ return compileOptimized(ErrMsg);