-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Use COFF image-base-relative jump tables on AMD64 #147625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
; RUN: llc < %s -relocation-model=static | FileCheck %s | ||
; RUN: llc < %s -relocation-model=pic | FileCheck %s --check-prefix=PIC | ||
; RUN: llc < %s -relocation-model=pic -code-model=large | FileCheck %s --check-prefix=PIC | ||
; RUN: llc < %s -relocation-model=pic | FileCheck %s --check-prefixes=CHECK,PIC | ||
; RUN: llc < %s -relocation-model=pic -code-model=large | FileCheck %s --check-prefixes=CHECK,LARGE | ||
|
||
; FIXME: Remove '-relocation-model=static' when it is no longer necessary to | ||
; trigger the separate .rdata section. | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The existing code is:
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. |
||
|
||
; LARGE: movl %ecx, %eax | ||
; LARGE-NEXT: movabsq $.LJTI0_0, %rcx | ||
; LARGE-NEXT: movl (%rcx,%rax,4), %eax | ||
; LARGE-NEXT: movabsq $__ImageBase, %rcx | ||
; LARGE-NEXT: addq %rax, %rcx | ||
; LARGE-NEXT: jmpq *%rcx | ||
|
||
; CHECK: .LBB0_{{.*}}: # %sw.bb | ||
; CHECK: .LBB0_{{.*}}: # %sw.bb2 | ||
; CHECK: .LBB0_{{.*}}: # %sw.bb3 | ||
; CHECK: .LBB0_{{.*}}: # %sw.bb1 | ||
; CHECK: callq g | ||
; CHECK: jmp g # TAILCALL | ||
; STATIC: callq g | ||
; STATIC: jmp g # TAILCALL | ||
; CHECK: .section .rdata,"dr" | ||
; CHECK: .quad .LBB0_ | ||
; CHECK: .quad .LBB0_ | ||
; CHECK: .quad .LBB0_ | ||
; CHECK: .quad .LBB0_ | ||
; CHECK: .LJTI0_0: | ||
; CHECK: .long .LBB0_{{[0-9]+}}@IMGREL | ||
; CHECK: .long .LBB0_{{[0-9]+}}@IMGREL | ||
; CHECK: .long .LBB0_{{[0-9]+}}@IMGREL | ||
; CHECK: .long .LBB0_{{[0-9]+}}@IMGREL | ||
|
||
; It's important that we switch back to .text here, not .rdata. | ||
; CHECK: .text | ||
; CHECK: .seh_endproc | ||
|
||
; Windows PIC code should use 32-bit entries | ||
; PIC: .long .LBB0_2-.LJTI0_0 | ||
; PIC: .long .LBB0_3-.LJTI0_0 | ||
; PIC: .long .LBB0_4-.LJTI0_0 | ||
; PIC: .long .LBB0_5-.LJTI0_0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs mir support tests in test/CodeGen/MIR