Skip to content

Commit 3eb20f3

Browse files
committed
Correct signatures and arguments associated with call into vec_append_glue.
1 parent d97c800 commit 3eb20f3

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/comp/middle/trans.rs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@ fn T_vec(TypeRef t) -> TypeRef {
321321
));
322322
}
323323

324+
fn T_opaque_vec_ptr() -> TypeRef {
325+
ret T_ptr(T_vec(T_int()));
326+
}
327+
324328
fn T_str() -> TypeRef {
325329
ret T_vec(T_i8());
326330
}
@@ -2464,20 +2468,23 @@ fn trans_vec_append(@block_ctxt cx, @ty.t t,
24642468
auto llelt_tydesc = get_tydesc(bcx, elt_ty);
24652469
bcx = llelt_tydesc.bcx;
24662470

2467-
ret res(cx, cx.build.FastCall(cx.fcx.ccx.glues.memcpy_glue,
2468-
vec(cx.fcx.lltaskptr,
2469-
llvec_tydesc.val,
2470-
llelt_tydesc.val,
2471-
lhs,
2472-
load_scalar_or_boxed(cx, rhs, t),
2473-
skip_null)));
2471+
auto dst = bcx.build.PointerCast(lhs, T_ptr(T_opaque_vec_ptr()));
2472+
auto src = bcx.build.PointerCast(rhs, T_opaque_vec_ptr());
2473+
2474+
ret res(bcx, bcx.build.FastCall(cx.fcx.ccx.glues.vec_append_glue,
2475+
vec(cx.fcx.lltaskptr,
2476+
llvec_tydesc.val,
2477+
llelt_tydesc.val,
2478+
dst, src, skip_null)));
24742479
}
24752480

24762481
fn trans_vec_add(@block_ctxt cx, @ty.t t,
24772482
ValueRef lhs, ValueRef rhs) -> result {
24782483
auto r = alloc_ty(cx, t);
2479-
r = copy_ty(r.bcx, INIT, r.val, lhs, t);
2480-
ret trans_vec_append(r.bcx, t, lhs, rhs);
2484+
auto tmp = r.val;
2485+
find_scope_cx(cx).cleanups += clean(bind drop_ty(_, tmp, t));
2486+
r = copy_ty(r.bcx, INIT, tmp, lhs, t);
2487+
ret trans_vec_append(r.bcx, t, tmp, rhs);
24812488
}
24822489

24832490

@@ -5423,7 +5430,7 @@ fn make_vec_append_glue(ModuleRef llmod, type_names tn) -> ValueRef {
54235430
* elements can be copied to a newly alloc'ed vec if one must be
54245431
* created.
54255432
*
5426-
* 3. Dst vec alias (i.e. ptr to ptr to rust_vec, we will mutate it).
5433+
* 3. Dst vec ptr (i.e. ptr to ptr to rust_vec).
54275434
*
54285435
* 4. Src vec (i.e. ptr to rust_vec).
54295436
*
@@ -5434,9 +5441,9 @@ fn make_vec_append_glue(ModuleRef llmod, type_names tn) -> ValueRef {
54345441
auto ty = T_fn(vec(T_taskptr(tn),
54355442
T_ptr(T_tydesc(tn)),
54365443
T_ptr(T_tydesc(tn)),
5437-
T_ptr(T_ptr(T_vec(T_int()))), // a lie.
5438-
T_ptr(T_vec(T_int())), // a lie.
5439-
T_bool()), T_void());
5444+
T_ptr(T_opaque_vec_ptr()),
5445+
T_opaque_vec_ptr(), T_bool()),
5446+
T_void());
54405447

54415448
auto llfn = decl_fastcall_fn(llmod, abi.vec_append_glue_name(), ty);
54425449
ret llfn;
@@ -5488,10 +5495,8 @@ fn trans_vec_append_glue(@crate_ctxt cx) {
54885495
vp2i(bcx, llvec_tydesc)));
54895496

54905497
bcx = llnew_vec_res.bcx;
5491-
auto llnew_vec = vi2p(bcx,
5492-
llnew_vec_res.val,
5493-
T_ptr(T_vec(T_int())) // a lie.
5494-
);
5498+
auto llnew_vec = vi2p(bcx, llnew_vec_res.val,
5499+
T_opaque_vec_ptr());
54955500

54965501

54975502
// FIXME: complete this.

0 commit comments

Comments
 (0)