Wrap a recurring question into an interface: getPointerToGlobalFromJIT().
(cherry picked from commit 0b7973cecb915abd7e0add8b907cec6784a30313)
This commit is contained in:
parent
8247202478
commit
ee2977ce79
@ -413,3 +413,12 @@ void* ExecutionContext::getAddressOfGlobal(llvm::Module* m,
|
||||
}
|
||||
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 @@
|
||||
#include <set>
|
||||
|
||||
namespace llvm {
|
||||
class Module;
|
||||
class ExecutionEngine;
|
||||
class GlobalValue;
|
||||
class Module;
|
||||
}
|
||||
|
||||
namespace clang {
|
||||
@ -177,6 +178,13 @@ namespace cling {
|
||||
void* getAddressOfGlobal(llvm::Module* m, const char* mangledName,
|
||||
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 {
|
||||
if (!m_engine)
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user