From 55bc9b3f9ebf482936661e62894102e6bacd9f7e Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Tue, 22 Aug 2017 23:56:30 +0000 Subject: TargetInstrInfo: Change duplicate() to work on bundles. Adds infrastructure to clone whole instruction bundles rather than just single instructions. This fixes a bug where tail duplication would unbundle instructions while cloning. This should unbreak the "Clang Stage 1: cmake, RA, with expensive checks enabled" build on greendragon. The bot broke with r311139 hitting this pre-existing bug. A proper testcase will come next. llvm-svn: 311511 --- llvm/lib/CodeGen/TailDuplicator.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'llvm/lib/CodeGen/TailDuplicator.cpp') diff --git a/llvm/lib/CodeGen/TailDuplicator.cpp b/llvm/lib/CodeGen/TailDuplicator.cpp index dc7265dcf6c..0f22040f3ae 100644 --- a/llvm/lib/CodeGen/TailDuplicator.cpp +++ b/llvm/lib/CodeGen/TailDuplicator.cpp @@ -369,10 +369,10 @@ void TailDuplicator::duplicateInstruction( MachineInstr *MI, MachineBasicBlock *TailBB, MachineBasicBlock *PredBB, DenseMap &LocalVRMap, const DenseSet &UsedByPhi) { - MachineInstr *NewMI = TII->duplicate(*MI, *MF); + MachineInstr &NewMI = TII->duplicate(*PredBB, PredBB->end(), *MI); if (PreRegAlloc) { - for (unsigned i = 0, e = NewMI->getNumOperands(); i != e; ++i) { - MachineOperand &MO = NewMI->getOperand(i); + for (unsigned i = 0, e = NewMI.getNumOperands(); i != e; ++i) { + MachineOperand &MO = NewMI.getOperand(i); if (!MO.isReg()) continue; unsigned Reg = MO.getReg(); @@ -443,7 +443,6 @@ void TailDuplicator::duplicateInstruction( } } } - PredBB->insert(PredBB->instr_end(), NewMI); } /// After FromBB is tail duplicated into its predecessor blocks, the successors @@ -825,10 +824,8 @@ bool TailDuplicator::tailDuplicate(bool IsSimple, MachineBasicBlock *TailBB, // Clone the contents of TailBB into PredBB. DenseMap LocalVRMap; SmallVector, 4> CopyInfos; - // Use instr_iterator here to properly handle bundles, e.g. - // ARM Thumb2 IT block. - MachineBasicBlock::instr_iterator I = TailBB->instr_begin(); - while (I != TailBB->instr_end()) { + for (MachineBasicBlock::iterator I = TailBB->begin(), E = TailBB->end(); + I != E; /* empty */) { MachineInstr *MI = &*I; ++I; if (MI->isPHI()) { -- cgit v1.2.3