[PATCH] D87245: [LLD][ELF] Fix performance of MarkLive::scanEhFrameSection

Andrew Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 7 10:09:35 PDT 2020


andrewng created this revision.
andrewng added reviewers: ruiu, MaskRay, pcc.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.
andrewng requested review of this revision.

Only iterate over the .eh_frame relocations that need to be resolved for
an EhSectionPiece.

This appears to be a performance regression introduced in commit
e6c24299d237 (https://reviews.llvm.org/D59800).

This change has been seen to reduce link time by up to ~50%.


https://reviews.llvm.org/D87245

Files:
  lld/ELF/MarkLive.cpp


Index: lld/ELF/MarkLive.cpp
===================================================================
--- lld/ELF/MarkLive.cpp
+++ lld/ELF/MarkLive.cpp
@@ -152,9 +152,9 @@
     // a LSDA. We only need to keep the LSDA alive, so ignore anything that
     // points to executable sections.
     uint64_t pieceEnd = piece.inputOff + piece.size;
-    for (size_t j = firstRelI, end2 = rels.size(); j < end2; ++j)
-      if (rels[j].r_offset < pieceEnd)
-        resolveReloc(eh, rels[j], true);
+    for (size_t j = firstRelI, end2 = rels.size();
+         (j < end2) && (rels[j].r_offset < pieceEnd); ++j)
+      resolveReloc(eh, rels[j], true);
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87245.290310.patch
Type: text/x-patch
Size: 647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200907/042065aa/attachment.bin>


More information about the llvm-commits mailing list