mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-13 17:20:28 +00:00
unique_ptrify LTOCodeGenerator::NativeObjectFile
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216927 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7b96c4919a
commit
fc5b232004
@ -142,7 +142,7 @@ private:
|
|||||||
lto_codegen_model CodeModel;
|
lto_codegen_model CodeModel;
|
||||||
StringSet MustPreserveSymbols;
|
StringSet MustPreserveSymbols;
|
||||||
StringSet AsmUndefinedRefs;
|
StringSet AsmUndefinedRefs;
|
||||||
MemoryBuffer *NativeObjectFile;
|
std::unique_ptr<MemoryBuffer> NativeObjectFile;
|
||||||
std::vector<char *> CodegenOptions;
|
std::vector<char *> CodegenOptions;
|
||||||
std::string MCpu;
|
std::string MCpu;
|
||||||
std::string MAttr;
|
std::string MAttr;
|
||||||
|
@ -67,15 +67,13 @@ LTOCodeGenerator::LTOCodeGenerator()
|
|||||||
: Context(getGlobalContext()), IRLinker(new Module("ld-temp.o", Context)),
|
: Context(getGlobalContext()), IRLinker(new Module("ld-temp.o", Context)),
|
||||||
TargetMach(nullptr), EmitDwarfDebugInfo(false),
|
TargetMach(nullptr), EmitDwarfDebugInfo(false),
|
||||||
ScopeRestrictionsDone(false), CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT),
|
ScopeRestrictionsDone(false), CodeModel(LTO_CODEGEN_PIC_MODEL_DEFAULT),
|
||||||
NativeObjectFile(nullptr), DiagHandler(nullptr), DiagContext(nullptr) {
|
DiagHandler(nullptr), DiagContext(nullptr) {
|
||||||
initializeLTOPasses();
|
initializeLTOPasses();
|
||||||
}
|
}
|
||||||
|
|
||||||
LTOCodeGenerator::~LTOCodeGenerator() {
|
LTOCodeGenerator::~LTOCodeGenerator() {
|
||||||
delete TargetMach;
|
delete TargetMach;
|
||||||
delete NativeObjectFile;
|
|
||||||
TargetMach = nullptr;
|
TargetMach = nullptr;
|
||||||
NativeObjectFile = nullptr;
|
|
||||||
|
|
||||||
IRLinker.deleteModule();
|
IRLinker.deleteModule();
|
||||||
|
|
||||||
@ -234,9 +232,6 @@ const void* LTOCodeGenerator::compile(size_t* length,
|
|||||||
errMsg))
|
errMsg))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// remove old buffer if compile() called twice
|
|
||||||
delete NativeObjectFile;
|
|
||||||
|
|
||||||
// read .o file into memory buffer
|
// read .o file into memory buffer
|
||||||
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
|
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
|
||||||
MemoryBuffer::getFile(name, -1, false);
|
MemoryBuffer::getFile(name, -1, false);
|
||||||
@ -245,7 +240,7 @@ const void* LTOCodeGenerator::compile(size_t* length,
|
|||||||
sys::fs::remove(NativeObjectPath);
|
sys::fs::remove(NativeObjectPath);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
NativeObjectFile = BufferOrErr.get().release();
|
NativeObjectFile = std::move(*BufferOrErr);
|
||||||
|
|
||||||
// remove temp files
|
// remove temp files
|
||||||
sys::fs::remove(NativeObjectPath);
|
sys::fs::remove(NativeObjectPath);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user