[PATCH] D127223: [BOLT] Set valid index for functions with profiles

Vladislav Khmelevsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 7 08:45:21 PDT 2022


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

Some of the passes that calculates tentative layout like LongJmp and
Golang are expecting that only functions with valid index will be
located in hot text section. But currently functions with valid profiles
and not set index are breaking this logic, to fix this we can move the
hasValidProfile() condition from AssignSections pass to ReorderFunctions.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127223

Files:
  bolt/lib/Passes/BinaryPasses.cpp
  bolt/lib/Passes/ReorderFunctions.cpp


Index: bolt/lib/Passes/ReorderFunctions.cpp
===================================================================
--- bolt/lib/Passes/ReorderFunctions.cpp
+++ bolt/lib/Passes/ReorderFunctions.cpp
@@ -128,6 +128,13 @@
     }
   }
 
+  // Assign index for split functions
+  for (auto &it : BFs) {
+    BinaryFunction &BF = it.second;
+    if (!BF.hasValidIndex() && BF.hasValidProfile())
+      BF.setIndex(Index++);
+  }
+
   if (opts::ReorderFunctions == RT_NONE)
     return;
 
Index: bolt/lib/Passes/BinaryPasses.cpp
===================================================================
--- bolt/lib/Passes/BinaryPasses.cpp
+++ bolt/lib/Passes/BinaryPasses.cpp
@@ -1211,8 +1211,7 @@
       continue;
     }
 
-    if (!UseColdSection || Function.hasValidIndex() ||
-        Function.hasValidProfile())
+    if (!UseColdSection || Function.hasValidIndex())
       Function.setCodeSectionName(BC.getMainCodeSectionName());
     else
       Function.setCodeSectionName(BC.getColdCodeSectionName());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127223.434836.patch
Type: text/x-patch
Size: 995 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220607/e4ca5e47/attachment.bin>


More information about the llvm-commits mailing list