[PATCH] D101064: [WIP] improve debug-info in stack-slot-coloring
Markus Lavin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 22 06:56:03 PDT 2021
markus created this revision.
Herald added a subscriber: hiraditya.
markus requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D101064
Files:
llvm/lib/CodeGen/StackSlotColoring.cpp
Index: llvm/lib/CodeGen/StackSlotColoring.cpp
===================================================================
--- llvm/lib/CodeGen/StackSlotColoring.cpp
+++ llvm/lib/CodeGen/StackSlotColoring.cpp
@@ -72,6 +72,7 @@
// to be careful that renames like [FI0, FI1] -> [FI1, FI2] do not
// become FI0 -> FI1 -> FI2.
SmallVector<SmallVector<MachineMemOperand *, 8>, 16> SSRefs;
+ DenseMap<unsigned, MachineOperand *> BBDbgRefs;
// OrigAlignments - Alignments of stack objects before coloring.
SmallVector<Align, 16> OrigAlignments;
@@ -370,8 +371,14 @@
// Rewrite all MO_FrameIndex operands. Look for dead stores.
for (MachineBasicBlock &MBB : MF) {
- for (MachineInstr &MI : MBB)
+ BBDbgRefs.clear();
+ for (MachineInstr &MI : MBB) {
+ if (MI.isDebugValue() && MI.getOperand(0).isFI()) {
+ auto FI = MI.getOperand(0).getIndex();
+ BBDbgRefs[FI] = &MI.getOperand(0);
+ }
RewriteInstruction(MI, SlotMapping, MF);
+ }
RemoveDeadStores(&MBB);
}
@@ -405,6 +412,20 @@
if (NewFI == -1 || NewFI == OldFI)
continue;
+ // If NewFI (!= OldFI) has active DBG_VALUE we need to kill that variable.
+ if (MI.isDebugValue() && BBDbgRefs[NewFI]) {
+ auto MO = BBDbgRefs[NewFI];
+ auto DbgValue = MO->getParent();
+ BuildMI(*DbgValue->getParent(), MI, DbgValue->getDebugLoc(),
+ TII->get(TargetOpcode::DBG_VALUE))
+ .addReg(0) // $noreg
+ .add(DbgValue->getOperand(1))
+ .add(DbgValue->getOperand(2))
+ .add(DbgValue->getOperand(3));
+
+ BBDbgRefs.erase(NewFI);
+ }
+
assert(MFI->getStackID(OldFI) == MFI->getStackID(NewFI));
MO.setIndex(NewFI);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101064.339612.patch
Type: text/x-patch
Size: 1725 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210422/8e62fe95/attachment.bin>
More information about the llvm-commits
mailing list