summaryrefslogtreecommitdiff
path: root/unittests/ExecutionEngine
diff options
context:
space:
mode:
authorPeter Zotov <whitequark@whitequark.org>2014-12-22 18:53:11 +0000
committerPeter Zotov <whitequark@whitequark.org>2014-12-22 18:53:11 +0000
commit7bfc61dfe3ade3762dd0cbc9dc1879c0eb9abec2 (patch)
tree990bea6b4fd8e067d233ee53700e2f66f546894d /unittests/ExecutionEngine
parent7b885653345311402354b3e9e948d5ad0badb962 (diff)
[C API] Expose LLVMGetGlobalValueAddress and LLVMGetFunctionAddress.
Patch by Ramkumar Ramachandra <artagnon@gmail.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224720 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ExecutionEngine')
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
index c80b88b8c2b..62967bdd327 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
+++ b/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
@@ -347,6 +347,44 @@ TEST_F(MCJITCAPITest, simple_function) {
EXPECT_EQ(42, functionPointer.usable());
}
+TEST_F(MCJITCAPITest, gva) {
+ SKIP_UNSUPPORTED_PLATFORM;
+
+ Module = LLVMModuleCreateWithName("simple_module");
+ LLVMSetTarget(Module, HostTriple.c_str());
+ LLVMValueRef GlobalVar = LLVMAddGlobal(Module, LLVMInt32Type(), "simple_value");
+ LLVMSetInitializer(GlobalVar, LLVMConstInt(LLVMInt32Type(), 42, 0));
+
+ buildMCJITOptions();
+ buildMCJITEngine();
+ buildAndRunPasses();
+
+ union {
+ uint64_t raw;
+ int32_t *usable;
+ } valuePointer;
+ valuePointer.raw = LLVMGetGlobalValueAddress(Engine, "simple_value");
+
+ EXPECT_EQ(42, *valuePointer.usable);
+}
+
+TEST_F(MCJITCAPITest, gfa) {
+ SKIP_UNSUPPORTED_PLATFORM;
+
+ buildSimpleFunction();
+ buildMCJITOptions();
+ buildMCJITEngine();
+ buildAndRunPasses();
+
+ union {
+ uint64_t raw;
+ int (*usable)();
+ } functionPointer;
+ functionPointer.raw = LLVMGetFunctionAddress(Engine, "simple_function");
+
+ EXPECT_EQ(42, functionPointer.usable());
+}
+
TEST_F(MCJITCAPITest, custom_memory_manager) {
SKIP_UNSUPPORTED_PLATFORM;