diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-04-08 14:53:14 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-04-08 14:53:14 +0000 |
commit | 0f554492467064b3198df509227a3e902cf7cf1f (patch) | |
tree | 0dfba6a87cfc1958802b365a9d0bb1304b3ebb1e /lib/ExecutionEngine/ExecutionEngine.cpp | |
parent | 5e93a7672222853cdf5dd261c322e6f89d40be01 (diff) |
EngineBuilder::create is expected to take ownership of the TargetMachine passed to it. Delete it on error or when we create an interpreter that doesn't need it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154288 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/ExecutionEngine.cpp')
-rw-r--r-- | lib/ExecutionEngine/ExecutionEngine.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 9f7b20f20b..a744d0c1e7 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -448,6 +448,8 @@ ExecutionEngine *ExecutionEngine::createJIT(Module *M, } ExecutionEngine *EngineBuilder::create(TargetMachine *TM) { + OwningPtr<TargetMachine> TheTM(TM); // Take ownership. + // Make sure we can resolve symbols in the program as well. The zero arg // to the function tells DynamicLibrary to load the program, not a library. if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr)) @@ -468,7 +470,7 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) { // Unless the interpreter was explicitly selected or the JIT is not linked, // try making a JIT. - if ((WhichEngine & EngineKind::JIT) && TM) { + if ((WhichEngine & EngineKind::JIT) && TheTM) { Triple TT(M->getTargetTriple()); if (!TM->getTarget().hasJIT()) { errs() << "WARNING: This target JIT is not designed for the host" @@ -479,12 +481,12 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) { if (UseMCJIT && ExecutionEngine::MCJITCtor) { ExecutionEngine *EE = ExecutionEngine::MCJITCtor(M, ErrorStr, JMM, - AllocateGVsWithCode, TM); + AllocateGVsWithCode, TheTM.take()); if (EE) return EE; } else if (ExecutionEngine::JITCtor) { ExecutionEngine *EE = ExecutionEngine::JITCtor(M, ErrorStr, JMM, - AllocateGVsWithCode, TM); + AllocateGVsWithCode, TheTM.take()); if (EE) return EE; } } |