[llvm-commits] [llvm] r40028 - in /llvm/trunk/lib/Target/X86: README.txt X86RegisterInfo.cpp X86RegisterInfo.h

Evan Cheng evan.cheng at apple.com
Wed Jul 18 17:42:09 PDT 2007


Author: evancheng
Date: Wed Jul 18 19:42:05 2007
New Revision: 40028

URL: http://llvm.org/viewvc/llvm-project?rev=40028&view=rev
Log:
Only adjust esp around calls in presence of alloca.

Modified:
    llvm/trunk/lib/Target/X86/README.txt
    llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
    llvm/trunk/lib/Target/X86/X86RegisterInfo.h

Modified: llvm/trunk/lib/Target/X86/README.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=40028&r1=40027&r2=40028&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/README.txt (original)
+++ llvm/trunk/lib/Target/X86/README.txt Wed Jul 18 19:42:05 2007
@@ -1040,51 +1040,6 @@
 
 //===---------------------------------------------------------------------===//
 
-We use push/pop of stack space around calls in situations where we don't have to.
-Call to f below produces:
-        subl $16, %esp      <<<<<
-        movl %eax, (%esp)
-        call L_f$stub
-        addl $16, %esp     <<<<<
-The stack push/pop can be moved into the prolog/epilog.  It does this because it's
-building the frame pointer, but this should not be sufficient, only the use of alloca
-should cause it to do this.
-(There are other issues shown by this code, but this is one.)
-
-typedef struct _range_t {
-    float fbias;
-    float fscale;
-    int ibias;
-    int iscale;
-    int ishift;
-    unsigned char lut[];
-} range_t;
-
-struct _decode_t {
-    int type:4;
-    int unit:4;
-    int alpha:8;
-    int N:8;
-    int bpc:8;
-    int bpp:16;
-    int skip:8;
-    int swap:8;
-    const range_t*const*range;
-};
-
-typedef struct _decode_t decode_t;
-
-extern int f(const decode_t* decode);
-
-int decode_byte (const decode_t* decode) {
-  if (decode->swap != 0)
-    return f(decode);
-  return 0;
-}
-
-
-//===---------------------------------------------------------------------===//
-
 This:
 #include <xmmintrin.h>
 unsigned test(float f) {

Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=40028&r1=40027&r2=40028&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Wed Jul 18 19:42:05 2007
@@ -1022,18 +1022,23 @@
   MachineModuleInfo *MMI = MFI->getMachineModuleInfo();
 
   return (NoFramePointerElim || 
-          MF.getFrameInfo()->hasVarSizedObjects() ||
+          MFI->hasVarSizedObjects() ||
           MF.getInfo<X86MachineFunctionInfo>()->getForceFramePointer() ||
           (MMI && MMI->callsUnwindInit()));
 }
 
+bool X86RegisterInfo::hasReservedCallFrame(MachineFunction &MF) const {
+  return !MF.getFrameInfo()->hasVarSizedObjects();
+}
+
 void X86RegisterInfo::
 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
                               MachineBasicBlock::iterator I) const {
-  if (hasFP(MF)) {
-    // If we have a frame pointer, turn the adjcallstackup instruction into a
-    // 'sub ESP, <amt>' and the adjcallstackdown instruction into 'add ESP,
-    // <amt>'
+  if (!hasReservedCallFrame(MF)) {
+    // If the stack pointer can be changed after prologue, turn the
+    // adjcallstackup instruction into a 'sub ESP, <amt>' and the
+    // adjcallstackdown instruction into 'add ESP, <amt>'
+    // TODO: consider using push / pop instead of sub + store / add
     MachineInstr *Old = I;
     uint64_t Amount = Old->getOperand(0).getImm();
     if (Amount != 0) {

Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.h?rev=40028&r1=40027&r2=40028&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86RegisterInfo.h (original)
+++ llvm/trunk/lib/Target/X86/X86RegisterInfo.h Wed Jul 18 19:42:05 2007
@@ -98,6 +98,8 @@
 
   bool hasFP(const MachineFunction &MF) const;
 
+  bool hasReservedCallFrame(MachineFunction &MF) const;
+
   void eliminateCallFramePseudoInstr(MachineFunction &MF,
                                      MachineBasicBlock &MBB,
                                      MachineBasicBlock::iterator MI) const;





More information about the llvm-commits mailing list