Skip to content

Commit fbb241c

Browse files
committed
use ref to avoid copy in range for-loop
Use big obj copy in range for-loop will call copy constructor every time, which can be avoided by use ref instead. Reviewed By: skan Differential Revision: https://reviews.llvm.org/D150024
1 parent 9032a94 commit fbb241c

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

llvm/include/llvm/MC/MCParser/MCAsmParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class MCAsmParser {
236236

237237
bool printPendingErrors() {
238238
bool rv = !PendingErrors.empty();
239-
for (auto Err : PendingErrors) {
239+
for (auto &Err : PendingErrors) {
240240
printError(Err.Loc, Twine(Err.Msg), Err.Range);
241241
}
242242
PendingErrors.clear();

llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ void VarLocBasedLDV::cleanupEntryValueTransfers(
13121312
return;
13131313

13141314
auto TransRange = EntryValTransfers.equal_range(TRInst);
1315-
for (auto TDPair : llvm::make_range(TransRange.first, TransRange.second)) {
1315+
for (auto &TDPair : llvm::make_range(TransRange.first, TransRange.second)) {
13161316
const VarLoc &EmittedEV = VarLocIDs[TDPair.second];
13171317
if (std::tie(EntryVL.Var, EntryVL.Locs[0].Value.RegNo, EntryVL.Expr) ==
13181318
std::tie(EmittedEV.Var, EmittedEV.Locs[0].Value.RegNo,

llvm/lib/CodeGen/MIRParser/MIRParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ bool MIRParserImpl::initializeCallSiteInfo(
402402
MachineFunction &MF = PFS.MF;
403403
SMDiagnostic Error;
404404
const LLVMTargetMachine &TM = MF.getTarget();
405-
for (auto YamlCSInfo : YamlMF.CallSitesInfo) {
405+
for (auto &YamlCSInfo : YamlMF.CallSitesInfo) {
406406
yaml::CallSiteInfo::MachineInstrLoc MILoc = YamlCSInfo.CallLocation;
407407
if (MILoc.BlockNum >= MF.size())
408408
return error(Twine(MF.getName()) +

llvm/lib/ObjectYAML/MachOEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ void MachOWriter::writeRelocations(raw_ostream &OS) {
426426
void MachOWriter::writeBindOpcodes(
427427
raw_ostream &OS, std::vector<MachOYAML::BindOpcode> &BindOpcodes) {
428428

429-
for (auto Opcode : BindOpcodes) {
429+
for (auto &Opcode : BindOpcodes) {
430430
uint8_t OpByte = Opcode.Opcode | Opcode.Imm;
431431
OS.write(reinterpret_cast<char *>(&OpByte), 1);
432432
for (auto Data : Opcode.ULEBExtraData) {

llvm/utils/TableGen/GlobalISel/GIMatchTree.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ void GIMatchTreeVRegDefPartitioner::applyForPartition(
733733
NewInstrID = SubBuilder.allocInstrID();
734734

735735
GIMatchTreeBuilder::LeafVec &NewLeaves = SubBuilder.getPossibleLeaves();
736-
for (const auto I : zip(NewLeaves, TraversedEdgesByNewLeaves)) {
736+
for (const auto &I : zip(NewLeaves, TraversedEdgesByNewLeaves)) {
737737
auto &Leaf = std::get<0>(I);
738738
auto &TraversedEdgesForLeaf = std::get<1>(I);
739739
GIMatchTreeInstrInfo *InstrInfo = Leaf.getInstrInfo(InstrID);

0 commit comments

Comments
 (0)