Register allocator is responsible for spilling callee saved regs
authorChris Lattner <sabre@nondot.org>
Tue, 17 Dec 2002 02:48:57 +0000 (02:48 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 17 Dec 2002 02:48:57 +0000 (02:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5092 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86RegisterInfo.cpp

index c96bbd86b0168a8e03971cbc85937cd848b75784..fc87a02e3b367146a9871bbdd01f9737e1649af5 100644 (file)
@@ -117,14 +117,6 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF,
   MachineBasicBlock &MBB = MF.front();   // Prolog goes in entry BB
   MachineBasicBlock::iterator MBBI = MBB.begin();
 
-  // PUSH all callee-save registers
-  const unsigned* regs = getCalleeSaveRegs();
-  while (*regs) {
-    MachineInstr *MI = BuildMI(X86::PUSHr32, 1).addReg(*regs);
-    MBBI = ++MBB.insert(MBBI, MI);
-    ++regs;
-  }
-
   // PUSH ebp
   MachineInstr *MI = BuildMI(X86::PUSHr32, 1).addReg(X86::EBP);
   MBBI = ++MBB.insert(MBBI, MI);
@@ -144,15 +136,7 @@ void X86RegisterInfo::emitEpilogue(MachineBasicBlock &MBB,
   assert((*MBBI)->getOpcode() == X86::RET &&
          "Can only insert epilog into returning blocks");
 
-  // insert LEAVE
-  MBBI = ++MBB.insert(MBBI, BuildMI(X86::LEAVE, 0));
-
-  // POP all callee-save registers in REVERSE ORDER
-  static const unsigned regs[] = { X86::EBX, X86::EDI, X86::ESI,
-                                   MRegisterInfo::NoRegister };
-  unsigned idx = 0;
-  while (regs[idx]) {
-    MachineInstr *MI = BuildMI(X86::POPr32, 0, regs[idx++]);
-    MBBI = ++(MBB.insert(MBBI, MI));
-  }
+  // insert LEAVE: mov ESP, EBP; pop EBP
+  MBBI = ++MBB.insert(MBBI, BuildMI(X86::MOVrr32, 1,X86::ESP).addReg(X86::EBP));
+  MBBI = ++MBB.insert(MBBI, BuildMI(X86::POPr32, 1).addReg(X86::EBP));
 }