mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
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:
@@ -125,13 +125,13 @@ int main(int argc, char **argv) {
|
||||
|
||||
//Read the BrainF program
|
||||
BrainF bf;
|
||||
Module *mod = bf.parse(in, 65536, cf, Context); //64 KiB
|
||||
std::unique_ptr<Module> Mod(bf.parse(in, 65536, cf, Context)); // 64 KiB
|
||||
if (in != &std::cin)
|
||||
delete in;
|
||||
addMainFunction(mod);
|
||||
addMainFunction(Mod.get());
|
||||
|
||||
//Verify generated code
|
||||
if (verifyModule(*mod)) {
|
||||
if (verifyModule(*Mod)) {
|
||||
errs() << "Error: module failed verification. This shouldn't happen.\n";
|
||||
abort();
|
||||
}
|
||||
@@ -141,18 +141,18 @@ int main(int argc, char **argv) {
|
||||
InitializeNativeTarget();
|
||||
|
||||
outs() << "------- Running JIT -------\n";
|
||||
ExecutionEngine *ee = EngineBuilder(mod).create();
|
||||
Module &M = *Mod;
|
||||
ExecutionEngine *ee = EngineBuilder(std::move(Mod)).create();
|
||||
std::vector<GenericValue> args;
|
||||
Function *brainf_func = mod->getFunction("brainf");
|
||||
Function *brainf_func = M.getFunction("brainf");
|
||||
GenericValue gv = ee->runFunction(brainf_func, args);
|
||||
} else {
|
||||
WriteBitcodeToFile(mod, *out);
|
||||
WriteBitcodeToFile(Mod.get(), *out);
|
||||
}
|
||||
|
||||
//Clean up
|
||||
if (out != &outs())
|
||||
delete out;
|
||||
delete mod;
|
||||
|
||||
llvm_shutdown();
|
||||
|
||||
|
||||
@@ -1957,12 +1957,14 @@ int main(int argc, char *argv[]) {
|
||||
llvm::IRBuilder<> theBuilder(context);
|
||||
|
||||
// Make the module, which holds all the code.
|
||||
llvm::Module *module = new llvm::Module("my cool jit", context);
|
||||
std::unique_ptr<llvm::Module> Owner =
|
||||
llvm::make_unique<llvm::Module>("my cool jit", context);
|
||||
llvm::Module *module = Owner.get();
|
||||
|
||||
llvm::RTDyldMemoryManager *MemMgr = new llvm::SectionMemoryManager();
|
||||
|
||||
// Build engine with JIT
|
||||
llvm::EngineBuilder factory(module);
|
||||
llvm::EngineBuilder factory(std::move(Owner));
|
||||
factory.setEngineKind(llvm::EngineKind::JIT);
|
||||
factory.setAllocateGVsWithCode(false);
|
||||
factory.setTargetOptions(Opts);
|
||||
|
||||
@@ -96,15 +96,16 @@ int main(int argc, char **argv) {
|
||||
LLVMContext Context;
|
||||
|
||||
// Create some module to put our function into it.
|
||||
std::unique_ptr<Module> M(new Module("test", Context));
|
||||
std::unique_ptr<Module> Owner(new Module("test", Context));
|
||||
Module *M = Owner.get();
|
||||
|
||||
// We are about to create the "fib" function:
|
||||
Function *FibF = CreateFibFunction(M.get(), Context);
|
||||
Function *FibF = CreateFibFunction(M, Context);
|
||||
|
||||
// Now we going to create JIT
|
||||
std::string errStr;
|
||||
ExecutionEngine *EE =
|
||||
EngineBuilder(M.get())
|
||||
EngineBuilder(std::move(Owner))
|
||||
.setErrorStr(&errStr)
|
||||
.setEngineKind(EngineKind::JIT)
|
||||
.create();
|
||||
|
||||
@@ -56,7 +56,8 @@ int main() {
|
||||
LLVMContext Context;
|
||||
|
||||
// Create some module to put our function into it.
|
||||
Module *M = new Module("test", Context);
|
||||
std::unique_ptr<Module> Owner = make_unique<Module>("test", Context);
|
||||
Module *M = Owner.get();
|
||||
|
||||
// Create the add1 function entry and insert this entry into module M. The
|
||||
// function will have a return type of "int" and take an argument of "int".
|
||||
@@ -114,7 +115,7 @@ int main() {
|
||||
builder.CreateRet(Add1CallRes);
|
||||
|
||||
// Now we create the JIT.
|
||||
ExecutionEngine* EE = EngineBuilder(M).create();
|
||||
ExecutionEngine* EE = EngineBuilder(std::move(Owner)).create();
|
||||
|
||||
outs() << "We just constructed this LLVM module:\n\n" << *M;
|
||||
outs() << "\n\nRunning foo: ";
|
||||
|
||||
@@ -572,11 +572,13 @@ int main() {
|
||||
getNextToken();
|
||||
|
||||
// Make the module, which holds all the code.
|
||||
TheModule = new Module("my cool jit", Context);
|
||||
std::unique_ptr<Module> Owner = make_unique<Module>("my cool jit", Context);
|
||||
TheModule = Owner.get();
|
||||
|
||||
// Create the JIT. This takes ownership of the module.
|
||||
std::string ErrStr;
|
||||
TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
|
||||
TheExecutionEngine =
|
||||
EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
|
||||
if (!TheExecutionEngine) {
|
||||
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
|
||||
exit(1);
|
||||
|
||||
@@ -817,11 +817,13 @@ int main() {
|
||||
getNextToken();
|
||||
|
||||
// Make the module, which holds all the code.
|
||||
TheModule = new Module("my cool jit", Context);
|
||||
std::unique_ptr<Module> Owner = make_unique<Module>("my cool jit", Context);
|
||||
TheModule = Owner.get();
|
||||
|
||||
// Create the JIT. This takes ownership of the module.
|
||||
std::string ErrStr;
|
||||
TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
|
||||
TheExecutionEngine =
|
||||
EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
|
||||
if (!TheExecutionEngine) {
|
||||
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
|
||||
exit(1);
|
||||
|
||||
@@ -935,11 +935,13 @@ int main() {
|
||||
getNextToken();
|
||||
|
||||
// Make the module, which holds all the code.
|
||||
TheModule = new Module("my cool jit", Context);
|
||||
std::unique_ptr<Module> Owner = make_unique<Module>("my cool jit", Context);
|
||||
TheModule = Owner.get();
|
||||
|
||||
// Create the JIT. This takes ownership of the module.
|
||||
std::string ErrStr;
|
||||
TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
|
||||
TheExecutionEngine =
|
||||
EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
|
||||
if (!TheExecutionEngine) {
|
||||
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
|
||||
exit(1);
|
||||
|
||||
@@ -1099,11 +1099,13 @@ int main() {
|
||||
getNextToken();
|
||||
|
||||
// Make the module, which holds all the code.
|
||||
TheModule = new Module("my cool jit", Context);
|
||||
std::unique_ptr<Module> Owner = make_unique<Module>("my cool jit", Context);
|
||||
TheModule = Owner.get();
|
||||
|
||||
// Create the JIT. This takes ownership of the module.
|
||||
std::string ErrStr;
|
||||
TheExecutionEngine = EngineBuilder(TheModule).setErrorStr(&ErrStr).create();
|
||||
TheExecutionEngine =
|
||||
EngineBuilder(std::move(Owner)).setErrorStr(&ErrStr).create();
|
||||
if (!TheExecutionEngine) {
|
||||
fprintf(stderr, "Could not create ExecutionEngine: %s\n", ErrStr.c_str());
|
||||
exit(1);
|
||||
|
||||
@@ -243,13 +243,14 @@ int main() {
|
||||
LLVMContext Context;
|
||||
|
||||
// Create some module to put our function into it.
|
||||
Module *M = new Module("test", Context);
|
||||
std::unique_ptr<Module> Owner = make_unique<Module>("test", Context);
|
||||
Module *M = Owner.get();
|
||||
|
||||
Function* add1F = createAdd1( M );
|
||||
Function* fibF = CreateFibFunction( M );
|
||||
|
||||
// Now we create the JIT.
|
||||
ExecutionEngine* EE = EngineBuilder(M).create();
|
||||
ExecutionEngine* EE = EngineBuilder(std::move(Owner)).create();
|
||||
|
||||
//~ std::cout << "We just constructed this LLVM module:\n\n" << *M;
|
||||
//~ std::cout << "\n\nRunning foo: " << std::flush;
|
||||
|
||||
Reference in New Issue
Block a user