[PATCH] D105026: [2/2][LiveDebugVariables] Avoid reduntant DBG_VALUEs after virtregrewrite
Djordje Todorovic via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 28 06:54:03 PDT 2021
djtodoro created this revision.
djtodoro added reviewers: jmorse, Orlando, aprantl, dstenb.
djtodoro added a project: debug-info.
Herald added subscribers: hiraditya, nemanjai.
djtodoro requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This is a follow-up for the D105025 <https://reviews.llvm.org/D105025>. It tries to find duplicates even further.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D105026
Files:
llvm/lib/CodeGen/LiveDebugVariables.cpp
llvm/test/CodeGen/PowerPC/non-debug-mi-search-frspxsrsp.ll
Index: llvm/test/CodeGen/PowerPC/non-debug-mi-search-frspxsrsp.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/non-debug-mi-search-frspxsrsp.ll
+++ llvm/test/CodeGen/PowerPC/non-debug-mi-search-frspxsrsp.ll
@@ -29,7 +29,6 @@
; CHECK-NEXT: xvcvdpsp 34, 0
; CHECK-NEXT: xvcvdpsp 35, 1
; CHECK-NEXT: vmrgew 2, 2, 3
-; CHECK-NEXT: #DEBUG_VALUE: test:Vptr <- $x4
; CHECK-NEXT: .loc 1 3 9 is_stmt 0
; CHECK-NEXT: stvx 2, 0, 4
; CHECK-NEXT: .loc 1 4 1 is_stmt 1
Index: llvm/lib/CodeGen/LiveDebugVariables.cpp
===================================================================
--- llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -1642,14 +1642,28 @@
const DILocalVariable *Variable,
const MachineOperand &LocOp,
const DIExpression *Expr, DebugLoc &dl) {
+ if (!LocOp.isReg())
+ return false;
+
MachineBasicBlock::reverse_iterator it =
std::next(MachineBasicBlock::reverse_iterator(MI));
while (it != MBB->rend()) {
- if (!it->isDebugValue())
- return false;
+ if (!it->isDebugValue()) {
+ if (it->isMetaInstruction()) {
+ it = std::next(it);
+ continue;
+ }
+
+ const auto *TRI = MI.getMF()->getSubtarget().getRegisterInfo();
+ if (it->modifiesRegister(LocOp.getReg(), TRI))
+ return false;
+
+ it = std::next(it);
+ continue;
+ }
MachineOperand &loc = it->getDebugOperand(0);
- if (Variable == it->getDebugVariable() && loc.isReg() && LocOp.isReg() &&
+ if (Variable == it->getDebugVariable() && loc.isReg() &&
loc.getReg() == LocOp.getReg() && Expr == it->getDebugExpression() &&
dl == it->getDebugLoc()) {
LLVM_DEBUG(llvm::dbgs() << "\navoiding duplicated "; it->dump(););
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105026.354884.patch
Type: text/x-patch
Size: 1964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210628/5672bd8f/attachment.bin>
More information about the llvm-commits
mailing list