diff options
| author | Keno Fischer <kfischer@college.harvard.edu> | 2015-06-20 00:55:58 +0000 |
|---|---|---|
| committer | Keno Fischer <kfischer@college.harvard.edu> | 2015-06-20 00:55:58 +0000 |
| commit | 73378eb1c739ef39c6c01184a09a9019d94dc031 (patch) | |
| tree | ac20e9b7fb8585fd65a6f76d609c361e82d79c89 /llvm/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp | |
| parent | e46d3796fc7a7c766c5a6a943cfe8b162c320ca8 (diff) | |
| download | llvm-73378eb1c739ef39c6c01184a09a9019d94dc031.zip llvm-73378eb1c739ef39c6c01184a09a9019d94dc031.tar.gz llvm-73378eb1c739ef39c6c01184a09a9019d94dc031.tar.bz2 | |
[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
llvm-svn: 240202
Diffstat (limited to 'llvm/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp')
| -rw-r--r-- | llvm/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp b/llvm/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp index da6e25a..7d52a9a 100644 --- a/llvm/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp +++ b/llvm/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp @@ -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); |
