aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 14d9bb29..5f9e4a6 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -1101,6 +1101,7 @@ class SlotIndexUpdateDelegate : public MachineFunction::Delegate {
private:
MachineFunction &MF;
SlotIndexes *Indexes;
+ SmallSetVector<MachineInstr *, 2> Insertions;
public:
SlotIndexUpdateDelegate(MachineFunction &MF, SlotIndexes *Indexes)
@@ -1108,15 +1109,20 @@ public:
MF.setDelegate(this);
}
- ~SlotIndexUpdateDelegate() { MF.resetDelegate(this); }
+ ~SlotIndexUpdateDelegate() {
+ MF.resetDelegate(this);
+ for (auto MI : Insertions)
+ Indexes->insertMachineInstrInMaps(*MI);
+ }
void MF_HandleInsertion(MachineInstr &MI) override {
+ // This is called before MI is inserted into block so defer index update.
if (Indexes)
- Indexes->insertMachineInstrInMaps(MI);
+ Insertions.insert(&MI);
}
void MF_HandleRemoval(MachineInstr &MI) override {
- if (Indexes)
+ if (Indexes && !Insertions.remove(&MI))
Indexes->removeMachineInstrFromMaps(MI);
}
};