[llvm-commits] [llvm] r154288 - /llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
Benjamin Kramer
benny.kra at googlemail.com
Sun Apr 8 07:53:14 PDT 2012
Author: d0k
Date: Sun Apr 8 09:53:14 2012
New Revision: 154288
URL: http://llvm.org/viewvc/llvm-project?rev=154288&view=rev
Log:
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.
Modified:
llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=154288&r1=154287&r2=154288&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Sun Apr 8 09:53:14 2012
@@ -448,6 +448,8 @@
}
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 @@
// 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 @@
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;
}
}
More information about the llvm-commits
mailing list