[llvm-commits] CVS: llvm/lib/Target/X86/X86JITInfo.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Nov 22 14:25:44 PST 2004



Changes in directory llvm/lib/Target/X86:

X86JITInfo.cpp updated: 1.2 -> 1.3
---
Log message:

Do not push two return addresses on the stack when we call external functions who have their addresses taken.  This fixes test-call.ll


---
Diffs of the changes:  (+16 -10)

Index: llvm/lib/Target/X86/X86JITInfo.cpp
diff -u llvm/lib/Target/X86/X86JITInfo.cpp:1.2 llvm/lib/Target/X86/X86JITInfo.cpp:1.3
--- llvm/lib/Target/X86/X86JITInfo.cpp:1.2	Sat Nov 20 21:46:06 2004
+++ llvm/lib/Target/X86/X86JITInfo.cpp	Mon Nov 22 16:25:30 2004
@@ -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 @@
   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






More information about the llvm-commits mailing list