diff --git a/bolt/include/bolt/Core/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h --- a/bolt/include/bolt/Core/BinaryFunction.h +++ b/bolt/include/bolt/Core/BinaryFunction.h @@ -34,6 +34,7 @@ #include "bolt/Core/JumpTable.h" #include "bolt/Core/MCPlus.h" #include "bolt/Utils/NameResolver.h" +#include "bolt/Utils/Utils.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" @@ -1011,6 +1012,11 @@ return AllNames; } + /// Return true if the function name can change across compilations. + bool hasVolatileName() const { + return llvm::any_of(getNames(), getLTOCommonName); + } + /// Return a state the function is in (see BinaryFunction::State definition /// for description). State getState() const { return CurrentState; } diff --git a/bolt/lib/Profile/DataReader.cpp b/bolt/lib/Profile/DataReader.cpp --- a/bolt/lib/Profile/DataReader.cpp +++ b/bolt/lib/Profile/DataReader.cpp @@ -43,15 +43,6 @@ namespace { -/// Return true if the function name can change across compilations. -bool hasVolatileName(const BinaryFunction &BF) { - for (const StringRef &Name : BF.getNames()) - if (getLTOCommonName(Name)) - return true; - - return false; -} - /// Return standard escaped name of the function possibly renamed by BOLT. std::string normalizeName(StringRef NameRef) { // Strip "PG." prefix used for globalized locals. @@ -420,7 +411,7 @@ // Check if the function name can fluctuate between several compilations // possibly triggered by minor unrelated code changes in the source code // of the input binary. - if (!hasVolatileName(BF)) + if (!BF.hasVolatileName()) return; // Check for a profile that matches with 100% confidence. @@ -1325,7 +1316,7 @@ getMemDataForNames(Function.getNames())) return true; - if (!hasVolatileName(Function)) + if (!Function.hasVolatileName()) return false; const std::vector AllBranchData =