Minor speedup by avoiding callbacks to functions already generated

llvm-svn: 6052
This commit is contained in:
Chris Lattner 2003-05-08 21:44:21 +00:00
parent d340dbdb5d
commit 037f1e58bd
2 changed files with 8 additions and 5 deletions

View File

@ -46,7 +46,6 @@ void VM::CompilationCallback() {
#endif
}
void VM::registerCallback() {
TheVM = this;
}

View File

@ -131,11 +131,15 @@ void Emitter::emitAddress(void *Addr, bool isPCRelative) {
void Emitter::emitGlobalAddress(GlobalValue *V, bool isPCRelative) {
if (isPCRelative) { // must be a call, this is a major hack!
// FIXME: Try looking up the function to see if it is already compiled!
TheVM.addFunctionRef(CurByte, cast<Function>(V));
// Try looking up the function to see if it is already compiled!
if (void *Addr = TheVM.getPointerToGlobalIfAvailable(V)) {
emitAddress(Addr, isPCRelative);
} else { // Function has not yet been code generated!
TheVM.addFunctionRef(CurByte, cast<Function>(V));
// Delayed resolution...
emitAddress((void*)VM::CompilationCallback, isPCRelative);
// Delayed resolution...
emitAddress((void*)VM::CompilationCallback, isPCRelative);
}
} else {
emitAddress(TheVM.getPointerToGlobal(V), isPCRelative);
}