Make it explicit that ExecutionEngine takes ownership of the modules.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215967 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-08-19 04:04:25 +00:00
parent 4d48c3f2a4
commit 3f4ed32b43
27 changed files with 242 additions and 223 deletions

View File

@ -30,9 +30,10 @@ static struct RegisterInterp {
extern "C" void LLVMLinkInInterpreter() { }
/// create - Create a new interpreter object. This can never fail.
/// Create a new interpreter object.
///
ExecutionEngine *Interpreter::create(Module *M, std::string* ErrStr) {
ExecutionEngine *Interpreter::create(std::unique_ptr<Module> M,
std::string *ErrStr) {
// Tell this Module to materialize everything and release the GVMaterializer.
if (std::error_code EC = M->materializeAllPermanently()) {
if (ErrStr)
@ -41,15 +42,15 @@ ExecutionEngine *Interpreter::create(Module *M, std::string* ErrStr) {
return nullptr;
}
return new Interpreter(M);
return new Interpreter(std::move(M));
}
//===----------------------------------------------------------------------===//
// Interpreter ctor - Initialize stuff
//
Interpreter::Interpreter(Module *M)
: ExecutionEngine(M), TD(M) {
Interpreter::Interpreter(std::unique_ptr<Module> M)
: ExecutionEngine(std::move(M)), TD(Modules.back().get()) {
memset(&ExitValue.Untyped, 0, sizeof(ExitValue.Untyped));
setDataLayout(&TD);
// Initialize the "backend"

View File

@ -94,7 +94,7 @@ class Interpreter : public ExecutionEngine, public InstVisitor<Interpreter> {
std::vector<Function*> AtExitHandlers;
public:
explicit Interpreter(Module *M);
explicit Interpreter(std::unique_ptr<Module> M);
~Interpreter();
/// runAtExitHandlers - Run any functions registered by the program's calls to
@ -105,10 +105,11 @@ public:
static void Register() {
InterpCtor = create;
}
/// create - Create an interpreter ExecutionEngine. This can never fail.
/// Create an interpreter ExecutionEngine.
///
static ExecutionEngine *create(Module *M, std::string *ErrorStr = nullptr);
static ExecutionEngine *create(std::unique_ptr<Module> M,
std::string *ErrorStr = nullptr);
/// run - Start execution with the specified function and arguments.
///