[BOLT][NFC] Use refs for loop variables to avoid copies

Addresses warnings when built with Apple Clang.

Reviewed By: yota9

Differential Revision: https://reviews.llvm.org/D125483
This commit is contained in:
Amir Ayupov 2022-05-13 20:14:17 +01:00 committed by Amir Ayupov
parent 139744ac53
commit 253b8f0abd
3 changed files with 5 additions and 5 deletions

View File

@ -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 ";
}

View File

@ -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;

View File

@ -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;
@ -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;
}
@ -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;