[lld] [LLD] Implement --enable-non-contiguous-regions (PR #90007)
Daniel Thornburgh via llvm-commits
llvm-commits at lists.llvm.org
Wed May 8 13:45:49 PDT 2024
================
@@ -0,0 +1,54 @@
+# If a spilling reorders input sections, the .ARM.exidx table must be rebuilt
+# using the new order.
+
+RUN: split-file %s %t
+RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %t/test.s -o %t/test.o
+RUN: ld.lld -T %t/test.ld %t/test.o -o %t/test --enable-non-contiguous-regions
+RUN: llvm-readobj -x .ARM.exidx %t/test | FileCheck %s
+
+CHECK: 20000000 08849780 1c000000 10849880
+CHECK-NEXT: 18000000 20849980 14000000 01000000
+
+#--- test.ld
+MEMORY {
+ exidx : ORIGIN = 0, LENGTH = 32
+ a : ORIGIN = 32, LENGTH = 4
+ b : ORIGIN = 36, LENGTH = 4
+ c : ORIGIN = 40, LENGTH = 4
+}
+
+SECTIONS {
+ .ARM.exidx : { *(.ARM.exidx) } >exidx
+ .first_chance : { *(.text .text.f2) } >a
+ .text.f1 : { *(.text.f1) } >b
+ .last_chance : { *(.text.f2) } >c
+}
+
+#--- test.s
+ .syntax unified
+ .section .text, "ax",%progbits
+ .globl _start
+_start:
+ .fnstart
+ bx lr
+ .save {r7, lr}
+ .setfp r7, sp, #0
+ .fnend
+
+ .section .text.f1, "ax", %progbits
+ .globl f1
+f1:
+ .fnstart
+ bx lr
+ .save {r8, lr}
+ .setfp r8, sp, #0
+ .fnend
+
+ .section .text.f2, "ax", %progbits
+ .globl f2
+f2:
+ .fnstart
+ bx lr
+ .save {r9, lr}
+ .setfp r9, sp, #0
----------------
mysterymath wrote:
> I think it could be worth making the unwind instructions identical for at least two of the sections. The .exidx table compression merges identical entries. One of things I was worried about with this patch was whether the table compression would still work properly when the order of sections could change.
Ah, good point. I had just copied this from another test, since I haven't learned the details of `.ARM.exidx`'s encoding yet. I've made two of the sets of assembly declarations identical and updated the assertions. Found that llvm-readobj had a nice pretty-printer for the exidx section, and the results seem plausible.
> However to make a test that actually fails to converge would be difficult and not representative of real world usage.
Even if the `.ARM.exidx` alternatively grows or shrinks on different passes, I'd think it still wouldn't affect convergence. At least, it shouldn't on the basis of spilling alone, since performing a spill is still an irrevocable action.
https://github.com/llvm/llvm-project/pull/90007
More information about the llvm-commits
mailing list