Skip to content

Commit 1bf1505

Browse files
DamonFoolrlavaee
authored andcommitted
[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.
1 parent 0463f37 commit 1bf1505

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

llvm/lib/Target/Sparc/SparcISelLowering.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ SparcTargetLowering::LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
10441044
// The InGlue in necessary since all emitted instructions must be
10451045
// stuck together.
10461046
SDValue InGlue;
1047-
for (const auto [OrigReg, N] : RegsToPass) {
1047+
for (const auto &[OrigReg, N] : RegsToPass) {
10481048
Register Reg = isTailCall ? OrigReg : toCallerWindow(OrigReg);
10491049
Chain = DAG.getCopyToReg(Chain, dl, Reg, N, InGlue);
10501050
InGlue = Chain.getValue(1);
@@ -1067,7 +1067,7 @@ SparcTargetLowering::LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
10671067
Ops.push_back(Callee);
10681068
if (hasStructRetAttr)
10691069
Ops.push_back(DAG.getTargetConstant(SRetArgSize, dl, MVT::i32));
1070-
for (const auto [OrigReg, N] : RegsToPass) {
1070+
for (const auto &[OrigReg, N] : RegsToPass) {
10711071
Register Reg = isTailCall ? OrigReg : toCallerWindow(OrigReg);
10721072
Ops.push_back(DAG.getRegister(Reg, N.getValueType()));
10731073
}
@@ -1371,7 +1371,7 @@ SparcTargetLowering::LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
13711371
// necessary since all emitted instructions must be stuck together in order
13721372
// to pass the live physical registers.
13731373
SDValue InGlue;
1374-
for (const auto [Reg, N] : RegsToPass) {
1374+
for (const auto &[Reg, N] : RegsToPass) {
13751375
Chain = DAG.getCopyToReg(Chain, DL, Reg, N, InGlue);
13761376
InGlue = Chain.getValue(1);
13771377
}
@@ -1390,7 +1390,7 @@ SparcTargetLowering::LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
13901390
SmallVector<SDValue, 8> Ops;
13911391
Ops.push_back(Chain);
13921392
Ops.push_back(Callee);
1393-
for (const auto [Reg, N] : RegsToPass)
1393+
for (const auto &[Reg, N] : RegsToPass)
13941394
Ops.push_back(DAG.getRegister(Reg, N.getValueType()));
13951395

13961396
// Add a register mask operand representing the call-preserved registers.

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,7 +2387,7 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
23872387
}
23882388

23892389
// Build a sequence of copy-to-reg nodes, chained and glued together.
2390-
for (const auto [Reg, N] : RegsToPass) {
2390+
for (const auto &[Reg, N] : RegsToPass) {
23912391
Chain = DAG.getCopyToReg(Chain, DL, Reg, N, Glue);
23922392
Glue = Chain.getValue(1);
23932393
}
@@ -2399,7 +2399,7 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
23992399

24002400
// Add argument registers to the end of the list so that they are
24012401
// known live into the call.
2402-
for (const auto [Reg, N] : RegsToPass)
2402+
for (const auto &[Reg, N] : RegsToPass)
24032403
Ops.push_back(DAG.getRegister(Reg, N.getValueType()));
24042404

24052405
// Add a register mask operand representing the call-preserved registers.

0 commit comments

Comments
 (0)