[CodeGen] LiveDebug - Use const-ref iterator in for-range loop. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 17 Sep 2021 13:00:16 +0000 (14:00 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 17 Sep 2021 13:04:54 +0000 (14:04 +0100)
Avoid unnecessary copies, reported by MSVC static analyzer.

llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
llvm/lib/CodeGen/LiveDebugVariables.cpp

index 99a57b5..899163c 100644 (file)
@@ -627,7 +627,7 @@ private:
     /// add each of them to \p Regs and return true.
     bool getDescribingRegs(SmallVectorImpl<uint32_t> &Regs) const {
       bool AnyRegs = false;
-      for (auto Loc : Locs)
+      for (const auto &Loc : Locs)
         if (Loc.Kind == MachineLocKind::RegisterKind) {
           Regs.push_back(Loc.Value.RegNo);
           AnyRegs = true;
index 9a86cc7..c929c1d 100644 (file)
@@ -417,7 +417,7 @@ public:
   void addDef(SlotIndex Idx, ArrayRef<MachineOperand> LocMOs, bool IsIndirect,
               bool IsList, const DIExpression &Expr) {
     SmallVector<unsigned> Locs;
-    for (MachineOperand Op : LocMOs)
+    for (const MachineOperand &Op : LocMOs)
       Locs.push_back(getLocationNo(Op));
     DbgVariableValue DbgValue(Locs, IsIndirect, IsList, Expr);
     // Add a singular (Idx,Idx) -> value mapping.