diff options
| author | Graydon Hoare <[email protected]> | 2011-01-17 15:54:52 -0800 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-01-17 15:54:52 -0800 |
| commit | 58bf592dcc14a6b7c9609536f2094c3de135f337 (patch) | |
| tree | 119e806ef793926afad3f6ca4753336d01c5e3e8 | |
| parent | Allocate and reload retslots. Copy into them on polymorphic returns. (diff) | |
| download | rust-58bf592dcc14a6b7c9609536f2094c3de135f337.tar.xz rust-58bf592dcc14a6b7c9609536f2094c3de135f337.zip | |
Fix a couple bugs in parametric returns.
| -rw-r--r-- | src/comp/middle/trans.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 62c8a4fb..a449eec8 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -2014,8 +2014,7 @@ impure fn trans_args(@block_ctxt cx, auto retty = ty.ty_fn_ret(fn_ty); auto llretty = type_of(cx.fcx.ccx, retty); auto llretslot = cx.build.Alloca(llretty); - llretslot = cx.build.PointerCast(llretslot, T_ptr(T_i8())); - vs += llretslot; + vs += cx.build.PointerCast(llretslot, T_ptr(T_i8())); llretslot_opt = some[ValueRef](llretslot); } } @@ -2318,19 +2317,22 @@ impure fn trans_call(@block_ctxt cx, @ast.expr f, auto bcx = args_res._0; auto real_retval = bcx.build.FastCall(faddr, args_res._1); - auto retval; + auto retval = real_retval; + + if (ty.type_is_nil(ret_ty)) { + retval = C_nil(); + } // Check for a generic retslot. alt (args_res._2) { + case (some[ValueRef](?llretslot)) { - retval = bcx.build.Load(llretslot); + retval = load_scalar_or_boxed(bcx, llretslot, ret_ty); } - case (none[ValueRef]) { - retval = real_retval; - if (ty.type_is_nil(ret_ty)) { - retval = C_nil(); - } else if (ty.type_is_structural(ret_ty)) { + case (none[ValueRef]) { + if (! (ty.type_is_scalar(ret_ty) || + ty.type_is_boxed(ret_ty))) { // Structured returns come back as first-class values. This is // nice for LLVM but wrong for us; we treat structured values // by pointer in most of our code here. So spill it to an @@ -2342,8 +2344,6 @@ impure fn trans_call(@block_ctxt cx, @ast.expr f, } } - - // Retval doesn't correspond to anything really tangible in the frame, but // it's a ref all the same, so we put a note here to drop it when we're // done in this scope. |