summaryrefslogtreecommitdiff
path: root/lib/CodeGen/TailDuplication.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2012-02-20 07:51:58 +0000
committerEvan Cheng <evan.cheng@apple.com>2012-02-20 07:51:58 +0000
commitdf7e8bd7020c300a3c17f5858d281828a5e0cf87 (patch)
treeda32f207569d42de3d93d07620a0432652b714d9 /lib/CodeGen/TailDuplication.cpp
parent7fa767770574ba0312165ac9ed08f792b8fb7874 (diff)
downloadllvm-df7e8bd7020c300a3c17f5858d281828a5e0cf87.tar.gz
llvm-df7e8bd7020c300a3c17f5858d281828a5e0cf87.tar.bz2
llvm-df7e8bd7020c300a3c17f5858d281828a5e0cf87.tar.xz
Make post-ra tail duplication bundle safe. No test case as recent codegen
flow changes have already hidden the bug. rdar://10893812 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150949 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TailDuplication.cpp')
-rw-r--r--lib/CodeGen/TailDuplication.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/CodeGen/TailDuplication.cpp b/lib/CodeGen/TailDuplication.cpp
index ac23e34da9..8ebfbcae78 100644
--- a/lib/CodeGen/TailDuplication.cpp
+++ b/lib/CodeGen/TailDuplication.cpp
@@ -433,7 +433,7 @@ void TailDuplicatePass::DuplicateInstruction(MachineInstr *MI,
MO.setReg(VI->second);
}
}
- PredBB->insert(PredBB->end(), NewMI);
+ PredBB->insert(PredBB->instr_end(), NewMI);
}
/// UpdateSuccessorsPHIs - After FromBB is tail duplicated into its predecessor
@@ -778,8 +778,10 @@ TailDuplicatePass::TailDuplicate(MachineBasicBlock *TailBB,
// Clone the contents of TailBB into PredBB.
DenseMap<unsigned, unsigned> LocalVRMap;
SmallVector<std::pair<unsigned,unsigned>, 4> CopyInfos;
- MachineBasicBlock::iterator I = TailBB->begin();
- while (I != TailBB->end()) {
+ // 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()) {
MachineInstr *MI = &*I;
++I;
if (MI->isPHI()) {
@@ -849,6 +851,7 @@ TailDuplicatePass::TailDuplicate(MachineBasicBlock *TailBB,
// Replace def of virtual registers with new registers, and update
// uses with PHI source register or the new registers.
MachineInstr *MI = &*I++;
+ assert(!MI->isBundle() && "Not expecting bundles before regalloc!");
DuplicateInstruction(MI, TailBB, PrevBB, MF, LocalVRMap, UsedByPhi);
MI->eraseFromParent();
}