diff options
| author | Patrick Walton <[email protected]> | 2011-03-19 13:58:48 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-03-19 13:58:48 -0700 |
| commit | c710c9a1b81f9231b3227159c9655ac7a2a5e099 (patch) | |
| tree | b5fa5a74b19bdead54fc5ed112b5516df65c1d3c /src/comp | |
| parent | rustc: Implement int-to-native casts (diff) | |
| download | rust-c710c9a1b81f9231b3227159c9655ac7a2a5e099.tar.xz rust-c710c9a1b81f9231b3227159c9655ac7a2a5e099.zip | |
rustc: Do argument casts before loading aggregates, not after
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/trans.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 71f0d65c..aa9c3cba 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -4029,11 +4029,6 @@ fn trans_args(@block_ctxt cx, auto re = trans_expr(bcx, e); val = re.val; bcx = re.bcx; - if (mode == ast.val) { - // Until here we've been treating structures by pointer; - // we are now passing it as an arg, so need to load it. - val = bcx.build.Load(val); - } } else if (mode == ast.alias) { let lval_result lv; if (ty.is_lval(e)) { @@ -4063,9 +4058,25 @@ fn trans_args(@block_ctxt cx, if (ty.count_ty_params(args.(i).ty) > 0u) { auto lldestty = arg_tys.(i); + if (mode == ast.val) { + // FIXME: we'd prefer to use &&, but rustboot doesn't like it + if (ty.type_is_structural(ty.expr_ty(e))) { + lldestty = T_ptr(lldestty); + } + } + val = bcx.build.PointerCast(val, lldestty); } + if (mode == ast.val) { + // FIXME: we'd prefer to use &&, but rustboot doesn't like it + if (ty.type_is_structural(ty.expr_ty(e))) { + // Until here we've been treating structures by pointer; + // we are now passing it as an arg, so need to load it. + val = bcx.build.Load(val); + } + } + llargs += vec(val); i += 1u; } |