summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/JIT/Emitter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-11-15 23:20:04 +0000
committerChris Lattner <sabre@nondot.org>2004-11-15 23:20:04 +0000
commit1edd79a1bc66b03cb9c2ccad58edc3adf8d04675 (patch)
tree0f51a2996eb554ca9b8896cede6c14ef027bb32f /llvm/lib/ExecutionEngine/JIT/Emitter.cpp
parentb264f7f428ef69b1eff9b99029c509d6cf484e62 (diff)
downloadbcm5719-llvm-1edd79a1bc66b03cb9c2ccad58edc3adf8d04675.tar.gz
bcm5719-llvm-1edd79a1bc66b03cb9c2ccad58edc3adf8d04675.zip
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. llvm-svn: 17864
Diffstat (limited to 'llvm/lib/ExecutionEngine/JIT/Emitter.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/JIT/Emitter.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/ExecutionEngine/JIT/Emitter.cpp b/llvm/lib/ExecutionEngine/JIT/Emitter.cpp
index 63bec960936..878c3c33bb5 100644
--- a/llvm/lib/ExecutionEngine/JIT/Emitter.cpp
+++ b/llvm/lib/ExecutionEngine/JIT/Emitter.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<Function>(V))
- return (intptr_t)TheJIT->getPointerToGlobalIfAvailable(V);
- else {
+ if (Function *F = dyn_cast<Function>(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<GlobalVariable>(V));
}
}
OpenPOWER on IntegriCloud