Skip to content

Commit 9a6804a

Browse files
committed
[TableGen] CodeGenDAGPatterns - use const references on for-range loops to avoid unnecessary copies. NFCI.
1 parent 0168da3 commit 9a6804a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

llvm/utils/TableGen/CodeGenDAGPatterns.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ static unsigned GetNumNodeResults(Record *Operator, CodeGenDAGPatterns &CDP) {
18011801
// The number of results of a fragment with alternative records is the
18021802
// maximum number of results across all alternatives.
18031803
unsigned NumResults = 0;
1804-
for (auto T : PFRec->getTrees())
1804+
for (const auto &T : PFRec->getTrees())
18051805
NumResults = std::max(NumResults, T->getNumTypes());
18061806
return NumResults;
18071807
}
@@ -2023,7 +2023,7 @@ void TreePatternNode::InlinePatternFragments(
20232023
if (ChildAlternatives[i].empty())
20242024
return;
20252025

2026-
for (auto NewChild : ChildAlternatives[i])
2026+
for (const auto &NewChild : ChildAlternatives[i])
20272027
assert((Child->getPredicateCalls().empty() ||
20282028
NewChild->getPredicateCalls() == Child->getPredicateCalls()) &&
20292029
"Non-empty child predicate clobbered!");
@@ -2098,7 +2098,7 @@ void TreePatternNode::InlinePatternFragments(
20982098
}
20992099

21002100
// Loop over all fragment alternatives.
2101-
for (auto Alternative : Frag->getTrees()) {
2101+
for (const auto &Alternative : Frag->getTrees()) {
21022102
TreePatternNodePtr FragTree = Alternative->clone();
21032103

21042104
if (!PredFn.isAlwaysTrue())
@@ -3214,7 +3214,7 @@ void CodeGenDAGPatterns::ParsePatternFragments(bool OutFrags) {
32143214
// it.
32153215
Record *Transform = Frag->getValueAsDef("OperandTransform");
32163216
if (!getSDNodeTransform(Transform).second.empty()) // not noop xform?
3217-
for (auto T : P->getTrees())
3217+
for (const auto &T : P->getTrees())
32183218
T->setTransformFn(Transform);
32193219
}
32203220

@@ -4187,7 +4187,7 @@ void CodeGenDAGPatterns::ParseOnePattern(Record *TheDef,
41874187
// resolve cases where the input type is known to be a pointer type (which
41884188
// is considered resolved), but the result knows it needs to be 32- or
41894189
// 64-bits. Infer the other way for good measure.
4190-
for (auto T : Pattern.getTrees())
4190+
for (const auto &T : Pattern.getTrees())
41914191
for (unsigned i = 0, e = std::min(Result.getOnlyTree()->getNumTypes(),
41924192
T->getNumTypes());
41934193
i != e; ++i) {
@@ -4241,7 +4241,7 @@ void CodeGenDAGPatterns::ParseOnePattern(Record *TheDef,
42414241
// will lead to a contradiction, which is not an error however, but
42424242
// a sign that this pattern will simply never match.
42434243
if (Temp.getOnlyTree()->hasPossibleType())
4244-
for (auto T : Pattern.getTrees())
4244+
for (const auto &T : Pattern.getTrees())
42454245
if (T->hasPossibleType())
42464246
AddPatternToMatch(&Pattern,
42474247
PatternToMatch(TheDef, makePredList(Preds),
@@ -4704,7 +4704,7 @@ void CodeGenDAGPatterns::GenerateVariants() {
47044704
}
47054705
}
47064706

4707-
for (auto it : PatternsWithVariants) {
4707+
for (const auto &it : PatternsWithVariants) {
47084708
unsigned i = it.first;
47094709
const MultipleUseVarSet &DepVars = it.second.first;
47104710
const std::vector<TreePatternNodePtr> &Variants = it.second.second;

0 commit comments

Comments
 (0)