Skip to content
Snippets Groups Projects
Commit b9e2bedb authored by Axel Naumann's avatar Axel Naumann
Browse files

Wrap a recurring question into an interface: getPointerToGlobalFromJIT().

(cherry picked from commit 0b7973cecb915abd7e0add8b907cec6784a30313)
parent 66652212
No related branches found
No related tags found
No related merge requests found
...@@ -413,3 +413,12 @@ void* ExecutionContext::getAddressOfGlobal(llvm::Module* m, ...@@ -413,3 +413,12 @@ void* ExecutionContext::getAddressOfGlobal(llvm::Module* m,
} }
return address; return address;
} }
void*
ExecutionContext::getPointerToGlobalFromJIT(const llvm::GlobalValue& GV) const {
if (void* addr = m_engine->getPointerToGlobalIfAvailable(&GV))
return addr;
// Function not yet codegened by the JIT, force this to happen now.
return m_engine->getPointerToGlobal(&GV);
}
...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
#include <set> #include <set>
namespace llvm { namespace llvm {
class Module;
class ExecutionEngine; class ExecutionEngine;
class GlobalValue;
class Module;
} }
namespace clang { namespace clang {
...@@ -177,6 +178,13 @@ namespace cling { ...@@ -177,6 +178,13 @@ namespace cling {
void* getAddressOfGlobal(llvm::Module* m, const char* mangledName, void* getAddressOfGlobal(llvm::Module* m, const char* mangledName,
bool* fromJIT = 0) const; bool* fromJIT = 0) const;
///\brief Return the address of a global from the ExecutionEngine (as
/// opposed to dynamic libraries). Forces the emission of the symbol if
/// it has not happened yet.
///
///param[in] GV - global value for which the address will be returned.
void* getPointerToGlobalFromJIT(const llvm::GlobalValue& GV) const;
llvm::ExecutionEngine* getExecutionEngine() const { llvm::ExecutionEngine* getExecutionEngine() const {
if (!m_engine) if (!m_engine)
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment