[llvm] Use COFF image-base-relative jump tables on AMD64 (PR #147625)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 9 10:05:23 PDT 2025
================
@@ -43,25 +43,39 @@ declare void @g(i32)
; CHECK: .text
; CHECK: f:
; CHECK: .seh_proc f
-; CHECK: jmpq *.LJTI0_0
+; CHECK: .seh_endprologue
+
+; STATIC: movl .LJTI0_0(,%rax,4), %eax
+; STATIC: leaq __ImageBase(%rax), %rax
+; STATIC: jmpq *%rax
+
+; PIC: movl %ecx, %eax
+; PIC: leaq .LJTI0_0(%rip), %rcx
+; PIC: movl (%rcx,%rax,4), %eax
+; PIC: leaq __ImageBase(%rip), %rcx
+; PIC: addq %rax, %rcx
+; PIC: jmpq *%rcx
----------------
efriedma-quic wrote:
The existing code is:
```
# %bb.1: # %entry
movl %ecx, %eax
leaq .LJTI0_0(%rip), %rcx
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
```
The proposed sequence is 5 bytes longer, and the benefit is... compatibility with Microsoft-internal tools that don't understand the jump-table debug info format defined by Microsoft? That seems a little dubious; why can't these tools understand the existing debug info?
The difference on AArch64 is likely even larger because you're essentially proposing we disable jump table compression.
https://github.com/llvm/llvm-project/pull/147625
More information about the llvm-commits
mailing list