[llvm] 4af7643 - [CodeGen] LiveDebug - Use const-ref iterator in for-range loop. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 17 06:09:59 PDT 2021
Author: Simon Pilgrim
Date: 2021-09-17T14:04:54+01:00
New Revision: 4af76434706a65d839ff167d98455d0704cad70b
URL: https://github.com/llvm/llvm-project/commit/4af76434706a65d839ff167d98455d0704cad70b
DIFF: https://github.com/llvm/llvm-project/commit/4af76434706a65d839ff167d98455d0704cad70b.diff
LOG: [CodeGen] LiveDebug - Use const-ref iterator in for-range loop. NFCI.
Avoid unnecessary copies, reported by MSVC static analyzer.
Added:
Modified:
llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
llvm/lib/CodeGen/LiveDebugVariables.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
index 99a57b50fb3b..899163c09f41 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
@@ -627,7 +627,7 @@ class VarLocBasedLDV : public LDVImpl {
/// 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;
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index 9a86cc78cd57..c929c1dfc0da 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -417,7 +417,7 @@ class UserValue {
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.
More information about the llvm-commits
mailing list