mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-18 13:34:04 +00:00
[LTO API] fix memory leakage introduced at r230290.
r230290 released the LLVM module but not the LTOModule. rdar://19024554 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230544 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
92d1637e2f
commit
f2a351a514
@ -155,6 +155,7 @@ private:
|
||||
typedef StringMap<uint8_t> StringSet;
|
||||
|
||||
void initialize();
|
||||
void destroyMergedModule();
|
||||
std::unique_ptr<LLVMContext> OwnedContext;
|
||||
LLVMContext &Context;
|
||||
Linker IRLinker;
|
||||
@ -172,6 +173,7 @@ private:
|
||||
TargetOptions Options;
|
||||
lto_diagnostic_handler_t DiagHandler;
|
||||
void *DiagContext;
|
||||
LTOModule *OwnedModule;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
@ -82,16 +82,27 @@ void LTOCodeGenerator::initialize() {
|
||||
CodeModel = LTO_CODEGEN_PIC_MODEL_DEFAULT;
|
||||
DiagHandler = nullptr;
|
||||
DiagContext = nullptr;
|
||||
OwnedModule = nullptr;
|
||||
|
||||
initializeLTOPasses();
|
||||
}
|
||||
|
||||
void LTOCodeGenerator::destroyMergedModule() {
|
||||
if (OwnedModule) {
|
||||
assert(IRLinker.getModule() == &OwnedModule->getModule() &&
|
||||
"The linker's module should be the same as the owned module");
|
||||
delete OwnedModule;
|
||||
OwnedModule = nullptr;
|
||||
} else if (IRLinker.getModule())
|
||||
IRLinker.deleteModule();
|
||||
}
|
||||
|
||||
LTOCodeGenerator::~LTOCodeGenerator() {
|
||||
destroyMergedModule();
|
||||
|
||||
delete TargetMach;
|
||||
TargetMach = nullptr;
|
||||
|
||||
IRLinker.deleteModule();
|
||||
|
||||
for (std::vector<char *>::iterator I = CodegenOptions.begin(),
|
||||
E = CodegenOptions.end();
|
||||
I != E; ++I)
|
||||
@ -146,10 +157,10 @@ void LTOCodeGenerator::setModule(LTOModule *Mod) {
|
||||
"Expected module in same context");
|
||||
|
||||
// Delete the old merged module.
|
||||
if (IRLinker.getModule())
|
||||
IRLinker.deleteModule();
|
||||
destroyMergedModule();
|
||||
AsmUndefinedRefs.clear();
|
||||
|
||||
OwnedModule = Mod;
|
||||
IRLinker.setModule(&Mod->getModule());
|
||||
|
||||
const std::vector<const char*> &Undefs = Mod->getAsmUndefinedRefs();
|
||||
|
Loading…
x
Reference in New Issue
Block a user