[lld] 7ef47dd - [LLD] Increase thunk pass limit

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 13 03:06:36 PDT 2023


Author: Peter Smith
Date: 2023-03-13T10:04:39Z
New Revision: 7ef47dd54e2d9f103986aec90aca554f634cc3e6

URL: https://github.com/llvm/llvm-project/commit/7ef47dd54e2d9f103986aec90aca554f634cc3e6
DIFF: https://github.com/llvm/llvm-project/commit/7ef47dd54e2d9f103986aec90aca554f634cc3e6.diff

LOG: [LLD] Increase thunk pass limit

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.

Differential Revision: https://reviews.llvm.org/D145786

Added: 
    

Modified: 
    lld/ELF/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index e01e8ce2523be..534794bd835a3 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1647,8 +1647,8 @@ template <class ELFT> void Writer<ELFT>::finalizeAddressDependentContent() {
     ++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;


        


More information about the llvm-commits mailing list