Skip to content

Commit fe3a609

Browse files
committed
[MIR-trans] Fix handling of small aggregate arguments
Function arguments that are small aggregates get passed as integer types instead. To correctly handle that, we need to use store_ty instead of plain Store.
1 parent 1ad89e0 commit fe3a609

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/librustc_trans/trans/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ fn arg_value_refs<'bcx, 'tcx>(bcx: Block<'bcx, 'tcx>,
177177
let llarg = llvm::get_param(fcx.llfn, idx);
178178
idx += 1;
179179
let lltemp = base::alloc_ty(bcx, arg_ty, &format!("arg{}", arg_index));
180-
build::Store(bcx, llarg, lltemp);
180+
base::store_ty(bcx, llarg, lltemp, arg_ty);
181181
lltemp
182182
};
183183
LvalueRef::new(llval, LvalueTy::from_ty(arg_ty))
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2015 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+
#![feature(rustc_attrs)]
12+
13+
#[rustc_mir]
14+
fn foo((x, y): (i8, i8)) {
15+
}
16+
17+
fn main() {
18+
foo((0, 1));
19+
}

0 commit comments

Comments
 (0)