diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/SimpleRegisterCoalescing.cpp | 5 | ||||
-rw-r--r-- | lib/Target/X86/X86InstrInfo.cpp | 11 |
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp index 2f2d549..6eeb21c 100644 --- a/lib/CodeGen/SimpleRegisterCoalescing.cpp +++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp @@ -471,8 +471,9 @@ bool SimpleRegisterCoalescing::ReMaterializeTrivialDef(LiveInterval &SrcInt, } } - MachineBasicBlock::iterator MII = CopyMI; MachineBasicBlock *MBB = CopyMI->getParent(); + MachineBasicBlock::iterator MII = next(MachineBasicBlock::iterator(CopyMI)); + CopyMI->removeFromParent(); tii_->reMaterialize(*MBB, MII, DstReg, DefMI); MachineInstr *NewMI = prior(MII); // CopyMI may have implicit operands, transfer them over to the newly @@ -491,7 +492,7 @@ bool SimpleRegisterCoalescing::ReMaterializeTrivialDef(LiveInterval &SrcInt, } li_->ReplaceMachineInstrInMaps(CopyMI, NewMI); - CopyMI->eraseFromParent(); + MBB->getParent()->DeleteMachineInstr(CopyMI); ReMatCopies.insert(CopyMI); ReMatDefs.insert(DefMI); ++NumReMats; diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index b19c8b9..84e113f 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -848,12 +848,13 @@ X86InstrInfo::isReallyTriviallyReMaterializable(const MachineInstr *MI) const { /// two instructions it assumes it's not safe. static bool isSafeToClobberEFLAGS(MachineBasicBlock &MBB, MachineBasicBlock::iterator I) { + // It's always safe to clobber EFLAGS at the end of a block. + if (I == MBB.end()) + return true; + // For compile time consideration, if we are not able to determine the // safety after visiting 2 instructions, we will assume it's not safe. for (unsigned i = 0; i < 2; ++i) { - if (I == MBB.end()) - // Reached end of block, it's safe. - return true; bool SeenDef = false; for (unsigned j = 0, e = I->getNumOperands(); j != e; ++j) { MachineOperand &MO = I->getOperand(j); @@ -870,6 +871,10 @@ static bool isSafeToClobberEFLAGS(MachineBasicBlock &MBB, // This instruction defines EFLAGS, no need to look any further. return true; ++I; + + // If we make it to the end of the block, it's safe to clobber EFLAGS. + if (I == MBB.end()) + return true; } // Conservative answer. |