Heal EH handling stuff by emitting correct offsets to callee-saved registers.

Pretty hackish, but code itself is dirty mess, so we won't make anything worse. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40472 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anton Korobeynikov 2007-07-24 21:07:39 +00:00
parent 1ad2cb7555
commit d97b8cd38c

View File

@ -1297,9 +1297,21 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
// Add callee saved registers to move list.
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
for (unsigned I = 0, E = CSI.size(); I != E; ++I) {
// FIXME: This is dirty hack. The code itself is pretty mess right now.
// It should be rewritten from scratch and generalized sometimes.
// Determine maximum offset (minumum due to stack growth)
int64_t MaxOffset = 0;
for (unsigned I = 0, E = CSI.size(); I!=E; ++I)
MaxOffset = std::min(MaxOffset,
MFI->getObjectOffset(CSI[I].getFrameIdx()));
// Calculate offsets
for (unsigned I = 0, E = CSI.size(); I!=E; ++I) {
int64_t Offset = MFI->getObjectOffset(CSI[I].getFrameIdx());
unsigned Reg = CSI[I].getReg();
Offset = (MaxOffset-Offset+3*stackGrowth);
MachineLocation CSDst(MachineLocation::VirtualFP, Offset);
MachineLocation CSSrc(Reg);
Moves.push_back(MachineMove(FrameLabelId, CSDst, CSSrc));