summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TailDuplicator.cpp
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2017-08-22 23:56:30 +0000
committerMatthias Braun <matze@braunis.de>2017-08-22 23:56:30 +0000
commit55bc9b3f9ebf482936661e62894102e6bacd9f7e (patch)
tree35faee00884c2e59f63f6d46ea1b655557b94af8 /llvm/lib/CodeGen/TailDuplicator.cpp
parent35189d52218511153c6ad3a027599bb814818779 (diff)
downloadbcm5719-llvm-55bc9b3f9ebf482936661e62894102e6bacd9f7e.tar.gz
bcm5719-llvm-55bc9b3f9ebf482936661e62894102e6bacd9f7e.zip
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
Diffstat (limited to 'llvm/lib/CodeGen/TailDuplicator.cpp')
-rw-r--r--llvm/lib/CodeGen/TailDuplicator.cpp13
1 files changed, 5 insertions, 8 deletions
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<unsigned, RegSubRegPair> &LocalVRMap,
const DenseSet<unsigned> &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<unsigned, RegSubRegPair> LocalVRMap;
SmallVector<std::pair<unsigned, RegSubRegPair>, 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()) {
OpenPOWER on IntegriCloud