diff --git a/src/librustc_trans/abi.rs b/src/librustc_trans/abi.rs index 07f9b8fed8b..5079ce77523 100644 --- a/src/librustc_trans/abi.rs +++ b/src/librustc_trans/abi.rs @@ -608,9 +608,6 @@ impl<'a, 'tcx> ArgType<'tcx> { } pub fn store_fn_arg(&self, bx: &Builder<'a, 'tcx>, idx: &mut usize, dst: PlaceRef<'tcx>) { - if self.pad.is_some() { - *idx += 1; - } let mut next = || { let val = llvm::get_param(bx.llfn(), *idx as c_uint); *idx += 1; diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs index ddd78f268fa..3064e2f7c7a 100644 --- a/src/librustc_trans/mir/mod.rs +++ b/src/librustc_trans/mir/mod.rs @@ -402,6 +402,9 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>, for i in 0..tupled_arg_tys.len() { let arg = &fx.fn_ty.args[idx]; idx += 1; + if arg.pad.is_some() { + llarg_idx += 1; + } arg.store_fn_arg(bx, &mut llarg_idx, place.project_field(bx, i)); } diff --git a/src/test/codegen/issue-47278.rs b/src/test/codegen/issue-47278.rs new file mode 100644 index 00000000000..21858b434bf --- /dev/null +++ b/src/test/codegen/issue-47278.rs @@ -0,0 +1,19 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// -C no-prepopulate-passes +#![crate_type="staticlib"] + +#[repr(C)] +pub struct Foo(u64); + +// CHECK: define {{.*}} @foo( +#[no_mangle] +pub extern fn foo(_: Foo) -> Foo { loop {} }