Skip to content

Commit

Permalink
Add a test for 128-bit return values
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-schievink committed Sep 26, 2020
1 parent 4c5acc4 commit cc2ba3b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/test/codegen/return-value-in-reg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//! This test checks that types of up to 128 bits are returned by-value instead of via out-pointer.

// compile-flags: -C no-prepopulate-passes -O
// only-x86_64

#![crate_type = "lib"]

pub struct S {
a: u64,
b: u32,
c: u32,
}

// CHECK: define i128 @modify(%S* noalias nocapture dereferenceable(16) %s)
#[no_mangle]
pub fn modify(s: S) -> S {
S { a: s.a + s.a, b: s.b + s.b, c: s.c + s.c }
}

#[repr(packed)]
pub struct TooBig {
a: u64,
b: u32,
c: u32,
d: u8,
}

// CHECK: define void @m_big(%TooBig* [[ATTRS:.*sret.*]], %TooBig* [[ATTRS2:.*]] %s)
#[no_mangle]
pub fn m_big(s: TooBig) -> TooBig {
TooBig { a: s.a + s.a, b: s.b + s.b, c: s.c + s.c, d: s.d + s.d }
}

0 comments on commit cc2ba3b

Please sign in to comment.