Skip to content

Commit

Permalink
[NFC][DwarfDebug] Avoid default capturing when using lambdas
Browse files Browse the repository at this point in the history
It is bad practice to capture by default (via [&] in this case) when
using lambdas, so we should avoid that as much as possible.

This patch fixes that in the getForwardingRegsDefinedByMI
from DwarfDebug module.

Differential Revision: https://reviews.llvm.org/D79616
  • Loading branch information
djtodoro committed May 11, 2020
1 parent 507d1eb commit 45e5a32
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Expand Up @@ -706,20 +706,21 @@ static void collectCallSiteParameters(const MachineInstr *CallMI,

// If the MI is an instruction defining one or more parameters' forwarding
// registers, add those defines.
auto getForwardingRegsDefinedByMI = [&](const MachineInstr &MI,
SmallSetVector<unsigned, 4> &Defs) {
if (MI.isDebugInstr())
return;

for (const MachineOperand &MO : MI.operands()) {
if (MO.isReg() && MO.isDef() &&
Register::isPhysicalRegister(MO.getReg())) {
for (auto FwdReg : ForwardedRegWorklist)
if (TRI.regsOverlap(FwdReg.first, MO.getReg()))
Defs.insert(FwdReg.first);
}
}
};
auto getForwardingRegsDefinedByMI =
[&TRI](const MachineInstr &MI, SmallSetVector<unsigned, 4> &Defs,
const FwdRegWorklist &ForwardedRegWorklist) {
if (MI.isDebugInstr())
return;

for (const MachineOperand &MO : MI.operands()) {
if (MO.isReg() && MO.isDef() &&
Register::isPhysicalRegister(MO.getReg())) {
for (auto FwdReg : ForwardedRegWorklist)
if (TRI.regsOverlap(FwdReg.first, MO.getReg()))
Defs.insert(FwdReg.first);
}
}
};

// Search for a loading value in forwarding registers.
for (; I != MBB->rend(); ++I) {
Expand All @@ -738,7 +739,7 @@ static void collectCallSiteParameters(const MachineInstr *CallMI,
// Set of worklist registers that are defined by this instruction.
SmallSetVector<unsigned, 4> FwdRegDefs;

getForwardingRegsDefinedByMI(*I, FwdRegDefs);
getForwardingRegsDefinedByMI(*I, FwdRegDefs, ForwardedRegWorklist);
if (FwdRegDefs.empty())
continue;

Expand Down

0 comments on commit 45e5a32

Please sign in to comment.