From 02376e3f29fd393d2e36a2e3bb682bdcecb1c8ab Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 15 Nov 2004 23:20:04 +0000 Subject: [PATCH] Now that we have ghost linkage, we can force resolution of external symbols immediately instead of lazily. In this program, for example: int main() { printf("hello world\n"); printf("hello world\n"); printf("hello world\n"); printf("hello world\n"); } We used to have to go through compilation callback 4 times (once for each call to printf), now we don't go to it at all. Thanks to Misha for noticing this, and for adding the initial ghost linkage patches. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17864 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ExecutionEngine/JIT/JITEmitter.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index 63bec960936..878c3c33bb5 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -213,9 +213,14 @@ void Emitter::emitWordAt(unsigned W, unsigned *Ptr) { uint64_t Emitter::getGlobalValueAddress(GlobalValue *V) { // Try looking up the function to see if it is already compiled, if not return // 0. - if (isa(V)) - return (intptr_t)TheJIT->getPointerToGlobalIfAvailable(V); - else { + if (Function *F = dyn_cast(V)) { + void *Addr = TheJIT->getPointerToGlobalIfAvailable(F); + if (Addr == 0 && F->hasExternalLinkage()) { + // Do not output stubs for external functions. + Addr = TheJIT->getPointerToFunction(F); + } + return (intptr_t)Addr; + } else { return (intptr_t)TheJIT->getOrEmitGlobalVariable(cast(V)); } } -- 2.34.1