[PATCH] D132047: [BOLT] Update buildCallGraph to check for split blocks

Fabian Parzefall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 17 11:24:03 PDT 2022


FPar created this revision.
FPar added reviewers: maksfb, yota9, Amir, rafauler.
Herald added a subscriber: ayermolo.
Herald added a project: All.
FPar requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Use isSplit() instead of isCold() when building the call graph and
update parameter names to reflect this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132047

Files:
  bolt/include/bolt/Passes/BinaryFunctionCallGraph.h
  bolt/lib/Passes/BinaryFunctionCallGraph.cpp
  bolt/lib/Passes/ReorderFunctions.cpp


Index: bolt/lib/Passes/ReorderFunctions.cpp
===================================================================
--- bolt/lib/Passes/ReorderFunctions.cpp
+++ bolt/lib/Passes/ReorderFunctions.cpp
@@ -266,20 +266,19 @@
   if (opts::ReorderFunctions != RT_NONE &&
       opts::ReorderFunctions != RT_EXEC_COUNT &&
       opts::ReorderFunctions != RT_USER) {
-    Cg = buildCallGraph(BC,
-                        [](const BinaryFunction &BF) {
-                          if (!BF.hasProfile())
-                            return true;
-                          if (BF.getState() != BinaryFunction::State::CFG)
-                            return true;
-                          return false;
-                        },
-                        opts::CgFromPerfData,
-                        false, // IncludeColdCalls
-                        opts::ReorderFunctionsUseHotSize,
-                        opts::CgUseSplitHotSize,
-                        opts::UseEdgeCounts,
-                        opts::CgIgnoreRecursiveCalls);
+    Cg = buildCallGraph(
+        BC,
+        [](const BinaryFunction &BF) {
+          if (!BF.hasProfile())
+            return true;
+          if (BF.getState() != BinaryFunction::State::CFG)
+            return true;
+          return false;
+        },
+        opts::CgFromPerfData,
+        /*IncludeSplitCalls=*/false, opts::ReorderFunctionsUseHotSize,
+        opts::CgUseSplitHotSize, opts::UseEdgeCounts,
+        opts::CgIgnoreRecursiveCalls);
     Cg.normalizeArcWeights();
   }
 
Index: bolt/lib/Passes/BinaryFunctionCallGraph.cpp
===================================================================
--- bolt/lib/Passes/BinaryFunctionCallGraph.cpp
+++ bolt/lib/Passes/BinaryFunctionCallGraph.cpp
@@ -80,7 +80,7 @@
 
 BinaryFunctionCallGraph
 buildCallGraph(BinaryContext &BC, CgFilterFunction Filter, bool CgFromPerfData,
-               bool IncludeColdCalls, bool UseFunctionHotSize,
+               bool IncludeSplitCalls, bool UseFunctionHotSize,
                bool UseSplitHotSize, bool UseEdgeCounts,
                bool IgnoreRecursiveCalls) {
   NamedRegionTimer T1("buildcg", "Callgraph construction", "CG breakdown",
@@ -216,8 +216,8 @@
       }
     } else {
       for (BinaryBasicBlock *BB : Function->getLayout().blocks()) {
-        // Don't count calls from cold blocks unless requested.
-        if (BB->isCold() && !IncludeColdCalls)
+        // Don't count calls from split blocks unless requested.
+        if (BB->isSplit() && !IncludeSplitCalls)
           continue;
 
         // Determine whether the block is included in Function's (hot) size
@@ -225,7 +225,7 @@
         bool BBIncludedInFunctionSize = false;
         if (UseFunctionHotSize && Function->isSplit()) {
           if (UseSplitHotSize)
-            BBIncludedInFunctionSize = !BB->isCold();
+            BBIncludedInFunctionSize = !BB->isSplit();
           else
             BBIncludedInFunctionSize = BB->getKnownExecutionCount() != 0;
         } else {
Index: bolt/include/bolt/Passes/BinaryFunctionCallGraph.h
===================================================================
--- bolt/include/bolt/Passes/BinaryFunctionCallGraph.h
+++ bolt/include/bolt/Passes/BinaryFunctionCallGraph.h
@@ -56,15 +56,14 @@
 /// The arguments control how the graph is constructed.
 /// Filter is called on each function, any function that it returns true for
 /// is omitted from the graph.
-/// If IncludeColdCalls is true, then calls from cold BBs are considered for the
-/// graph, otherwise they are ignored.
-/// UseFunctionHotSize controls whether the hot size of a function is used when
-/// filling in the Size attribute of new Nodes.
-/// UseEdgeCounts is used to control if the Weight attribute on Arcs is computed
-/// using the number of calls.
+/// If IncludeSplitCalls is true, then calls from cold BBs are considered for
+/// the graph, otherwise they are ignored. UseFunctionHotSize controls whether
+/// the hot size of a function is used when filling in the Size attribute of new
+/// Nodes. UseEdgeCounts is used to control if the Weight attribute on Arcs is
+/// computed using the number of calls.
 BinaryFunctionCallGraph
 buildCallGraph(BinaryContext &BC, CgFilterFunction Filter = NoFilter,
-               bool CgFromPerfData = false, bool IncludeColdCalls = true,
+               bool CgFromPerfData = false, bool IncludeSplitCalls = true,
                bool UseFunctionHotSize = false, bool UseSplitHotSize = false,
                bool UseEdgeCounts = false, bool IgnoreRecursiveCalls = false);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132047.453362.patch
Type: text/x-patch
Size: 4551 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220817/cef1185f/attachment.bin>


More information about the llvm-commits mailing list