diff options
author | Chris Lattner <sabre@nondot.org> | 2004-11-22 22:25:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-11-22 22:25:30 +0000 |
commit | 90b1b457ef6d1747a9de84a1839cd22d9fca3735 (patch) | |
tree | a227c8cf2bba22b980ce7f6e8701a5a18f3009a2 /lib/Target/X86/X86JITInfo.cpp | |
parent | e55cb54a909c2cf2290c5ee317fc10cfb89e45bf (diff) | |
download | external_llvm-90b1b457ef6d1747a9de84a1839cd22d9fca3735.zip external_llvm-90b1b457ef6d1747a9de84a1839cd22d9fca3735.tar.gz external_llvm-90b1b457ef6d1747a9de84a1839cd22d9fca3735.tar.bz2 |
Do not push two return addresses on the stack when we call external functions who have their addresses taken. This fixes test-call.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18134 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86JITInfo.cpp')
-rw-r--r-- | lib/Target/X86/X86JITInfo.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/Target/X86/X86JITInfo.cpp b/lib/Target/X86/X86JITInfo.cpp index 4696b65..4d7b238 100644 --- a/lib/Target/X86/X86JITInfo.cpp +++ b/lib/Target/X86/X86JITInfo.cpp @@ -18,16 +18,6 @@ #include "llvm/Config/alloca.h" using namespace llvm; -void *X86JITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) { - MCE.startFunctionStub(6); - MCE.emitByte(0xE8); // Call with 32 bit pc-rel destination... - - MCE.emitWord((intptr_t)Fn-MCE.getCurrentPCValue()-4); - - MCE.emitByte(0xCD); // Interrupt - Just a marker identifying the stub! - return MCE.finishFunctionStub(0); -} - void X86JITInfo::replaceMachineCodeForFunction(void *Old, void *New) { unsigned char *OldByte = (unsigned char *)Old; *OldByte++ = 0xE9; // Emit JMP opcode. @@ -113,6 +103,22 @@ X86JITInfo::getLazyResolverFunction(JITCompilerFn F) { return CompilationCallback; } +void *X86JITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) { + if (Fn != CompilationCallback) { + MCE.startFunctionStub(5); + MCE.emitByte(0xE9); + MCE.emitWord((intptr_t)Fn-MCE.getCurrentPCValue()-4); + return MCE.finishFunctionStub(0); + } + + MCE.startFunctionStub(6); + MCE.emitByte(0xE8); // Call with 32 bit pc-rel destination... + + MCE.emitWord((intptr_t)Fn-MCE.getCurrentPCValue()-4); + + MCE.emitByte(0xCD); // Interrupt - Just a marker identifying the stub! + return MCE.finishFunctionStub(0); +} /// relocate - Before the JIT can run a block of code that has been emitted, /// it must rewrite the code to contain the actual addresses of any |