summaryrefslogtreecommitdiffstats
path: root/llvm/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
commitc433cd7bfa4e4ae575a791722b6533f4406c687e (patch)
tree5bdd4c2d351a416a6b6387c728b02e8d80a69402 /llvm/unittests/ExecutionEngine
parentb62ba516e7464a1b5af83cf63256ac5ea7df6481 (diff)
downloadbcm5719-llvm-c433cd7bfa4e4ae575a791722b6533f4406c687e.tar.gz
bcm5719-llvm-c433cd7bfa4e4ae575a791722b6533f4406c687e.zip
[C API] Expose LLVMGetGlobalValueAddress and LLVMGetFunctionAddress.
Patch by Ramkumar Ramachandra <artagnon@gmail.com> llvm-svn: 224720
Diffstat (limited to 'llvm/unittests/ExecutionEngine')
-rw-r--r--llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp b/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
index c80b88b8c2b..62967bdd327 100644
--- a/llvm/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud