[llvm-commits] [llvm] r88728 - /llvm/trunk/lib/CodeGen/PHIElimination.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Fri Nov 13 16:38:13 PST 2009


Author: stoklund
Date: Fri Nov 13 18:38:13 2009
New Revision: 88728

URL: http://llvm.org/viewvc/llvm-project?rev=88728&view=rev
Log:
Fix bug in -split-phi-edges.

When splitting an edge after a machine basic block with fall-through, we
forgot to insert a jump instruction. Fix this by calling updateTerminator() on
the fall-through block when relevant.

Also be more precise in PHIElimination::isLiveIn.

Modified:
    llvm/trunk/lib/CodeGen/PHIElimination.cpp

Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=88728&r1=88727&r2=88728&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Fri Nov 13 18:38:13 2009
@@ -64,7 +64,6 @@
 
   PHIDefs.clear();
   PHIKills.clear();
-
   bool Changed = false;
 
   // Split critical edges to help the coalescer
@@ -419,7 +418,16 @@
                                     LiveVariables &LV) {
   LiveVariables::VarInfo &VI = LV.getVarInfo(Reg);
 
-  return VI.AliveBlocks.test(MBB.getNumber()) || VI.findKill(&MBB);
+  if (VI.AliveBlocks.test(MBB.getNumber()))
+    return true;
+
+  // defined in MBB?
+  const MachineInstr *Def = MRI->getVRegDef(Reg);
+  if (Def && Def->getParent() == &MBB)
+    return false;
+
+  // killed in MBB?
+  return VI.findKill(&MBB);
 }
 
 MachineBasicBlock *PHIElimination::SplitCriticalEdge(MachineBasicBlock *A,
@@ -436,9 +444,12 @@
         << " -- BB#" << B->getNumber() << '\n');
 
   A->ReplaceUsesOfBlockWith(B, NMBB);
-  NMBB->addSuccessor(B);
+  // If A may fall through to B, we may have to insert a branch.
+  if (A->isLayoutSuccessor(B))
+    A->updateTerminator();
 
   // Insert unconditional "jump B" instruction in NMBB.
+  NMBB->addSuccessor(B);
   SmallVector<MachineOperand, 4> Cond;
   MF->getTarget().getInstrInfo()->InsertBranch(*NMBB, B, NULL, Cond);
 





More information about the llvm-commits mailing list