diff options
| author | Chris Lattner <sabre@nondot.org> | 2003-01-13 01:00:48 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2003-01-13 01:00:48 +0000 |
| commit | 4bc4b67eed630dfc243c3bc1f9ed3cd564d7ccb6 (patch) | |
| tree | bd69ca6a409011462e2072f2cb3b759ca88e1595 /llvm/lib/ExecutionEngine/JIT/VM.cpp | |
| parent | 2e8815833a9b595380751327066f8528cd2a7320 (diff) | |
| download | bcm5719-llvm-4bc4b67eed630dfc243c3bc1f9ed3cd564d7ccb6.tar.gz bcm5719-llvm-4bc4b67eed630dfc243c3bc1f9ed3cd564d7ccb6.zip | |
Add support for named functions
llvm-svn: 5258
Diffstat (limited to 'llvm/lib/ExecutionEngine/JIT/VM.cpp')
| -rw-r--r-- | llvm/lib/ExecutionEngine/JIT/VM.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/llvm/lib/ExecutionEngine/JIT/VM.cpp b/llvm/lib/ExecutionEngine/JIT/VM.cpp index f66d4d7b7ea..c107438f0f2 100644 --- a/llvm/lib/ExecutionEngine/JIT/VM.cpp +++ b/llvm/lib/ExecutionEngine/JIT/VM.cpp @@ -55,6 +55,22 @@ const std::string &VM::getFunctionReferencedName(void *RefAddr) { static void NoopFn() {} +/// getPointerToNamedFunction - This method returns the address of the specified +/// function by using the dlsym function call. As such it is only useful for +/// resolving library symbols, not code generated symbols. +/// +void *VM::getPointerToNamedFunction(const std::string &Name) { + // If it's an external function, look it up in the process image... + void *Ptr = dlsym(0, Name.c_str()); + if (Ptr == 0) { + std::cerr << "WARNING: Cannot resolve fn '" << Name + << "' using a dummy noop function instead!\n"; + Ptr = (void*)NoopFn; + } + + return Ptr; +} + /// getPointerToFunction - This method is used to get the address of the /// specified function, compiling it if neccesary. /// @@ -62,17 +78,8 @@ void *VM::getPointerToFunction(const Function *F) { void *&Addr = GlobalAddress[F]; // Function already code gen'd if (Addr) return Addr; - if (F->isExternal()) { - // If it's an external function, look it up in the process image... - void *Ptr = dlsym(0, F->getName().c_str()); - if (Ptr == 0) { - std::cerr << "WARNING: Cannot resolve fn '" << F->getName() - << "' using a dummy noop function instead!\n"; - Ptr = (void*)NoopFn; - } - - return Addr = Ptr; - } + if (F->isExternal()) + return Addr = getPointerToNamedFunction(F->getName()); // JIT all of the functions in the module. Eventually this will JIT functions // on demand. This has the effect of populating all of the non-external |

