mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +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:
@@ -20,9 +20,10 @@ namespace {
|
||||
|
||||
class ExecutionEngineTest : public testing::Test {
|
||||
protected:
|
||||
ExecutionEngineTest()
|
||||
: M(new Module("<main>", getGlobalContext())), Error(""),
|
||||
Engine(EngineBuilder(M).setErrorStr(&Error).create()) {
|
||||
ExecutionEngineTest() {
|
||||
auto Owner = make_unique<Module>("<main>", getGlobalContext());
|
||||
M = Owner.get();
|
||||
Engine.reset(EngineBuilder(std::move(Owner)).setErrorStr(&Error).create());
|
||||
}
|
||||
|
||||
virtual void SetUp() {
|
||||
@@ -35,9 +36,9 @@ protected:
|
||||
GlobalValue::ExternalLinkage, nullptr, Name);
|
||||
}
|
||||
|
||||
Module *const M;
|
||||
std::string Error;
|
||||
const std::unique_ptr<ExecutionEngine> Engine;
|
||||
Module *M; // Owned by ExecutionEngine.
|
||||
std::unique_ptr<ExecutionEngine> Engine;
|
||||
};
|
||||
|
||||
TEST_F(ExecutionEngineTest, ForwardGlobalMapping) {
|
||||
|
@@ -60,15 +60,16 @@ struct RecordingJITEventListener : public JITEventListener {
|
||||
|
||||
class JITEventListenerTest : public testing::Test {
|
||||
protected:
|
||||
JITEventListenerTest()
|
||||
: M(new Module("module", getGlobalContext())),
|
||||
EE(EngineBuilder(M)
|
||||
.setEngineKind(EngineKind::JIT)
|
||||
.create()) {
|
||||
}
|
||||
JITEventListenerTest() {
|
||||
auto Owner = make_unique<Module>("module", getGlobalContext());
|
||||
M = Owner.get();
|
||||
EE.reset(EngineBuilder(std::move(Owner))
|
||||
.setEngineKind(EngineKind::JIT)
|
||||
.create());
|
||||
}
|
||||
|
||||
Module *M;
|
||||
const std::unique_ptr<ExecutionEngine> EE;
|
||||
std::unique_ptr<ExecutionEngine> EE;
|
||||
};
|
||||
|
||||
// Tests on SystemZ disabled as we're running the old JIT
|
||||
|
@@ -184,15 +184,18 @@ class JITTest : public testing::Test {
|
||||
}
|
||||
|
||||
virtual void SetUp() {
|
||||
M = new Module("<main>", Context);
|
||||
std::unique_ptr<Module> Owner = make_unique<Module>("<main>", Context);
|
||||
M = Owner.get();
|
||||
RJMM = createMemoryManager();
|
||||
RJMM->setPoisonMemory(true);
|
||||
std::string Error;
|
||||
TargetOptions Options;
|
||||
TheJIT.reset(EngineBuilder(M).setEngineKind(EngineKind::JIT)
|
||||
.setJITMemoryManager(RJMM)
|
||||
.setErrorStr(&Error)
|
||||
.setTargetOptions(Options).create());
|
||||
TheJIT.reset(EngineBuilder(std::move(Owner))
|
||||
.setEngineKind(EngineKind::JIT)
|
||||
.setJITMemoryManager(RJMM)
|
||||
.setErrorStr(&Error)
|
||||
.setTargetOptions(Options)
|
||||
.create());
|
||||
ASSERT_TRUE(TheJIT.get() != nullptr) << Error;
|
||||
}
|
||||
|
||||
@@ -213,14 +216,15 @@ class JITTest : public testing::Test {
|
||||
// stays alive after that.
|
||||
TEST(JIT, GlobalInFunction) {
|
||||
LLVMContext context;
|
||||
Module *M = new Module("<main>", context);
|
||||
std::unique_ptr<Module> Owner = make_unique<Module>("<main>", context);
|
||||
Module *M = Owner.get();
|
||||
|
||||
JITMemoryManager *MemMgr = JITMemoryManager::CreateDefaultMemManager();
|
||||
// Tell the memory manager to poison freed memory so that accessing freed
|
||||
// memory is more easily tested.
|
||||
MemMgr->setPoisonMemory(true);
|
||||
std::string Error;
|
||||
std::unique_ptr<ExecutionEngine> JIT(EngineBuilder(M)
|
||||
std::unique_ptr<ExecutionEngine> JIT(EngineBuilder(std::move(Owner))
|
||||
.setEngineKind(EngineKind::JIT)
|
||||
.setErrorStr(&Error)
|
||||
.setJITMemoryManager(MemMgr)
|
||||
@@ -638,9 +642,10 @@ ExecutionEngine *getJITFromBitcode(
|
||||
delete BitcodeBuffer;
|
||||
return nullptr;
|
||||
}
|
||||
M = ModuleOrErr.get();
|
||||
std::unique_ptr<Module> Owner(ModuleOrErr.get());
|
||||
M = Owner.get();
|
||||
std::string errMsg;
|
||||
ExecutionEngine *TheJIT = EngineBuilder(M)
|
||||
ExecutionEngine *TheJIT = EngineBuilder(std::move(Owner))
|
||||
.setEngineKind(EngineKind::JIT)
|
||||
.setErrorStr(&errMsg)
|
||||
.create();
|
||||
|
@@ -24,20 +24,20 @@ namespace {
|
||||
#if !defined(__arm__) && !defined(__powerpc__) && !defined(__s390__) \
|
||||
&& !defined(__aarch64__)
|
||||
|
||||
bool LoadAssemblyInto(Module *M, const char *assembly) {
|
||||
std::unique_ptr<Module> loadAssembly(LLVMContext &Context,
|
||||
const char *Assembly) {
|
||||
SMDiagnostic Error;
|
||||
bool success =
|
||||
nullptr != ParseAssemblyString(assembly, M, Error, M->getContext());
|
||||
std::unique_ptr<Module> Ret(
|
||||
ParseAssemblyString(Assembly, nullptr, Error, Context));
|
||||
std::string errMsg;
|
||||
raw_string_ostream os(errMsg);
|
||||
Error.print("", os);
|
||||
EXPECT_TRUE(success) << os.str();
|
||||
return success;
|
||||
EXPECT_TRUE((bool)Ret) << os.str();
|
||||
return std::move(Ret);
|
||||
}
|
||||
|
||||
void createModule1(LLVMContext &Context1, Module *&M1, Function *&FooF1) {
|
||||
M1 = new Module("test1", Context1);
|
||||
LoadAssemblyInto(M1,
|
||||
std::unique_ptr<Module> createModule1(LLVMContext &Context1, Function *&FooF1) {
|
||||
std::unique_ptr<Module> Ret = loadAssembly(Context1,
|
||||
"define i32 @add1(i32 %ArgX1) { "
|
||||
"entry: "
|
||||
" %addresult = add i32 1, %ArgX1 "
|
||||
@@ -49,12 +49,12 @@ void createModule1(LLVMContext &Context1, Module *&M1, Function *&FooF1) {
|
||||
" %add1 = call i32 @add1(i32 10) "
|
||||
" ret i32 %add1 "
|
||||
"} ");
|
||||
FooF1 = M1->getFunction("foo1");
|
||||
FooF1 = Ret->getFunction("foo1");
|
||||
return std::move(Ret);
|
||||
}
|
||||
|
||||
void createModule2(LLVMContext &Context2, Module *&M2, Function *&FooF2) {
|
||||
M2 = new Module("test2", Context2);
|
||||
LoadAssemblyInto(M2,
|
||||
std::unique_ptr<Module> createModule2(LLVMContext &Context2, Function *&FooF2) {
|
||||
std::unique_ptr<Module> Ret = loadAssembly(Context2,
|
||||
"define i32 @add2(i32 %ArgX2) { "
|
||||
"entry: "
|
||||
" %addresult = add i32 2, %ArgX2 "
|
||||
@@ -66,24 +66,23 @@ void createModule2(LLVMContext &Context2, Module *&M2, Function *&FooF2) {
|
||||
" %add2 = call i32 @add2(i32 10) "
|
||||
" ret i32 %add2 "
|
||||
"} ");
|
||||
FooF2 = M2->getFunction("foo2");
|
||||
FooF2 = Ret->getFunction("foo2");
|
||||
return std::move(Ret);
|
||||
}
|
||||
|
||||
TEST(MultiJitTest, EagerMode) {
|
||||
LLVMContext Context1;
|
||||
Module *M1 = nullptr;
|
||||
Function *FooF1 = nullptr;
|
||||
createModule1(Context1, M1, FooF1);
|
||||
std::unique_ptr<Module> M1 = createModule1(Context1, FooF1);
|
||||
|
||||
LLVMContext Context2;
|
||||
Module *M2 = nullptr;
|
||||
Function *FooF2 = nullptr;
|
||||
createModule2(Context2, M2, FooF2);
|
||||
std::unique_ptr<Module> M2 = createModule2(Context2, FooF2);
|
||||
|
||||
// Now we create the JIT in eager mode
|
||||
std::unique_ptr<ExecutionEngine> EE1(EngineBuilder(M1).create());
|
||||
std::unique_ptr<ExecutionEngine> EE1(EngineBuilder(std::move(M1)).create());
|
||||
EE1->DisableLazyCompilation(true);
|
||||
std::unique_ptr<ExecutionEngine> EE2(EngineBuilder(M2).create());
|
||||
std::unique_ptr<ExecutionEngine> EE2(EngineBuilder(std::move(M2)).create());
|
||||
EE2->DisableLazyCompilation(true);
|
||||
|
||||
// Call the `foo' function with no arguments:
|
||||
@@ -101,19 +100,17 @@ TEST(MultiJitTest, EagerMode) {
|
||||
|
||||
TEST(MultiJitTest, LazyMode) {
|
||||
LLVMContext Context1;
|
||||
Module *M1 = nullptr;
|
||||
Function *FooF1 = nullptr;
|
||||
createModule1(Context1, M1, FooF1);
|
||||
std::unique_ptr<Module> M1 = createModule1(Context1, FooF1);
|
||||
|
||||
LLVMContext Context2;
|
||||
Module *M2 = nullptr;
|
||||
Function *FooF2 = nullptr;
|
||||
createModule2(Context2, M2, FooF2);
|
||||
std::unique_ptr<Module> M2 = createModule2(Context2, FooF2);
|
||||
|
||||
// Now we create the JIT in lazy mode
|
||||
std::unique_ptr<ExecutionEngine> EE1(EngineBuilder(M1).create());
|
||||
std::unique_ptr<ExecutionEngine> EE1(EngineBuilder(std::move(M1)).create());
|
||||
EE1->DisableLazyCompilation(false);
|
||||
std::unique_ptr<ExecutionEngine> EE2(EngineBuilder(M2).create());
|
||||
std::unique_ptr<ExecutionEngine> EE2(EngineBuilder(std::move(M2)).create());
|
||||
EE2->DisableLazyCompilation(false);
|
||||
|
||||
// Call the `foo' function with no arguments:
|
||||
@@ -135,18 +132,16 @@ extern "C" {
|
||||
|
||||
TEST(MultiJitTest, JitPool) {
|
||||
LLVMContext Context1;
|
||||
Module *M1 = nullptr;
|
||||
Function *FooF1 = nullptr;
|
||||
createModule1(Context1, M1, FooF1);
|
||||
std::unique_ptr<Module> M1 = createModule1(Context1, FooF1);
|
||||
|
||||
LLVMContext Context2;
|
||||
Module *M2 = nullptr;
|
||||
Function *FooF2 = nullptr;
|
||||
createModule2(Context2, M2, FooF2);
|
||||
std::unique_ptr<Module> M2 = createModule2(Context2, FooF2);
|
||||
|
||||
// Now we create two JITs
|
||||
std::unique_ptr<ExecutionEngine> EE1(EngineBuilder(M1).create());
|
||||
std::unique_ptr<ExecutionEngine> EE2(EngineBuilder(M2).create());
|
||||
std::unique_ptr<ExecutionEngine> EE1(EngineBuilder(std::move(M1)).create());
|
||||
std::unique_ptr<ExecutionEngine> EE2(EngineBuilder(std::move(M2)).create());
|
||||
|
||||
Function *F1 = EE1->FindFunctionNamed("foo1");
|
||||
void *foo1 = EE1->getPointerToFunction(F1);
|
||||
|
@@ -94,8 +94,8 @@ TEST_F(MCJITMultipleModuleTest, two_module_case) {
|
||||
Function *FA, *FB;
|
||||
createTwoModuleCase(A, FA, B, FB);
|
||||
|
||||
createJIT(A.release());
|
||||
TheJIT->addModule(B.release());
|
||||
createJIT(std::move(A));
|
||||
TheJIT->addModule(std::move(B));
|
||||
|
||||
uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
|
||||
checkAdd(ptr);
|
||||
@@ -114,8 +114,8 @@ TEST_F(MCJITMultipleModuleTest, two_module_reverse_case) {
|
||||
Function *FA, *FB;
|
||||
createTwoModuleCase(A, FA, B, FB);
|
||||
|
||||
createJIT(A.release());
|
||||
TheJIT->addModule(B.release());
|
||||
createJIT(std::move(A));
|
||||
TheJIT->addModule(std::move(B));
|
||||
|
||||
uint64_t ptr = TheJIT->getFunctionAddress(FB->getName().str());
|
||||
TheJIT->finalizeObject();
|
||||
@@ -135,8 +135,8 @@ TEST_F(MCJITMultipleModuleTest, two_module_extern_reverse_case) {
|
||||
Function *FA, *FB;
|
||||
createTwoModuleExternCase(A, FA, B, FB);
|
||||
|
||||
createJIT(A.release());
|
||||
TheJIT->addModule(B.release());
|
||||
createJIT(std::move(A));
|
||||
TheJIT->addModule(std::move(B));
|
||||
|
||||
uint64_t ptr = TheJIT->getFunctionAddress(FB->getName().str());
|
||||
TheJIT->finalizeObject();
|
||||
@@ -156,8 +156,8 @@ TEST_F(MCJITMultipleModuleTest, two_module_extern_case) {
|
||||
Function *FA, *FB;
|
||||
createTwoModuleExternCase(A, FA, B, FB);
|
||||
|
||||
createJIT(A.release());
|
||||
TheJIT->addModule(B.release());
|
||||
createJIT(std::move(A));
|
||||
TheJIT->addModule(std::move(B));
|
||||
|
||||
uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
|
||||
checkAdd(ptr);
|
||||
@@ -177,8 +177,8 @@ TEST_F(MCJITMultipleModuleTest, two_module_consecutive_call_case) {
|
||||
createTwoModuleExternCase(A, FA1, B, FB);
|
||||
FA2 = insertSimpleCallFunction<int32_t(int32_t, int32_t)>(A.get(), FA1);
|
||||
|
||||
createJIT(A.release());
|
||||
TheJIT->addModule(B.release());
|
||||
createJIT(std::move(A));
|
||||
TheJIT->addModule(std::move(B));
|
||||
|
||||
uint64_t ptr = TheJIT->getFunctionAddress(FB->getName().str());
|
||||
TheJIT->finalizeObject();
|
||||
@@ -213,8 +213,8 @@ TEST_F(MCJITMultipleModuleTest, two_module_global_variables_case) {
|
||||
FB = startFunction<int32_t(void)>(B.get(), "FB");
|
||||
endFunctionWithRet(FB, Builder.CreateLoad(GVB));
|
||||
|
||||
createJIT(A.release());
|
||||
TheJIT->addModule(B.release());
|
||||
createJIT(std::move(A));
|
||||
TheJIT->addModule(std::move(B));
|
||||
|
||||
uint64_t FBPtr = TheJIT->getFunctionAddress(FB->getName().str());
|
||||
TheJIT->finalizeObject();
|
||||
@@ -241,9 +241,9 @@ TEST_F(MCJITMultipleModuleTest, three_module_case) {
|
||||
Function *FA, *FB, *FC;
|
||||
createThreeModuleCase(A, FA, B, FB, C, FC);
|
||||
|
||||
createJIT(A.release());
|
||||
TheJIT->addModule(B.release());
|
||||
TheJIT->addModule(C.release());
|
||||
createJIT(std::move(A));
|
||||
TheJIT->addModule(std::move(B));
|
||||
TheJIT->addModule(std::move(C));
|
||||
|
||||
uint64_t ptr = TheJIT->getFunctionAddress(FC->getName().str());
|
||||
checkAdd(ptr);
|
||||
@@ -266,9 +266,9 @@ TEST_F(MCJITMultipleModuleTest, three_module_case_reverse_order) {
|
||||
Function *FA, *FB, *FC;
|
||||
createThreeModuleCase(A, FA, B, FB, C, FC);
|
||||
|
||||
createJIT(A.release());
|
||||
TheJIT->addModule(B.release());
|
||||
TheJIT->addModule(C.release());
|
||||
createJIT(std::move(A));
|
||||
TheJIT->addModule(std::move(B));
|
||||
TheJIT->addModule(std::move(C));
|
||||
|
||||
uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
|
||||
checkAdd(ptr);
|
||||
@@ -291,9 +291,9 @@ TEST_F(MCJITMultipleModuleTest, three_module_chain_case) {
|
||||
Function *FA, *FB, *FC;
|
||||
createThreeModuleChainedCallsCase(A, FA, B, FB, C, FC);
|
||||
|
||||
createJIT(A.release());
|
||||
TheJIT->addModule(B.release());
|
||||
TheJIT->addModule(C.release());
|
||||
createJIT(std::move(A));
|
||||
TheJIT->addModule(std::move(B));
|
||||
TheJIT->addModule(std::move(C));
|
||||
|
||||
uint64_t ptr = TheJIT->getFunctionAddress(FC->getName().str());
|
||||
checkAdd(ptr);
|
||||
@@ -316,9 +316,9 @@ TEST_F(MCJITMultipleModuleTest, three_modules_chain_case_reverse_order) {
|
||||
Function *FA, *FB, *FC;
|
||||
createThreeModuleChainedCallsCase(A, FA, B, FB, C, FC);
|
||||
|
||||
createJIT(A.release());
|
||||
TheJIT->addModule(B.release());
|
||||
TheJIT->addModule(C.release());
|
||||
createJIT(std::move(A));
|
||||
TheJIT->addModule(std::move(B));
|
||||
TheJIT->addModule(std::move(C));
|
||||
|
||||
uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
|
||||
checkAdd(ptr);
|
||||
@@ -341,8 +341,8 @@ TEST_F(MCJITMultipleModuleTest, cross_module_dependency_case) {
|
||||
Function *FA, *FB1, *FB2;
|
||||
createCrossModuleRecursiveCase(A, FA, B, FB1, FB2);
|
||||
|
||||
createJIT(A.release());
|
||||
TheJIT->addModule(B.release());
|
||||
createJIT(std::move(A));
|
||||
TheJIT->addModule(std::move(B));
|
||||
|
||||
uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
|
||||
checkAccumulate(ptr);
|
||||
@@ -362,8 +362,8 @@ TEST_F(MCJITMultipleModuleTest, cross_module_dependency_case_reverse_order) {
|
||||
Function *FA, *FB1, *FB2;
|
||||
createCrossModuleRecursiveCase(A, FA, B, FB1, FB2);
|
||||
|
||||
createJIT(A.release());
|
||||
TheJIT->addModule(B.release());
|
||||
createJIT(std::move(A));
|
||||
TheJIT->addModule(std::move(B));
|
||||
|
||||
uint64_t ptr = TheJIT->getFunctionAddress(FB1->getName().str());
|
||||
checkAccumulate(ptr);
|
||||
@@ -383,8 +383,8 @@ TEST_F(MCJITMultipleModuleTest, cross_module_dependency_case3) {
|
||||
Function *FA, *FB1, *FB2;
|
||||
createCrossModuleRecursiveCase(A, FA, B, FB1, FB2);
|
||||
|
||||
createJIT(A.release());
|
||||
TheJIT->addModule(B.release());
|
||||
createJIT(std::move(A));
|
||||
TheJIT->addModule(std::move(B));
|
||||
|
||||
uint64_t ptr = TheJIT->getFunctionAddress(FB1->getName().str());
|
||||
checkAccumulate(ptr);
|
||||
|
@@ -114,7 +114,7 @@ protected:
|
||||
TEST_F(MCJITObjectCacheTest, SetNullObjectCache) {
|
||||
SKIP_UNSUPPORTED_PLATFORM;
|
||||
|
||||
createJIT(M.release());
|
||||
createJIT(std::move(M));
|
||||
|
||||
TheJIT->setObjectCache(nullptr);
|
||||
|
||||
@@ -130,7 +130,7 @@ TEST_F(MCJITObjectCacheTest, VerifyBasicObjectCaching) {
|
||||
// Save a copy of the module pointer before handing it off to MCJIT.
|
||||
const Module * SavedModulePointer = M.get();
|
||||
|
||||
createJIT(M.release());
|
||||
createJIT(std::move(M));
|
||||
|
||||
TheJIT->setObjectCache(Cache.get());
|
||||
|
||||
@@ -157,7 +157,7 @@ TEST_F(MCJITObjectCacheTest, VerifyLoadFromCache) {
|
||||
std::unique_ptr<TestObjectCache> Cache(new TestObjectCache);
|
||||
|
||||
// Compile this module with an MCJIT engine
|
||||
createJIT(M.release());
|
||||
createJIT(std::move(M));
|
||||
TheJIT->setObjectCache(Cache.get());
|
||||
TheJIT->finalizeObject();
|
||||
|
||||
@@ -174,7 +174,7 @@ TEST_F(MCJITObjectCacheTest, VerifyLoadFromCache) {
|
||||
const Module * SecondModulePointer = M.get();
|
||||
|
||||
// Create a new MCJIT instance to load this module then execute it.
|
||||
createJIT(M.release());
|
||||
createJIT(std::move(M));
|
||||
TheJIT->setObjectCache(Cache.get());
|
||||
compileAndRun();
|
||||
|
||||
@@ -191,7 +191,7 @@ TEST_F(MCJITObjectCacheTest, VerifyNonLoadFromCache) {
|
||||
std::unique_ptr<TestObjectCache> Cache(new TestObjectCache);
|
||||
|
||||
// Compile this module with an MCJIT engine
|
||||
createJIT(M.release());
|
||||
createJIT(std::move(M));
|
||||
TheJIT->setObjectCache(Cache.get());
|
||||
TheJIT->finalizeObject();
|
||||
|
||||
@@ -209,7 +209,7 @@ TEST_F(MCJITObjectCacheTest, VerifyNonLoadFromCache) {
|
||||
const Module * SecondModulePointer = M.get();
|
||||
|
||||
// Create a new MCJIT instance to load this module then execute it.
|
||||
createJIT(M.release());
|
||||
createJIT(std::move(M));
|
||||
TheJIT->setObjectCache(Cache.get());
|
||||
|
||||
// Verify that our object cache does not contain the module yet.
|
||||
|
@@ -49,7 +49,7 @@ TEST_F(MCJITTest, global_variable) {
|
||||
|
||||
int initialValue = 5;
|
||||
GlobalValue *Global = insertGlobalInt32(M.get(), "test_global", initialValue);
|
||||
createJIT(M.release());
|
||||
createJIT(std::move(M));
|
||||
void *globalPtr = TheJIT->getPointerToGlobal(Global);
|
||||
EXPECT_TRUE(nullptr != globalPtr)
|
||||
<< "Unable to get pointer to global value from JIT";
|
||||
@@ -62,7 +62,7 @@ TEST_F(MCJITTest, add_function) {
|
||||
SKIP_UNSUPPORTED_PLATFORM;
|
||||
|
||||
Function *F = insertAddFunction(M.get());
|
||||
createJIT(M.release());
|
||||
createJIT(std::move(M));
|
||||
uint64_t addPtr = TheJIT->getFunctionAddress(F->getName().str());
|
||||
EXPECT_TRUE(0 != addPtr)
|
||||
<< "Unable to get pointer to function from JIT";
|
||||
@@ -83,7 +83,7 @@ TEST_F(MCJITTest, run_main) {
|
||||
|
||||
int rc = 6;
|
||||
Function *Main = insertMainFunction(M.get(), 6);
|
||||
createJIT(M.release());
|
||||
createJIT(std::move(M));
|
||||
uint64_t ptr = TheJIT->getFunctionAddress(Main->getName().str());
|
||||
EXPECT_TRUE(0 != ptr)
|
||||
<< "Unable to get pointer to main() from JIT";
|
||||
@@ -104,7 +104,7 @@ TEST_F(MCJITTest, return_global) {
|
||||
Value *ReadGlobal = Builder.CreateLoad(GV);
|
||||
endFunctionWithRet(ReturnGlobal, ReadGlobal);
|
||||
|
||||
createJIT(M.release());
|
||||
createJIT(std::move(M));
|
||||
uint64_t rgvPtr = TheJIT->getFunctionAddress(ReturnGlobal->getName().str());
|
||||
EXPECT_TRUE(0 != rgvPtr);
|
||||
|
||||
@@ -175,7 +175,7 @@ TEST_F(MCJITTest, multiple_functions) {
|
||||
Inner = Outer;
|
||||
}
|
||||
|
||||
createJIT(M.release());
|
||||
createJIT(std::move(M));
|
||||
uint64_t ptr = TheJIT->getFunctionAddress(Outer->getName().str());
|
||||
EXPECT_TRUE(0 != ptr)
|
||||
<< "Unable to get pointer to outer function from JIT";
|
||||
|
@@ -307,13 +307,13 @@ protected:
|
||||
UnsupportedEnvironments.push_back(Triple::Cygnus);
|
||||
}
|
||||
|
||||
void createJIT(Module *M) {
|
||||
void createJIT(std::unique_ptr<Module> M) {
|
||||
|
||||
// Due to the EngineBuilder constructor, it is required to have a Module
|
||||
// in order to construct an ExecutionEngine (i.e. MCJIT)
|
||||
assert(M != 0 && "a non-null Module must be provided to create MCJIT");
|
||||
|
||||
EngineBuilder EB(M);
|
||||
EngineBuilder EB(std::move(M));
|
||||
std::string Error;
|
||||
TheJIT.reset(EB.setEngineKind(EngineKind::JIT)
|
||||
.setUseMCJIT(true) /* can this be folded into the EngineKind enum? */
|
||||
|
Reference in New Issue
Block a user