diff options
author | Cameron Zwarich <zwarich@apple.com> | 2013-02-11 09:24:45 +0000 |
---|---|---|
committer | Cameron Zwarich <zwarich@apple.com> | 2013-02-11 09:24:45 +0000 |
commit | cbe3f5e1622b5f809bc04d61da125801e4658a73 (patch) | |
tree | 33b89080880e242d1a73e3ed8cef6773c13517e1 /lib/CodeGen | |
parent | 4e08e35e9606eaf8cc2fee942f78fd40b53650b2 (diff) | |
download | external_llvm-cbe3f5e1622b5f809bc04d61da125801e4658a73.zip external_llvm-cbe3f5e1622b5f809bc04d61da125801e4658a73.tar.gz external_llvm-cbe3f5e1622b5f809bc04d61da125801e4658a73.tar.bz2 |
Update SlotIndexes after updateTerminator() possibly removes instructions. I am
really trying to avoid piping SlotIndexes through to RemoveBranch() and friends.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174869 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/MachineBasicBlock.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index 2534a74..7457cd5 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -693,8 +693,32 @@ MachineBasicBlock::SplitCriticalEdge(MachineBasicBlock *Succ, Pass *P) { } ReplaceUsesOfBlockWith(Succ, NMBB); + + // If updateTerminator() removes instructions, we need to remove them from + // SlotIndexes. + SmallVector<MachineInstr*, 4> Terminators; + if (Indexes) { + for (instr_iterator I = getFirstInstrTerminator(), E = instr_end(); + I != E; ++I) + Terminators.push_back(I); + } + updateTerminator(); + if (Indexes) { + SmallVector<MachineInstr*, 4> NewTerminators; + for (instr_iterator I = getFirstInstrTerminator(), E = instr_end(); + I != E; ++I) + NewTerminators.push_back(I); + + for (SmallVectorImpl<MachineInstr*>::iterator I = Terminators.begin(), + E = Terminators.end(); I != E; ++I) { + if (std::find(NewTerminators.begin(), NewTerminators.end(), *I) == + NewTerminators.end()) + Indexes->removeMachineInstrFromMaps(*I); + } + } + // Insert unconditional "jump Succ" instruction in NMBB if necessary. NMBB->addSuccessor(Succ); if (!NMBB->isLayoutSuccessor(Succ)) { |