Skip to content

Cranelift: Zero and sign extension unimplemented on x86_64 #7210

@bjorn3

Description

@bjorn3

Thanks for filing an issue! Please fill out the TODOs below.

.clif Test Case

target x86_64

function u0:0(i8) system_v {
    sig0 = (i8 uext) system_v
    fn0 = u0:0 sig0

block0(v0: i8):
    call fn0(v0)
    return
}

Steps to Reproduce

  • Compile above code for x86_64

Expected Results

v0 is zero-extended before passed to fn0.

Actual Results

No zero-extension happens, violating the System V ABI. This leads to miscompilations when linking against LLVM compiled code.

   0:   55                      pushq   %rbp
   1:   48 89 e5                movq    %rsp, %rbp
   4:   48 b8 00 00 00 00 00 00 00 00
                                movabsq $0, %rax
   e:   ff d0                   callq   *%rax
  10:   48 89 ec                movq    %rbp, %rsp
  13:   5d                      popq    %rbp
  14:   c3                      retq

Versions and Environment

Cranelift version or commit: 0.100.0 and 4c34504

Operating system: N/A

Architecture: x86_64

Extra Info

This is likely the root cause of https://github.com/bjorn3/rustc_codegen_cranelift/issues/1395.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior in the current implementation that needs fixingcraneliftIssues related to the Cranelift code generator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions