Skip to content

Commit 7b348f9

Browse files
[MIR][NFC] Use std::move to avoid copying (#125930)
1 parent 8d373ce commit 7b348f9

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

llvm/lib/CodeGen/MIRPrinter.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF,
452452
YamlObject.IsAliased = MFI.isAliasedObjectIndex(I);
453453
// Save the ID' position in FixedStackObjects storage vector.
454454
FixedStackObjectsIdx[ID] = YMF.FixedStackObjects.size();
455-
YMF.FixedStackObjects.push_back(YamlObject);
455+
YMF.FixedStackObjects.push_back(std::move(YamlObject));
456456
StackObjectOperandMapping.insert(
457457
std::make_pair(I, FrameIndexOperand::createFixed(ID)));
458458
}
@@ -506,11 +506,11 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF,
506506
auto &Object =
507507
YMF.FixedStackObjects
508508
[FixedStackObjectsIdx[FrameIdx + MFI.getNumFixedObjects()]];
509-
Object.CalleeSavedRegister = Reg;
509+
Object.CalleeSavedRegister = std::move(Reg);
510510
Object.CalleeSavedRestored = CSInfo.isRestored();
511511
} else {
512512
auto &Object = YMF.StackObjects[StackObjectsIdx[FrameIdx]];
513-
Object.CalleeSavedRegister = Reg;
513+
Object.CalleeSavedRegister = std::move(Reg);
514514
Object.CalleeSavedRestored = CSInfo.isRestored();
515515
}
516516
}
@@ -576,7 +576,7 @@ void MIRPrinter::convertCallSiteObjects(yaml::MachineFunction &YMF,
576576
printRegMIR(ArgReg.Reg, YmlArgReg.Reg, TRI);
577577
YmlCS.ArgForwardingRegs.emplace_back(YmlArgReg);
578578
}
579-
YMF.CallSitesInfo.push_back(YmlCS);
579+
YMF.CallSitesInfo.push_back(std::move(YmlCS));
580580
}
581581

582582
// Sort call info by position of call instructions.
@@ -597,7 +597,7 @@ void MIRPrinter::convertMachineMetadataNodes(yaml::MachineFunction &YMF,
597597
std::string NS;
598598
raw_string_ostream StrOS(NS);
599599
MD.second->print(StrOS, MST, MF.getFunction().getParent());
600-
YMF.MachineMetadataNodes.push_back(NS);
600+
YMF.MachineMetadataNodes.push_back(std::move(NS));
601601
}
602602
}
603603

@@ -612,7 +612,7 @@ void MIRPrinter::convertCalledGlobals(yaml::MachineFunction &YMF,
612612

613613
yaml::CalledGlobal YamlCG{CallSite, CG.Callee->getName().str(),
614614
CG.TargetFlags};
615-
YMF.CalledGlobals.push_back(YamlCG);
615+
YMF.CalledGlobals.push_back(std::move(YamlCG));
616616
}
617617

618618
// Sort by position of call instructions.
@@ -638,11 +638,11 @@ void MIRPrinter::convert(yaml::MachineFunction &MF,
638638

639639
yaml::MachineConstantPoolValue YamlConstant;
640640
YamlConstant.ID = ID++;
641-
YamlConstant.Value = Str;
641+
YamlConstant.Value = std::move(Str);
642642
YamlConstant.Alignment = Constant.getAlign();
643643
YamlConstant.IsTargetSpecific = Constant.isMachineConstantPoolEntry();
644644

645-
MF.Constants.push_back(YamlConstant);
645+
MF.Constants.push_back(std::move(YamlConstant));
646646
}
647647
}
648648

@@ -661,7 +661,7 @@ void MIRPrinter::convert(ModuleSlotTracker &MST,
661661
Entry.Blocks.push_back(Str);
662662
Str.clear();
663663
}
664-
YamlJTI.Entries.push_back(Entry);
664+
YamlJTI.Entries.push_back(std::move(Entry));
665665
}
666666
}
667667

llvm/lib/CodeGen/MachineFunction.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -967,13 +967,13 @@ void MachineFunction::copyAdditionalCallInfo(const MachineInstr *Old,
967967
CallSiteInfoMap::iterator CSIt = getCallSiteInfo(OldCallMI);
968968
if (CSIt != CallSitesInfo.end()) {
969969
CallSiteInfo CSInfo = CSIt->second;
970-
CallSitesInfo[New] = CSInfo;
970+
CallSitesInfo[New] = std::move(CSInfo);
971971
}
972972

973973
CalledGlobalsMap::iterator CGIt = CalledGlobalsInfo.find(OldCallMI);
974974
if (CGIt != CalledGlobalsInfo.end()) {
975975
CalledGlobalInfo CGInfo = CGIt->second;
976-
CalledGlobalsInfo[New] = CGInfo;
976+
CalledGlobalsInfo[New] = std::move(CGInfo);
977977
}
978978
}
979979

@@ -991,14 +991,14 @@ void MachineFunction::moveAdditionalCallInfo(const MachineInstr *Old,
991991
if (CSIt != CallSitesInfo.end()) {
992992
CallSiteInfo CSInfo = std::move(CSIt->second);
993993
CallSitesInfo.erase(CSIt);
994-
CallSitesInfo[New] = CSInfo;
994+
CallSitesInfo[New] = std::move(CSInfo);
995995
}
996996

997997
CalledGlobalsMap::iterator CGIt = CalledGlobalsInfo.find(OldCallMI);
998998
if (CGIt != CalledGlobalsInfo.end()) {
999999
CalledGlobalInfo CGInfo = std::move(CGIt->second);
10001000
CalledGlobalsInfo.erase(CGIt);
1001-
CalledGlobalsInfo[New] = CGInfo;
1001+
CalledGlobalsInfo[New] = std::move(CGInfo);
10021002
}
10031003
}
10041004

0 commit comments

Comments
 (0)