mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-01 12:24:24 +00:00
[MCJIT] Add a FindGlobalVariableNamed utility
Summary: This adds FindGlobalVariableNamed to ExecutionEngine (plus implementation in MCJIT), which is an analog of FindFunctionNamed for GlobalVariables. Reviewers: lhames Reviewed By: lhames Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10421 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240202 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -194,14 +194,15 @@ TEST_F(MCJITMultipleModuleTest, two_module_consecutive_call_case) {
|
||||
|
||||
|
||||
// Module A { Global Variable GVA, Function FA loads GVA },
|
||||
// Module B { Global Variable GVB, Function FB loads GVB },
|
||||
// execute FB then FA
|
||||
// Module B { Global Variable GVB, Internal Global GVC, Function FB loads GVB },
|
||||
// execute FB then FA, also check that the global variables are properly accesible
|
||||
// through the ExecutionEngine APIs
|
||||
TEST_F(MCJITMultipleModuleTest, two_module_global_variables_case) {
|
||||
SKIP_UNSUPPORTED_PLATFORM;
|
||||
|
||||
std::unique_ptr<Module> A, B;
|
||||
Function *FA, *FB;
|
||||
GlobalVariable *GVA, *GVB;
|
||||
GlobalVariable *GVA, *GVB, *GVC;
|
||||
A.reset(createEmptyModule("A"));
|
||||
B.reset(createEmptyModule("B"));
|
||||
|
||||
@ -213,9 +214,17 @@ TEST_F(MCJITMultipleModuleTest, two_module_global_variables_case) {
|
||||
FB = startFunction<int32_t(void)>(B.get(), "FB");
|
||||
endFunctionWithRet(FB, Builder.CreateLoad(GVB));
|
||||
|
||||
GVC = insertGlobalInt32(B.get(), "GVC", initialNum);
|
||||
GVC->setLinkage(GlobalValue::InternalLinkage);
|
||||
|
||||
createJIT(std::move(A));
|
||||
TheJIT->addModule(std::move(B));
|
||||
|
||||
EXPECT_EQ(GVA, TheJIT->FindGlobalVariableNamed("GVA"));
|
||||
EXPECT_EQ(GVB, TheJIT->FindGlobalVariableNamed("GVB"));
|
||||
EXPECT_EQ(GVC, TheJIT->FindGlobalVariableNamed("GVC",true));
|
||||
EXPECT_EQ(NULL, TheJIT->FindGlobalVariableNamed("GVC"));
|
||||
|
||||
uint64_t FBPtr = TheJIT->getFunctionAddress(FB->getName().str());
|
||||
TheJIT->finalizeObject();
|
||||
EXPECT_TRUE(0 != FBPtr);
|
||||
|
Reference in New Issue
Block a user