[LLD] Increase thunk pass limit
authorPeter Smith <peter.smith@arm.com>
Fri, 10 Mar 2023 13:22:18 +0000 (13:22 +0000)
committerPeter Smith <peter.smith@arm.com>
Mon, 13 Mar 2023 10:04:39 +0000 (10:04 +0000)
commit7ef47dd54e2d9f103986aec90aca554f634cc3e6
tree5ce50e2955398b80f285bc04eeacff48c4137e45
parent40b273998af142aefd7e72657b0a76194f8de2db
[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
lld/ELF/Writer.cpp