mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 18:24:00 +00:00
Make the C++ LTO API easier to use from C++ clients.
Start using C++ types such as StringRef and MemoryBuffer in the C++ LTO API. In doing so, clarify the ownership of the native object file: the caller now owns it, not the LTOCodeGenerator. The C libLTO library has been modified to use a derived class of LTOCodeGenerator that owns the object file. Differential Revision: http://reviews.llvm.org/D10114 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238776 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -250,8 +250,8 @@ bool LTOCodeGenerator::compileOptimizedToFile(const char **name,
|
||||
return true;
|
||||
}
|
||||
|
||||
const void *LTOCodeGenerator::compileOptimized(size_t *length,
|
||||
std::string &errMsg) {
|
||||
std::unique_ptr<MemoryBuffer>
|
||||
LTOCodeGenerator::compileOptimized(std::string &errMsg) {
|
||||
const char *name;
|
||||
if (!compileOptimizedToFile(&name, errMsg))
|
||||
return nullptr;
|
||||
@ -264,16 +264,11 @@ const void *LTOCodeGenerator::compileOptimized(size_t *length,
|
||||
sys::fs::remove(NativeObjectPath);
|
||||
return nullptr;
|
||||
}
|
||||
NativeObjectFile = std::move(*BufferOrErr);
|
||||
|
||||
// remove temp files
|
||||
sys::fs::remove(NativeObjectPath);
|
||||
|
||||
// return buffer, unless error
|
||||
if (!NativeObjectFile)
|
||||
return nullptr;
|
||||
*length = NativeObjectFile->getBufferSize();
|
||||
return NativeObjectFile->getBufferStart();
|
||||
return std::move(*BufferOrErr);
|
||||
}
|
||||
|
||||
|
||||
@ -289,16 +284,14 @@ bool LTOCodeGenerator::compile_to_file(const char **name,
|
||||
return compileOptimizedToFile(name, errMsg);
|
||||
}
|
||||
|
||||
const void* LTOCodeGenerator::compile(size_t *length,
|
||||
bool disableInline,
|
||||
bool disableGVNLoadPRE,
|
||||
bool disableVectorization,
|
||||
std::string &errMsg) {
|
||||
std::unique_ptr<MemoryBuffer>
|
||||
LTOCodeGenerator::compile(bool disableInline, bool disableGVNLoadPRE,
|
||||
bool disableVectorization, std::string &errMsg) {
|
||||
if (!optimize(disableInline, disableGVNLoadPRE,
|
||||
disableVectorization, errMsg))
|
||||
return nullptr;
|
||||
|
||||
return compileOptimized(length, errMsg);
|
||||
return compileOptimized(errMsg);
|
||||
}
|
||||
|
||||
bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
|
||||
|
Reference in New Issue
Block a user