Skip to content

Commit

Permalink
Auto merge of #47401 - rkruppe:issue-47278, r=eddyb
Browse files Browse the repository at this point in the history
Compute LLVM argument indices correctly in face of padding

Closes #47278

r? @eddyb
  • Loading branch information
bors committed Jan 19, 2018
2 parents 3bd4af8 + 9eb4735 commit 9af8d42
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/librustc_trans/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_trans/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
19 changes: 19 additions & 0 deletions src/test/codegen/issue-47278.rs
Original file line number Diff line number Diff line change
@@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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 {} }

0 comments on commit 9af8d42

Please sign in to comment.