Skip to content

Commit 40dc929

Browse files
committed
---
yaml --- r: 1113 b: refs/heads/master c: 7210a31 h: refs/heads/master i: 1111: 492ba6a v: v3
1 parent 22e4e20 commit 40dc929

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: b00abd04e26ee26a4f37d9f94dc1e28424a970d0
2+
refs/heads/master: 7210a31e2aadb8f7995326126d3411ebc19a7408

trunk/src/comp/middle/trans.rs

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -594,13 +594,7 @@ fn make_ty_info(@crate_ctxt cx, @typeck.ty ty) {
594594

595595
fn make_generic_glue(@crate_ctxt cx, @typeck.ty t, str name,
596596
val_and_ty_fn helper) -> ValueRef {
597-
auto arg_t;
598-
if (typeck.type_is_structural(t)) {
599-
arg_t = T_ptr(type_of(cx, t));
600-
} else {
601-
arg_t = type_of(cx, t);
602-
}
603-
auto llfnty = T_fn(vec(T_taskptr(), arg_t), T_void());
597+
auto llfnty = T_fn(vec(T_taskptr(), T_ptr(T_i8())), T_void());
604598

605599
auto fn_name = cx.names.next("_rust_" + name) + "." + typeck.ty_to_str(t);
606600
fn_name = sanitize(fn_name);
@@ -609,11 +603,24 @@ fn make_generic_glue(@crate_ctxt cx, @typeck.ty t, str name,
609603
auto fcx = new_fn_ctxt(cx, fn_name, llfn);
610604
auto bcx = new_top_block_ctxt(fcx);
611605

612-
auto llval = llvm.LLVMGetParam(llfn, 1u);
606+
auto re;
607+
if (!typeck.type_is_scalar(t)) {
608+
auto llty;
609+
if (typeck.type_is_structural(t)) {
610+
llty = T_ptr(type_of(cx, t));
611+
} else {
612+
llty = type_of(cx, t);
613+
}
613614

614-
auto res = helper(bcx, llval, t);
615+
auto llrawptr = llvm.LLVMGetParam(llfn, 1u);
616+
auto llval = bcx.build.BitCast(llrawptr, llty);
617+
618+
re = helper(bcx, llval, t);
619+
} else {
620+
re = res(bcx, C_nil());
621+
}
615622

616-
res.bcx.build.RetVoid();
623+
re.bcx.build.RetVoid();
617624
ret llfn;
618625
}
619626

@@ -960,8 +967,11 @@ fn iter_sequence(@block_ctxt cx,
960967
fn incr_all_refcnts(@block_ctxt cx,
961968
ValueRef v,
962969
@typeck.ty t) -> result {
963-
cx.build.FastCall(get_ty_info(cx.fcx.ccx, t).take_glue,
964-
vec(cx.fcx.lltaskptr, v));
970+
if (!typeck.type_is_scalar(t)) {
971+
auto llrawptr = cx.build.BitCast(v, T_ptr(T_i8()));
972+
cx.build.FastCall(get_ty_info(cx.fcx.ccx, t).take_glue,
973+
vec(cx.fcx.lltaskptr, llrawptr));
974+
}
965975
ret res(cx, C_nil());
966976
}
967977

@@ -980,8 +990,11 @@ fn drop_slot(@block_ctxt cx,
980990
fn drop_ty(@block_ctxt cx,
981991
ValueRef v,
982992
@typeck.ty t) -> result {
983-
cx.build.FastCall(get_ty_info(cx.fcx.ccx, t).drop_glue,
984-
vec(cx.fcx.lltaskptr, v));
993+
if (!typeck.type_is_scalar(t)) {
994+
auto llrawptr = cx.build.BitCast(v, T_ptr(T_i8()));
995+
cx.build.FastCall(get_ty_info(cx.fcx.ccx, t).drop_glue,
996+
vec(cx.fcx.lltaskptr, llrawptr));
997+
}
985998
ret res(cx, C_nil());
986999
}
9871000

trunk/src/comp/middle/typeck.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,7 @@ fn type_is_boxed(@ty t) -> bool {
887887

888888
fn type_is_scalar(@ty t) -> bool {
889889
alt (t.struct) {
890+
case (ty_nil) { ret true; }
890891
case (ty_bool) { ret true; }
891892
case (ty_int) { ret true; }
892893
case (ty_uint) { ret true; }

0 commit comments

Comments
 (0)