Skip to content

Commit 9a8b807

Browse files
committed
trans: Pass newtypes of immediates as their inner-most type again.
1 parent 02a141a commit 9a8b807

File tree

1 file changed

+18
-2
lines changed
  • src/librustc_trans/trans

1 file changed

+18
-2
lines changed

src/librustc_trans/trans/abi.rs

+18-2
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,27 @@ impl FnType {
378378
if abi == Abi::Rust || abi == Abi::RustCall ||
379379
abi == Abi::RustIntrinsic || abi == Abi::PlatformIntrinsic {
380380
let fixup = |arg: &mut ArgType| {
381-
if !arg.ty.is_aggregate() {
381+
let mut llty = arg.ty;
382+
383+
// Replace newtypes with their inner-most type.
384+
while llty.kind() == llvm::TypeKind::Struct {
385+
let inner = llty.field_types();
386+
if inner.len() != 1 {
387+
break;
388+
}
389+
llty = inner[0];
390+
}
391+
392+
if !llty.is_aggregate() {
382393
// Scalars and vectors, always immediate.
394+
if llty != arg.ty {
395+
// Needs a cast as we've unpacked a newtype.
396+
arg.cast = Some(llty);
397+
}
383398
return;
384399
}
385-
let size = llsize_of_real(ccx, arg.ty);
400+
401+
let size = llsize_of_real(ccx, llty);
386402
if size > llsize_of_real(ccx, ccx.int_type()) {
387403
arg.make_indirect(ccx);
388404
} else if size > 0 {

0 commit comments

Comments
 (0)