[lld] [lld][ELF] Sort thunks by their destination to allow quicker convergence (PR #209962)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 21 00:13:40 PDT 2026


================
@@ -1235,7 +1225,7 @@ class ThunkSection final : public SyntheticSection {
   size_t getSize() const override;
   void writeTo(uint8_t *buf) override;
   InputSection *getTargetInputSection() const;
-  bool assignOffsets();
+  bool assignOffsets(bool sort = false);
----------------
MaskRay wrote:

> prefix thunks where we do not want any sorting.

But the code does sort prefix thunks. It's benign because:

- For MIPS LA25, the thunk size is fixed the sort is a no-op.
- For AArch64 BTI landing thunks, they are created at pass 1+ (not at 0), so they are unaffected.

It's safer to add `ThunkSection::isPrefix` and skip them here.

https://github.com/llvm/llvm-project/pull/209962


More information about the llvm-commits mailing list