From a16d4429e49b5406c0af905953b5eae13b9cf47c Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Sat, 3 Mar 2007 02:18:00 +0000 Subject: [PATCH] Watch out for cases like this: entry (0x8b056f0, LLVM BB @0x8b01b30, ID#0): Live Ins: %r0 %r1 %r2 %r3 %reg1032 = tMOVrr %r3 %reg1033 = tMOVri8 1 %reg1034 = tMOVri8 0 tCMPi8 %reg1029, 0 tBcc mbb, 0 Successors according to CFG: 0x8b06980 0x8b06a10 entry (0x8b06980, LLVM BB @0x8b01b30, ID#12): Predecessors according to CFG: 0x8b056f0 %reg1036 = tMOVrr %reg1034 Successors according to CFG: 0x8b06a10 entry (0x8b06a10, LLVM BB @0x8b01b30, ID#13): Predecessors according to CFG: 0x8b056f0 0x8b06980 %reg1024 = tMOVrr %reg1030 ... reg1030 and r1 have already been joined. When reg1024 and reg1030 are joined, r1 live range from function entry to the tMOVrr instruction are dead. Eliminate r1 from the livein set of the entry BB, not the BB where the copy is. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34866 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/LiveIntervalAnalysis.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index 26d741f6898..50f1ab061f8 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -938,11 +938,12 @@ bool LiveIntervals::JoinCopy(MachineInstr *CopyMI, if (JoinIntervals(DestInt, SrcInt)) { if (isDead) { // Result of the copy is dead. Propagate this property. - if (SrcStart == 0 && MRegisterInfo::isPhysicalRegister(repSrcReg)) { - // Live-in to the function but dead. Remove it from MBB live-in set. + if (SrcStart == 0) { + assert(MRegisterInfo::isPhysicalRegister(repSrcReg) && + "Live-in must be a physical register!"); + // Live-in to the function but dead. Remove it from entry live-in set. // JoinIntervals may end up swapping the two intervals. - MachineBasicBlock *MBB = CopyMI->getParent(); - MBB->removeLiveIn(repSrcReg); + mf_->begin()->removeLiveIn(repSrcReg); } else { MachineInstr *SrcMI = getInstructionFromIndex(SrcStart); if (SrcMI) { -- 2.11.0