[PATCH] D145786: [LLD] Increase thunk pass limit

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 10 05:40:58 PST 2023


peter.smith created this revision.
peter.smith added reviewers: MaskRay, aeubanks.
Herald added subscribers: arichardson, emaste.
Herald added a project: All.
peter.smith requested review of this revision.

In issue 61250 https://github.com/llvm/llvm-project/issues/61250 there is an example of a program that takes 17 passes to converge, which is 2 more than the current limit of 15. Analysis of the program shows a particular section that is made up of many roughly thunk sized chunks of code ending in a call to a symbol that needs a thunk. Due to the positioning of the section, at each pass a subset of the calls go out of range of their original thunk, needing a new one created, which then pushes more thunks out of range. This process eventually stops after 17 passes.

This patch is the simplest fix for the problem, which is to increase the pass limit. I've chosen to double it which should comfortably account for future cases like this, while only taking a few more seconds to reach the limit in case of non-convergence.

As discussed in the issue, there could be some additional work done to limit thunk reuse, this would potentially increase the number of thunks in the program but should speed up convergence. This could be done in a follow up patch.


https://reviews.llvm.org/D145786

Files:
  lld/ELF/Writer.cpp


Index: lld/ELF/Writer.cpp
===================================================================
--- lld/ELF/Writer.cpp
+++ lld/ELF/Writer.cpp
@@ -1647,8 +1647,8 @@
     ++pass;
 
     // With Thunk Size much smaller than branch range we expect to
-    // converge quickly; if we get to 15 something has gone wrong.
-    if (changed && pass >= 15) {
+    // converge quickly; if we get to 30 something has gone wrong.
+    if (changed && pass >= 30) {
       error(target->needsThunks ? "thunk creation not converged"
                                 : "relaxation not converged");
       break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145786.504110.patch
Type: text/x-patch
Size: 593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230310/2dcaf04d/attachment.bin>


More information about the llvm-commits mailing list