[llvm] [StackColoring] Delete dead stack slots (PR #72633)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 27 03:57:59 PST 2023


================
@@ -899,17 +899,34 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
   unsigned FixedMemOp = 0;
   unsigned FixedDbg = 0;
 
-  // Remap debug information that refers to stack slots.
-  for (auto &VI : MF->getVariableDbgInfo()) {
-    if (!VI.Var || !VI.inStackSlot())
+  // Remap debug information that refers to stack slots and delete info for
+  // deleted slots.
+  auto &DbgInfo = MF->getVariableDbgInfo();
+  for (auto it = DbgInfo.begin(); it != DbgInfo.end();) {
----------------
nikic wrote:

I'd suggest to implement this using `erase_if(MF->getVariableDbgInfo(), ...)` instead of the manual iterator management here.

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


More information about the llvm-commits mailing list