From 06adfa17188859cab229fb977ec9dfe2b7dce6ed Mon Sep 17 00:00:00 2001 From: Carlos Alberto Enciso Date: Thu, 30 Aug 2018 07:17:41 +0000 Subject: [DWARF] Missing location debug information with -O2. Check that Machine CSE correctly handles during the transformation, the debug location information for local variables. Differential Revision: https://reviews.llvm.org/D50887 llvm-svn: 341025 --- llvm/lib/CodeGen/MachineCSE.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'llvm/lib/CodeGen/MachineCSE.cpp') diff --git a/llvm/lib/CodeGen/MachineCSE.cpp b/llvm/lib/CodeGen/MachineCSE.cpp index 6c92b1d426d..fa785ac0c5a 100644 --- a/llvm/lib/CodeGen/MachineCSE.cpp +++ b/llvm/lib/CodeGen/MachineCSE.cpp @@ -180,6 +180,14 @@ bool MachineCSE::PerformTrivialCopyPropagation(MachineInstr *MI, continue; LLVM_DEBUG(dbgs() << "Coalescing: " << *DefMI); LLVM_DEBUG(dbgs() << "*** to: " << *MI); + + // Collect matching debug values. + SmallVector DbgValues; + DefMI->collectDebugValues(DbgValues); + // Propagate SrcReg to debug value instructions. + for (auto *DBI : DbgValues) + DBI->getOperand(0).setReg(SrcReg); + // Propagate SrcReg of copies to MI. MO.setReg(SrcReg); MRI->clearKillFlags(SrcReg); -- cgit v1.2.3