Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/rustc_target/src/callconv/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ pub(crate) fn fill_inregs<'a, Ty, C>(

free_regs -= size_in_regs;

if arg.layout.size.bits() <= 32 && unit.kind == RegKind::Integer {
if opts.flavor != Flavor::FastcallOrVectorcall
|| arg.layout.size.bits() <= 32 && unit.kind == RegKind::Integer
{
attrs.set(ArgAttribute::InReg);
}

Expand Down
20 changes: 20 additions & 0 deletions tests/assembly-llvm/regparm-module-flag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@ use minicore::*;
unsafe extern "C" {
fn memset(p: *mut c_void, val: i32, len: usize) -> *mut c_void;
fn non_builtin_memset(p: *mut c_void, val: i32, len: usize) -> *mut c_void;
fn test_i64_arg(s: i64) -> i64;
}

#[unsafe(no_mangle)]
pub unsafe extern "C" fn test_i64() -> i64 {
// REGPARM1-LABEL: test_i64
// REGPARM1: pushl
// REGPARM1: pushl
// REGPARM1: calll test_i64_arg

// REGPARM2-LABEL: test_i64
// REGPARM2: movl $42, %eax
// REGPARM2: xorl %edx, %edx
// REGPARM2: jmp test_i64_arg

// REGPARM3-LABEL: test_i64
// REGPARM3: movl $42, %eax
// REGPARM3: xorl %edx, %edx
// REGPARM3: jmp test_i64_arg
unsafe { test_i64_arg(42) }
}

#[unsafe(no_mangle)]
Expand Down
Loading