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 @@ -42,13 +42,11 @@ namespace bolt { std::optional getLTOCommonName(const StringRef Name) { - size_t LTOSuffixPos = Name.find(".lto_priv."); - if (LTOSuffixPos != StringRef::npos) - return Name.substr(0, LTOSuffixPos + 10); - if ((LTOSuffixPos = Name.find(".constprop.")) != StringRef::npos) - return Name.substr(0, LTOSuffixPos + 11); - if ((LTOSuffixPos = Name.find(".llvm.")) != StringRef::npos) - return Name.substr(0, LTOSuffixPos + 6); + for (StringRef Suffix : {".__uniq.", ".lto_priv.", ".constprop.", ".llvm."}) { + size_t LTOSuffixPos = Name.find(Suffix); + if (LTOSuffixPos != StringRef::npos) + return Name.substr(0, LTOSuffixPos + Suffix.size()); + } return std::nullopt; } @@ -56,11 +54,7 @@ /// 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 llvm::any_of(BF.getNames(), getLTOCommonName); } /// Return standard escaped name of the function possibly renamed by BOLT.