From 1b6f698e85b5087e22044d7214dae54fb509d147 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Wed, 5 May 2010 23:07:41 +0000 Subject: Fix PR6520. An earlyclobber physreg must not be allocated to anything else. llvm-svn: 103133 --- llvm/lib/CodeGen/RegAllocLocal.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'llvm/lib/CodeGen') diff --git a/llvm/lib/CodeGen/RegAllocLocal.cpp b/llvm/lib/CodeGen/RegAllocLocal.cpp index 94456d14385..a3d2f9d2c2e 100644 --- a/llvm/lib/CodeGen/RegAllocLocal.cpp +++ b/llvm/lib/CodeGen/RegAllocLocal.cpp @@ -843,8 +843,18 @@ void RALocal::AllocateBasicBlock(MachineBasicBlock &MBB) { SmallVector Kills; for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { MachineOperand &MO = MI->getOperand(i); - if (!MO.isReg() || !MO.isKill()) continue; - + if (!MO.isReg()) continue; + unsigned Reg = MO.getReg(); + if (!Reg) continue; + + // Avoid allocating assigned early clobbers below. + if (MO.isEarlyClobber() && TargetRegisterInfo::isPhysicalRegister(Reg)) { + spillPhysReg(MBB, MI, Reg, true); // Spill any existing value in reg + PhysRegsUsed[Reg] = 0; // It is free and reserved now + AddToPhysRegsUseOrder(Reg); + } + + if (!MO.isKill()) continue; if (!MO.isImplicit()) Kills.push_back(MO.getReg()); else if (!isReadModWriteImplicitKill(MI, MO.getReg())) -- cgit v1.2.3