[PATCH] D141931: [BOLT] Fix error for -reg-reassign option

hezuoqiang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 06:47:09 PST 2023


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

Deal with the child fragments when we work on the function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141931

Files:
  bolt/include/bolt/Core/BinaryFunction.h
  bolt/lib/Passes/RegReAssign.cpp


Index: bolt/lib/Passes/RegReAssign.cpp
===================================================================
--- bolt/lib/Passes/RegReAssign.cpp
+++ bolt/lib/Passes/RegReAssign.cpp
@@ -308,6 +308,10 @@
                       << " with " << BC.MRI->getName(ExtReg) << "\n\n");
     swap(Function, ClassicReg, ExtReg);
     FuncsChanged.insert(&Function);
+    for (BinaryFunction *childF : Function.getFragments()) {
+      swap(*childF, RBX, Candidate);
+      FuncsChanged.insert(childF);
+    }
     ++Begin;
     if (Begin == End)
       break;
@@ -349,6 +353,10 @@
   (void)BC;
   swap(Function, RBX, Candidate);
   FuncsChanged.insert(&Function);
+  for (BinaryFunction *childF : Function.getFragments()) {
+    swap(*childF, RBX, Candidate);
+    FuncsChanged.insert(childF);
+  }
   return true;
 }
 
@@ -408,7 +416,7 @@
   for (auto &I : BC.getBinaryFunctions()) {
     BinaryFunction &Function = I.second;
 
-    if (!Function.isSimple() || Function.isIgnored())
+    if (!Function.isSimple() || Function.isIgnored() || Function.isFragment())
       continue;
 
     LLVM_DEBUG(dbgs() << "====================================\n");
Index: bolt/include/bolt/Core/BinaryFunction.h
===================================================================
--- bolt/include/bolt/Core/BinaryFunction.h
+++ bolt/include/bolt/Core/BinaryFunction.h
@@ -1831,6 +1831,11 @@
     return ParentFragments.count(Parent);
   }
 
+  /// Return the child fragment form parent function
+  SmallPtrSet<BinaryFunction *, 1> getFragments() {
+    return Fragments;
+  }
+
   /// Set the profile data for the number of times the function was called.
   BinaryFunction &setExecutionCount(uint64_t Count) {
     ExecutionCount = Count;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141931.489803.patch
Type: text/x-patch
Size: 1712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230117/16fa04e8/attachment.bin>


More information about the llvm-commits mailing list