Skip to content

Commit c710c9a

Browse files
committed
rustc: Do argument casts before loading aggregates, not after
1 parent 3f2bae4 commit c710c9a

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/comp/middle/trans.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4029,11 +4029,6 @@ fn trans_args(@block_ctxt cx,
40294029
auto re = trans_expr(bcx, e);
40304030
val = re.val;
40314031
bcx = re.bcx;
4032-
if (mode == ast.val) {
4033-
// Until here we've been treating structures by pointer;
4034-
// we are now passing it as an arg, so need to load it.
4035-
val = bcx.build.Load(val);
4036-
}
40374032
} else if (mode == ast.alias) {
40384033
let lval_result lv;
40394034
if (ty.is_lval(e)) {
@@ -4063,9 +4058,25 @@ fn trans_args(@block_ctxt cx,
40634058

40644059
if (ty.count_ty_params(args.(i).ty) > 0u) {
40654060
auto lldestty = arg_tys.(i);
4061+
if (mode == ast.val) {
4062+
// FIXME: we'd prefer to use &&, but rustboot doesn't like it
4063+
if (ty.type_is_structural(ty.expr_ty(e))) {
4064+
lldestty = T_ptr(lldestty);
4065+
}
4066+
}
4067+
40664068
val = bcx.build.PointerCast(val, lldestty);
40674069
}
40684070

4071+
if (mode == ast.val) {
4072+
// FIXME: we'd prefer to use &&, but rustboot doesn't like it
4073+
if (ty.type_is_structural(ty.expr_ty(e))) {
4074+
// Until here we've been treating structures by pointer;
4075+
// we are now passing it as an arg, so need to load it.
4076+
val = bcx.build.Load(val);
4077+
}
4078+
}
4079+
40694080
llargs += vec(val);
40704081
i += 1u;
40714082
}

0 commit comments

Comments
 (0)