diff options
| -rw-r--r-- | llvm/lib/ExecutionEngine/ExecutionEngine.cpp | 11 | 
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp index 53587bff5a0..95610e65b60 100644 --- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp @@ -171,7 +171,16 @@ void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) {      return getPointerToFunction(F);    MutexGuard locked(lock); -  assert(state.getGlobalAddressMap(locked)[GV] && "Global hasn't had an address allocated yet?"); +  void *p = state.getGlobalAddressMap(locked)[GV]; +  if (p) +    return p; + +  // Global variable might have been added since interpreter started. +  if (GlobalVariable *GVar = +          const_cast<GlobalVariable *>(dyn_cast<GlobalVariable>(GV))) +    EmitGlobalVariable(GVar); +  else +    assert("Global hasn't had an address allocated yet!");    return state.getGlobalAddressMap(locked)[GV];  }  | 

