[llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Oct 14 13:53:01 PDT 2003
Changes in directory llvm/lib/Target/X86:
X86RegisterInfo.cpp updated: 1.35 -> 1.36
---
Log message:
Disable the leaf function optimization, which is apparently not legal on
X86/linux. :( The problem is that a signal delivered while the function
is executing could clobber the functions stack. This is a partial fix
for PR41.
---
Diffs of the changes: (+2 -25)
Index: llvm/lib/Target/X86/X86RegisterInfo.cpp
diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.35 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.36
--- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.35 Mon Aug 18 09:32:46 2003
+++ llvm/lib/Target/X86/X86RegisterInfo.cpp Tue Oct 14 13:52:41 2003
@@ -81,18 +81,6 @@
return NoFPElim || MF.getFrameInfo()->hasVarSizedObjects();
}
-// hasSPAdjust - Return true if this function has ESP adjustment instructions in
-// the prolog and epilog which allocate local stack space. This is necessary
-// because we elide these instructions if there are no function calls in the
-// current function (ie, this is a leaf function). In this case, we can refer
-// beyond the stack pointer because we know that nothing will trample on that
-// part of the stack.
-//
-static bool hasSPAdjust(MachineFunction &MF) {
- assert(!hasFP(MF) && "Can only eliminate SP adjustment if no frame-pointer!");
- return MF.getFrameInfo()->hasCalls();
-}
-
void X86RegisterInfo::eliminateCallFramePseudoInstr(MachineFunction &MF,
MachineBasicBlock &MBB,
MachineBasicBlock::iterator &I) const {
@@ -144,10 +132,8 @@
int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) +
MI.getOperand(i+3).getImmedValue()+4;
- if (!hasFP(MF) && hasSPAdjust(MF)) {
- const MachineFrameInfo *MFI = MF.getFrameInfo();
- Offset += MFI->getStackSize();
- }
+ if (!hasFP(MF))
+ Offset += MF.getFrameInfo()->getStackSize();
MI.SetMachineOperandConst(i+3, MachineOperand::MO_SignExtendedImmed, Offset);
}
@@ -182,13 +168,6 @@
MI = BuildMI(X86::MOVrr32, 2, X86::EBP).addReg(X86::ESP);
MBBI = MBB.insert(MBBI, MI)+1;
} else {
- // If we don't have a frame pointer, and the function contains no call sites
- // (it's a leaf function), we don't have to emit ANY stack adjustment
- // instructions at all, we can just refer to the area beyond the stack
- // pointer. This can be important for small functions.
- //
- if (!hasSPAdjust(MF)) return;
-
// When we have no frame pointer, we reserve argument space for call sites
// in the function immediately on entry to the current function. This
// eliminates the need for add/sub ESP brackets around call sites.
@@ -232,8 +211,6 @@
MI = addRegOffset(BuildMI(X86::MOVmr32, 5, X86::EBP), X86::ESP, EBPOffset);
MBBI = 1+MBB.insert(MBBI, MI);
} else {
- if (!hasSPAdjust(MF)) return;
-
// Get the number of bytes allocated from the FrameInfo...
unsigned NumBytes = MFI->getStackSize();
More information about the llvm-commits
mailing list