This repository was archived by the owner on Aug 25, 2025. It is now read-only.

Description
Rust should use LLVM's signext and zeroext argument attributes for bool/i8/i16/u8/u16 types when targetting WebAssembly, for consistency with LLVM IR generated by clang, and to allow these values to be automatically interpreted by JS.
For example, on this Rust code:
#[no_mangle]
pub extern fn narrow(x: i32) -> i8 {
x as i8
}
#[no_mangle]
pub extern fn widen(x: i8) -> i32 {
x as i32
}
Running rustc test.rs --emit llvm-ir --crate-type=cdylib --target=wasm32-unknown-unknown produces:
[...]
define i8 @narrow(i32 %x) unnamed_addr #0 {
[...]
define i32 @widen(i8 %x) unnamed_addr #0 {
[...]
It should have attributes like this:
[...]
define signext i8 @foo(i32 %x) unnamed_addr #0 {
[...]
define i32 @bar(i8 signext %x) unnamed_addr #0 {
[...]