[llvm] 842f4f7 - [Target] Prevent copying in loop variables (NFC)
Jie Fu via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 28 23:25:47 PDT 2025
Author: Jie Fu
Date: 2025-06-29T14:24:41+08:00
New Revision: 842f4f711d3a2461ad7b27e8f7e30f5270a2ba47
URL: https://github.com/llvm/llvm-project/commit/842f4f711d3a2461ad7b27e8f7e30f5270a2ba47
DIFF: https://github.com/llvm/llvm-project/commit/842f4f711d3a2461ad7b27e8f7e30f5270a2ba47.diff
LOG: [Target] Prevent copying in loop variables (NFC)
/data/llvm-project/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp:2390:19: error: loop variable '[Reg, N]' creates a copy from type 'std::pair<unsigned int, llvm::SDValue> const' [-Werror,-Wrange-loop-construct]
for (const auto [Reg, N] : RegsToPass) {
^
/data/llvm-project/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp:2390:8: note: use reference type 'std::pair<unsigned int, llvm::SDValue> const &' to prevent copying
for (const auto [Reg, N] : RegsToPass) {
^~~~~~~~~~~~~~~~~~~~~
&
/data/llvm-project/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp:2402:19: error: loop variable '[Reg, N]' creates a copy from type 'std::pair<unsigned int, llvm::SDValue> const' [-Werror,-Wrange-loop-construct]
for (const auto [Reg, N] : RegsToPass)
^
/data/llvm-project/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp:2402:8: note: use reference type 'std::pair<unsigned int, llvm::SDValue> const &' to prevent copying
for (const auto [Reg, N] : RegsToPass)
^~~~~~~~~~~~~~~~~~~~~
&
2 errors generated.
Added:
Modified:
llvm/lib/Target/Sparc/SparcISelLowering.cpp
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/Sparc/SparcISelLowering.cpp b/llvm/lib/Target/Sparc/SparcISelLowering.cpp
index 8f33e528470e8..9640e4c49f02d 100644
--- a/llvm/lib/Target/Sparc/SparcISelLowering.cpp
+++ b/llvm/lib/Target/Sparc/SparcISelLowering.cpp
@@ -1044,7 +1044,7 @@ SparcTargetLowering::LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
// The InGlue in necessary since all emitted instructions must be
// stuck together.
SDValue InGlue;
- for (const auto [OrigReg, N] : RegsToPass) {
+ for (const auto &[OrigReg, N] : RegsToPass) {
Register Reg = isTailCall ? OrigReg : toCallerWindow(OrigReg);
Chain = DAG.getCopyToReg(Chain, dl, Reg, N, InGlue);
InGlue = Chain.getValue(1);
@@ -1067,7 +1067,7 @@ SparcTargetLowering::LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
Ops.push_back(Callee);
if (hasStructRetAttr)
Ops.push_back(DAG.getTargetConstant(SRetArgSize, dl, MVT::i32));
- for (const auto [OrigReg, N] : RegsToPass) {
+ for (const auto &[OrigReg, N] : RegsToPass) {
Register Reg = isTailCall ? OrigReg : toCallerWindow(OrigReg);
Ops.push_back(DAG.getRegister(Reg, N.getValueType()));
}
@@ -1371,7 +1371,7 @@ SparcTargetLowering::LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
// necessary since all emitted instructions must be stuck together in order
// to pass the live physical registers.
SDValue InGlue;
- for (const auto [Reg, N] : RegsToPass) {
+ for (const auto &[Reg, N] : RegsToPass) {
Chain = DAG.getCopyToReg(Chain, DL, Reg, N, InGlue);
InGlue = Chain.getValue(1);
}
@@ -1390,7 +1390,7 @@ SparcTargetLowering::LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
SmallVector<SDValue, 8> Ops;
Ops.push_back(Chain);
Ops.push_back(Callee);
- for (const auto [Reg, N] : RegsToPass)
+ for (const auto &[Reg, N] : RegsToPass)
Ops.push_back(DAG.getRegister(Reg, N.getValueType()));
// Add a register mask operand representing the call-preserved registers.
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index beb28c8f29780..c6044514fa951 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -2387,7 +2387,7 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
}
// Build a sequence of copy-to-reg nodes, chained and glued together.
- for (const auto [Reg, N] : RegsToPass) {
+ for (const auto &[Reg, N] : RegsToPass) {
Chain = DAG.getCopyToReg(Chain, DL, Reg, N, Glue);
Glue = Chain.getValue(1);
}
@@ -2399,7 +2399,7 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
// Add argument registers to the end of the list so that they are
// known live into the call.
- for (const auto [Reg, N] : RegsToPass)
+ for (const auto &[Reg, N] : RegsToPass)
Ops.push_back(DAG.getRegister(Reg, N.getValueType()));
// Add a register mask operand representing the call-preserved registers.
More information about the llvm-commits
mailing list