[PATCH] D134299: [BOLT][NFC] Refactor section-mapping code

Maksim Panchenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 20 11:59:39 PDT 2022


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

Simplify checks while searching for the original section.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134299

Files:
  bolt/lib/Rewrite/RewriteInstance.cpp


Index: bolt/lib/Rewrite/RewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/RewriteInstance.cpp
+++ bolt/lib/Rewrite/RewriteInstance.cpp
@@ -3818,18 +3818,18 @@
 
   // Handling for sections with relocations.
   for (BinarySection &Section : BC->sections()) {
-    if (!Section.hasSectionRef())
+    if (!Section.hasSectionRef() || !Section.isAllocatable())
       continue;
 
     StringRef SectionName = Section.getName();
     ErrorOr<BinarySection &> OrgSection =
         BC->getUniqueSectionByName((getOrgSecPrefix() + SectionName).str());
-    if (!OrgSection ||
-        !OrgSection->isAllocatable() ||
-        !OrgSection->isFinalized() ||
-        !OrgSection->hasValidSectionID())
+    if (!OrgSection)
       continue;
 
+    assert(OrgSection->isAllocatable() && OrgSection->isFinalized() &&
+           OrgSection->hasValidSectionID() && "section check failed");
+
     if (OrgSection->getOutputAddress()) {
       LLVM_DEBUG(dbgs() << "BOLT-DEBUG: section " << SectionName
                         << " is already mapped at 0x"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134299.461649.patch
Type: text/x-patch
Size: 1101 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220920/bfdc2ad8/attachment.bin>


More information about the llvm-commits mailing list