Skip to content

Commit

Permalink
[BOLT][NFC] Use refs for loop variables to avoid copies
Browse files Browse the repository at this point in the history
Addresses warnings when built with Apple Clang.

Reviewed By: yota9

Differential Revision: https://reviews.llvm.org/D125483
  • Loading branch information
aaupov committed May 13, 2022
1 parent 139744a commit 253b8f0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bolt/lib/Core/BinaryFunction.cpp
Expand Up @@ -419,7 +419,7 @@ void BinaryFunction::print(raw_ostream &OS, std::string Annotation,
if (AllNames.size() > 1) {
OS << "\n All names : ";
const char *Sep = "";
for (const StringRef Name : AllNames) {
for (const StringRef &Name : AllNames) {
OS << Sep << Name;
Sep = "\n ";
}
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Profile/DataReader.cpp
Expand Up @@ -56,7 +56,7 @@ namespace {

/// Return true if the function name can change across compilations.
bool hasVolatileName(const BinaryFunction &BF) {
for (const StringRef Name : BF.getNames())
for (const StringRef &Name : BF.getNames())
if (getLTOCommonName(Name))
return true;

Expand Down
6 changes: 3 additions & 3 deletions bolt/lib/Rewrite/BoltDiff.cpp
Expand Up @@ -219,7 +219,7 @@ class RewriteInstanceDiff {
const BinaryFunction &Function = BFI.second;
const double Score = getNormalizedScore(Function, RI1);
LargestBin1.insert(std::make_pair<>(Score, &Function));
for (const StringRef Name : Function.getNames()) {
for (const StringRef &Name : Function.getNames()) {
if (Optional<StringRef> OptionalLTOName = getLTOCommonName(Name))
LTOName = *OptionalLTOName;
NameLookup[Name] = &Function;
Expand All @@ -239,7 +239,7 @@ class RewriteInstanceDiff {
const BinaryFunction &Function = BFI.second;
const double Score = getNormalizedScore(Function, RI2);
LargestBin2.insert(std::make_pair<>(Score, &Function));
for (const StringRef Name : Function.getNames()) {
for (const StringRef &Name : Function.getNames()) {
if (Optional<StringRef> OptionalLTOName = getLTOCommonName(Name))
LTOName = *OptionalLTOName;
}
Expand All @@ -261,7 +261,7 @@ class RewriteInstanceDiff {
const BinaryFunction &Function2 = BFI2.second;
StringRef LTOName;
bool Match = false;
for (const StringRef Name : Function2.getNames()) {
for (const StringRef &Name : Function2.getNames()) {
auto Iter = NameLookup.find(Name);
if (Optional<StringRef> OptionalLTOName = getLTOCommonName(Name))
LTOName = *OptionalLTOName;
Expand Down

0 comments on commit 253b8f0

Please sign in to comment.