From 69e849014c0d17f97a5c22069a587e852e626395 Mon Sep 17 00:00:00 2001 From: Jeff Cohen Date: Tue, 7 Feb 2006 05:11:57 +0000 Subject: Teach the interpreter to handle global variables that are added to a module after interpretation has begun. The JIT already handles this situation correctly, and the interpreter can already handle new functions being added. llvm-svn: 26030 --- llvm/lib/ExecutionEngine/ExecutionEngine.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'llvm/lib/ExecutionEngine/ExecutionEngine.cpp') 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(dyn_cast(GV))) + EmitGlobalVariable(GVar); + else + assert("Global hasn't had an address allocated yet!"); return state.getGlobalAddressMap(locked)[GV]; } -- cgit v1.2.3