Skip to content

Commit 9af8d42

Browse files
committed
Auto merge of #47401 - rkruppe:issue-47278, r=eddyb
Compute LLVM argument indices correctly in face of padding Closes #47278 r? @eddyb
2 parents 3bd4af8 + 9eb4735 commit 9af8d42

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/librustc_trans/abi.rs

-3
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,6 @@ impl<'a, 'tcx> ArgType<'tcx> {
608608
}
609609

610610
pub fn store_fn_arg(&self, bx: &Builder<'a, 'tcx>, idx: &mut usize, dst: PlaceRef<'tcx>) {
611-
if self.pad.is_some() {
612-
*idx += 1;
613-
}
614611
let mut next = || {
615612
let val = llvm::get_param(bx.llfn(), *idx as c_uint);
616613
*idx += 1;

src/librustc_trans/mir/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
402402
for i in 0..tupled_arg_tys.len() {
403403
let arg = &fx.fn_ty.args[idx];
404404
idx += 1;
405+
if arg.pad.is_some() {
406+
llarg_idx += 1;
407+
}
405408
arg.store_fn_arg(bx, &mut llarg_idx, place.project_field(bx, i));
406409
}
407410

src/test/codegen/issue-47278.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// -C no-prepopulate-passes
12+
#![crate_type="staticlib"]
13+
14+
#[repr(C)]
15+
pub struct Foo(u64);
16+
17+
// CHECK: define {{.*}} @foo(
18+
#[no_mangle]
19+
pub extern fn foo(_: Foo) -> Foo { loop {} }

0 commit comments

Comments
 (0)