[PATCH] D142261: [BOLT][NFC] Move hasVolatileName into BinaryFunction

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 20 15:15:30 PST 2023


Amir created this revision.
Amir added a reviewer: bolt.
Herald added a reviewer: rafauler.
Herald added subscribers: treapster, ayermolo.
Herald added a reviewer: maksfb.
Herald added a project: All.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142261

Files:
  bolt/include/bolt/Core/BinaryFunction.h
  bolt/lib/Profile/DataReader.cpp


Index: bolt/lib/Profile/DataReader.cpp
===================================================================
--- bolt/lib/Profile/DataReader.cpp
+++ 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<FuncBranchData *> AllBranchData =
Index: bolt/include/bolt/Core/BinaryFunction.h
===================================================================
--- bolt/include/bolt/Core/BinaryFunction.h
+++ 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; }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142261.490986.patch
Type: text/x-patch
Size: 2039 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230120/68a36772/attachment.bin>


More information about the llvm-commits mailing list