[llvm] [CodeGen] Preserve LiveStack analysis in StackSlotColoring pass (PR #94967)

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 10 11:01:00 PDT 2024


================
@@ -411,6 +412,23 @@ bool StackSlotColoring::ColorSlots(MachineFunction &MF) {
     }
   }
 
+  // In order to preserve LiveStack analysis, the live ranges for dead spill
+  // stack slots would be merged with the live range of those stack slots that
+  // now share the spill object of the mentioned dead stack slot.
+  for (unsigned SS = 0, SE = SlotMapping.size(); SS != SE; ++SS) {
+    int NewFI = SlotMapping[SS];
+    if (SlotMapping[SS] == -1 || (NewFI == (int)SS)) {
+      continue;
+    }
+
+    LiveRange &lrToUpdateInto =
+        static_cast<LiveRange &>(LS->getInterval(NewFI));
+    const LiveRange &lrToUpdateFrom =
+        static_cast<LiveRange &>(LS->getInterval((int)SS));
+    lrToUpdateInto.MergeSegmentsInAsValue(lrToUpdateFrom,
+                                          lrToUpdateInto.getValNumInfo(0));
----------------
kparzysz wrote:

This should use `join`.

https://github.com/llvm/llvm-project/pull/94967


More information about the llvm-commits mailing list