-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve uext and sext flags for parameters on x86_64 and apple aarch64
This is required by the ABI and prevents a miscompilation when calling LLVM compiled functions.
- Loading branch information
Showing
4 changed files
with
153 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
cranelift/filetests/filetests/isa/aarch64/uext-sext-handling.clif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
test compile precise-output | ||
target aarch64 | ||
|
||
function u0:0(i8) system_v { | ||
; The aapcs64 call conv ignores the uext and sext flags | ||
sig0 = (i8 uext) system_v | ||
fn0 = u0:0 sig0 | ||
|
||
block0(v0: i8): | ||
call fn0(v0) | ||
return | ||
} | ||
|
||
; VCode: | ||
; stp fp, lr, [sp, #-16]! | ||
; mov fp, sp | ||
; block0: | ||
; load_ext_name x2, User(userextname0)+0 | ||
; blr x2 | ||
; ldp fp, lr, [sp], #16 | ||
; ret | ||
; | ||
; Disassembled: | ||
; block0: ; offset 0x0 | ||
; stp x29, x30, [sp, #-0x10]! | ||
; mov x29, sp | ||
; block1: ; offset 0x8 | ||
; ldr x2, #0x10 | ||
; b #0x18 | ||
; .byte 0x00, 0x00, 0x00, 0x00 ; reloc_external Abs8 u0:0 0 | ||
; .byte 0x00, 0x00, 0x00, 0x00 | ||
; blr x2 | ||
; ldp x29, x30, [sp], #0x10 | ||
; ret | ||
|
||
function u0:0(i8) apple_aarch64 { | ||
; The aaple aarch64 call conv respects the uext and sext flags | ||
sig0 = (i8 uext) apple_aarch64 | ||
fn0 = u0:0 sig0 | ||
|
||
block0(v0: i8): | ||
call fn0(v0) | ||
return | ||
} | ||
|
||
; VCode: | ||
; stp fp, lr, [sp, #-16]! | ||
; mov fp, sp | ||
; block0: | ||
; uxtb w0, w0 | ||
; load_ext_name x4, User(userextname0)+0 | ||
; blr x4 | ||
; ldp fp, lr, [sp], #16 | ||
; ret | ||
; | ||
; Disassembled: | ||
; block0: ; offset 0x0 | ||
; stp x29, x30, [sp, #-0x10]! | ||
; mov x29, sp | ||
; block1: ; offset 0x8 | ||
; uxtb w0, w0 | ||
; ldr x4, #0x14 | ||
; b #0x1c | ||
; .byte 0x00, 0x00, 0x00, 0x00 ; reloc_external Abs8 u0:0 0 | ||
; .byte 0x00, 0x00, 0x00, 0x00 | ||
; blr x4 | ||
; ldp x29, x30, [sp], #0x10 | ||
; ret | ||
|
75 changes: 75 additions & 0 deletions
75
cranelift/filetests/filetests/isa/x64/uext-sext-handling.clif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
test compile precise-output | ||
target x86_64 | ||
|
||
function u0:0(i8) system_v { | ||
; The x86_64 system_v call conv respects uext and sext | ||
sig0 = (i8 uext) system_v | ||
fn0 = u0:0 sig0 | ||
|
||
block0(v0: i8): | ||
call fn0(v0) | ||
return | ||
} | ||
|
||
; VCode: | ||
; pushq %rbp | ||
; movq %rsp, %rbp | ||
; block0: | ||
; movzbq %dil, %rdi | ||
; load_ext_name userextname0+0, %rdx | ||
; call *%rdx | ||
; movq %rbp, %rsp | ||
; popq %rbp | ||
; ret | ||
; | ||
; Disassembled: | ||
; block0: ; offset 0x0 | ||
; pushq %rbp | ||
; movq %rsp, %rbp | ||
; block1: ; offset 0x4 | ||
; movzbq %dil, %rdi | ||
; movabsq $0, %rdx ; reloc_external Abs8 u0:0 0 | ||
; callq *%rdx | ||
; movq %rbp, %rsp | ||
; popq %rbp | ||
; retq | ||
|
||
function u0:0(i8) windows_fastcall { | ||
; The x86_64 windows_fastcall call conv respects uext and sext | ||
sig0 = (i8 uext) windows_fastcall | ||
fn0 = u0:0 sig0 | ||
|
||
block0(v0: i8): | ||
call fn0(v0) | ||
return | ||
} | ||
|
||
; VCode: | ||
; pushq %rbp | ||
; movq %rsp, %rbp | ||
; block0: | ||
; subq %rsp, $32, %rsp | ||
; virtual_sp_offset_adjust 32 | ||
; movzbq %cl, %rcx | ||
; load_ext_name userextname0+0, %r9 | ||
; call *%r9 | ||
; addq %rsp, $32, %rsp | ||
; virtual_sp_offset_adjust -32 | ||
; movq %rbp, %rsp | ||
; popq %rbp | ||
; ret | ||
; | ||
; Disassembled: | ||
; block0: ; offset 0x0 | ||
; pushq %rbp | ||
; movq %rsp, %rbp | ||
; block1: ; offset 0x4 | ||
; subq $0x20, %rsp | ||
; movzbq %cl, %rcx | ||
; movabsq $0, %r9 ; reloc_external Abs8 u0:0 0 | ||
; callq *%r9 | ||
; addq $0x20, %rsp | ||
; movq %rbp, %rsp | ||
; popq %rbp | ||
; retq | ||
|