[PATCH] D135494: [BOLT] Section-handling refactoring/overhaul

Rafael Auler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 13 17:41:29 PDT 2022


rafauler accepted this revision.
rafauler added a comment.
This revision is now accepted and ready to land.

LGTM with comments



================
Comment at: bolt/lib/Core/BinaryContext.cpp:2035
+  auto Itr = Sections.find(&Section);
+  assert(Itr != Sections.end() && "section must exist to be renamed");
+  Sections.erase(Itr);
----------------
Flagging in case you want to stick to the other format that would write this as "Section (...)  ."


================
Comment at: bolt/lib/Rewrite/RewriteInstance.cpp:3840
 
-  for (std::string &SectionName : Sections) {
-    ErrorOr<BinarySection &> Section = BC->getUniqueSectionByName(SectionName);
-    if (!Section || !Section->isAllocatable() || !Section->isFinalized())
-      continue;
-    NextAvailableAddress =
-        alignTo(NextAvailableAddress, Section->getAlignment());
-    LLVM_DEBUG(dbgs() << "BOLT: mapping section " << SectionName << " (0x"
-                      << Twine::utohexstr(Section->getAllocAddress())
-                      << ") to 0x" << Twine::utohexstr(NextAvailableAddress)
-                      << ":0x"
-                      << Twine::utohexstr(NextAvailableAddress +
-                                          Section->getOutputSize())
-                      << '\n');
+  // Allocate read-only sections first, then writable sections.
+  enum : uint8_t { ST_READONLY, ST_READWRITE };
----------------
Check this loop


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135494/new/

https://reviews.llvm.org/D135494



More information about the llvm-commits mailing list