From: Simon Pilgrim Date: Fri, 17 Sep 2021 13:00:16 +0000 (+0100) Subject: [CodeGen] LiveDebug - Use const-ref iterator in for-range loop. NFCI. X-Git-Tag: upstream/15.0.7~31242 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4af76434706a65d839ff167d98455d0704cad70b;p=platform%2Fupstream%2Fllvm.git [CodeGen] LiveDebug - Use const-ref iterator in for-range loop. NFCI. Avoid unnecessary copies, reported by MSVC static analyzer. --- diff --git a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp index 99a57b5..899163c 100644 --- a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp @@ -627,7 +627,7 @@ private: /// add each of them to \p Regs and return true. bool getDescribingRegs(SmallVectorImpl &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; diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp index 9a86cc7..c929c1d 100644 --- a/llvm/lib/CodeGen/LiveDebugVariables.cpp +++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp @@ -417,7 +417,7 @@ public: void addDef(SlotIndex Idx, ArrayRef LocMOs, bool IsIndirect, bool IsList, const DIExpression &Expr) { SmallVector 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.