diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGEmit.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGEmit.cpp index d60dd493576..0c679734ea1 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAGEmit.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAGEmit.cpp @@ -675,6 +675,12 @@ void ScheduleDAG::EmitCrossRCCopy(SUnit *SU, /// EmitSchedule - Emit the machine code in scheduled order. MachineBasicBlock *ScheduleDAG::EmitSchedule() { + // For post-regalloc scheduling, we're rescheduling the instructions in the + // block, so start by removing them from the block. + if (!DAG) + while (!BB->empty()) + BB->remove(BB->begin()); + DenseMap VRBaseMap; DenseMap CopyVRBaseMap; for (unsigned i = 0, e = Sequence.size(); i != e; i++) {