[llvm] 45e5a32 - [NFC][DwarfDebug] Avoid default capturing when using lambdas

Djordje Todorovic via llvm-commits llvm-commits at lists.llvm.org
Mon May 11 01:03:09 PDT 2020


Author: Djordje Todorovic
Date: 2020-05-11T10:02:13+02:00
New Revision: 45e5a32a8bd36836c26778f71accdbccdc770a42

URL: https://github.com/llvm/llvm-project/commit/45e5a32a8bd36836c26778f71accdbccdc770a42
DIFF: https://github.com/llvm/llvm-project/commit/45e5a32a8bd36836c26778f71accdbccdc770a42.diff

LOG: [NFC][DwarfDebug] Avoid default capturing when using lambdas

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

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index f53fd3010672..bd033947cc7a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -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) {
@@ -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;
 


        


More information about the llvm-commits mailing list