LiveIntervals: Return index from replaceMachineInstrInMaps
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 25 Jul 2016 19:39:04 +0000 (19:39 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 25 Jul 2016 19:39:04 +0000 (19:39 +0000)
Fixes weird asymmetry with insertion

llvm-svn: 276678

llvm/include/llvm/CodeGen/LiveIntervalAnalysis.h
llvm/include/llvm/CodeGen/SlotIndexes.h

index d4ee058..e226a0b 100644 (file)
@@ -253,8 +253,8 @@ extern cl::opt<bool> UseSegmentSetForPhysRegs;
       Indexes->removeMachineInstrFromMaps(MI);
     }
 
-    void ReplaceMachineInstrInMaps(MachineInstr &MI, MachineInstr &NewMI) {
-      Indexes->replaceMachineInstrInMaps(MI, NewMI);
+    SlotIndex ReplaceMachineInstrInMaps(MachineInstr &MI, MachineInstr &NewMI) {
+      return Indexes->replaceMachineInstrInMaps(MI, NewMI);
     }
 
     VNInfo::Allocator& getVNInfoAllocator() { return VNInfoAllocator; }
index afb0288..01184dc 100644 (file)
@@ -632,11 +632,12 @@ namespace llvm {
     }
 
     /// ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in
-    /// maps used by register allocator.
-    void replaceMachineInstrInMaps(MachineInstr &MI, MachineInstr &NewMI) {
+    /// maps used by register allocator. \returns the index where the new
+    /// instruction was inserted.
+    SlotIndex replaceMachineInstrInMaps(MachineInstr &MI, MachineInstr &NewMI) {
       Mi2IndexMap::iterator mi2iItr = mi2iMap.find(&MI);
       if (mi2iItr == mi2iMap.end())
-        return;
+        return SlotIndex();
       SlotIndex replaceBaseIndex = mi2iItr->second;
       IndexListEntry *miEntry(replaceBaseIndex.listEntry());
       assert(miEntry->getInstr() == &MI &&
@@ -644,6 +645,7 @@ namespace llvm {
       miEntry->setInstr(&NewMI);
       mi2iMap.erase(mi2iItr);
       mi2iMap.insert(std::make_pair(&NewMI, replaceBaseIndex));
+      return replaceBaseIndex;
     }
 
     /// Add the given MachineBasicBlock into the maps.