diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -30,6 +30,7 @@ #include "bolt/Utils/CommandLineOpts.h" #include "bolt/Utils/Utils.h" #include "llvm/ADT/Optional.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFDebugFrame.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" @@ -2499,16 +2500,12 @@ BC->getBinaryFunctionAtAddress(Address + 1)) { // Do an extra check that the function was referenced previously. // It's a linear search, but it should rarely happen. - bool Found = false; - for (const auto &RelKV : ContainingBF->Relocations) { - const Relocation &Rel = RelKV.second; - if (Rel.Symbol == RogueBF->getSymbol() && - !Relocation::isPCRelative(Rel.Type)) { - Found = true; - break; - } - } - + auto CheckReloc = [&](const Relocation &Rel) { + return Rel.Symbol == RogueBF->getSymbol() && + !Relocation::isPCRelative(Rel.Type); + }; + bool Found = llvm::any_of( + llvm::make_second_range(ContainingBF->Relocations), CheckReloc); if (Found) { errs() << "BOLT-WARNING: detected possible compiler de-virtualization " "bug: -1 addend used with non-pc-relative relocation against " @@ -2620,8 +2617,8 @@ if (SymbolFlags & SymbolRef::SF_Global) { Name = SymbolName; } else { - if (StringRef(SymbolName) - .startswith(BC->AsmInfo->getPrivateGlobalPrefix())) + StringRef PGPrefix(BC->AsmInfo->getPrivateGlobalPrefix()); + if (StringRef(SymbolName).startswith(PGPrefix)) Name = NR.uniquify("PG" + SymbolName); else Name = NR.uniquify(SymbolName); @@ -2644,9 +2641,9 @@ LLVM_DEBUG({ dbgs() << "BOLT-DEBUG: processing ending on data relocation " << NumDataRelocations << ": "; + printRelocationInfo(Rel, ReferencedSymbol->getName(), SymbolAddress, + Addend, ExtractedValue); }); - printRelocationInfo(Rel, ReferencedSymbol->getName(), SymbolAddress, - Addend, ExtractedValue); } return (!opts::MaxDataRelocations ||