Skip to content

Commit d9d5eb8

Browse files
committed
rustc: Allow glue to be emitted even for scalar types; this is necessary to support compare glue
1 parent 6599b31 commit d9d5eb8

File tree

1 file changed

+33
-38
lines changed

1 file changed

+33
-38
lines changed

src/comp/middle/trans.rs

+33-38
Original file line numberDiff line numberDiff line change
@@ -1694,53 +1694,48 @@ fn make_generic_glue(@local_ctxt cx,
16941694
auto bcx = new_top_block_ctxt(fcx);
16951695
auto lltop = bcx.llbb;
16961696

1697-
if (!ty.type_is_scalar(t)) {
1698-
1699-
// Any nontrivial glue is with values passed *by alias*; this is a
1700-
// requirement since in many contexts glue is invoked indirectly and
1701-
// the caller has no idea if it's dealing with something that can be
1702-
// passed by value.
1697+
// Any nontrivial glue is with values passed *by alias*; this is a
1698+
// requirement since in many contexts glue is invoked indirectly and
1699+
// the caller has no idea if it's dealing with something that can be
1700+
// passed by value.
17031701

1704-
auto llty;
1705-
if (ty.type_has_dynamic_size(t)) {
1706-
llty = T_ptr(T_i8());
1707-
} else {
1708-
llty = T_ptr(type_of(cx.ccx, t));
1709-
}
1702+
auto llty;
1703+
if (ty.type_has_dynamic_size(t)) {
1704+
llty = T_ptr(T_i8());
1705+
} else {
1706+
llty = T_ptr(type_of(cx.ccx, t));
1707+
}
17101708

1711-
auto ty_param_count = _vec.len[uint](ty_params);
1709+
auto ty_param_count = _vec.len[uint](ty_params);
17121710

1713-
auto lltyparams = llvm.LLVMGetParam(llfn, 3u);
1711+
auto lltyparams = llvm.LLVMGetParam(llfn, 3u);
17141712

1715-
auto lltydescs = _vec.empty_mut[ValueRef]();
1716-
auto p = 0u;
1717-
while (p < ty_param_count) {
1718-
auto llparam = bcx.build.GEP(lltyparams, vec(C_int(p as int)));
1719-
llparam = bcx.build.Load(llparam);
1720-
_vec.grow_set[ValueRef](lltydescs, ty_params.(p), 0 as ValueRef,
1721-
llparam);
1722-
p += 1u;
1723-
}
1724-
bcx.fcx.lltydescs = _vec.freeze[ValueRef](lltydescs);
1713+
auto lltydescs = _vec.empty_mut[ValueRef]();
1714+
auto p = 0u;
1715+
while (p < ty_param_count) {
1716+
auto llparam = bcx.build.GEP(lltyparams, vec(C_int(p as int)));
1717+
llparam = bcx.build.Load(llparam);
1718+
_vec.grow_set[ValueRef](lltydescs, ty_params.(p), 0 as ValueRef,
1719+
llparam);
1720+
p += 1u;
1721+
}
1722+
bcx.fcx.lltydescs = _vec.freeze[ValueRef](lltydescs);
17251723

1726-
auto llrawptr0 = llvm.LLVMGetParam(llfn, 4u);
1727-
auto llval0 = bcx.build.BitCast(llrawptr0, llty);
1724+
auto llrawptr0 = llvm.LLVMGetParam(llfn, 4u);
1725+
auto llval0 = bcx.build.BitCast(llrawptr0, llty);
17281726

1729-
alt (helper) {
1730-
case (mgghf_single(?single_fn)) {
1731-
single_fn(bcx, llval0, t);
1732-
}
1733-
case (mgghf_cmp) {
1734-
auto llrawptr1 = llvm.LLVMGetParam(llfn, 5u);
1735-
auto llval1 = bcx.build.BitCast(llrawptr0, llty);
1727+
alt (helper) {
1728+
case (mgghf_single(?single_fn)) {
1729+
single_fn(bcx, llval0, t);
1730+
}
1731+
case (mgghf_cmp) {
1732+
auto llrawptr1 = llvm.LLVMGetParam(llfn, 5u);
1733+
auto llval1 = bcx.build.BitCast(llrawptr0, llty);
17361734

1737-
auto llcmpval = llvm.LLVMGetParam(llfn, 6u);
1735+
auto llcmpval = llvm.LLVMGetParam(llfn, 6u);
17381736

1739-
make_cmp_glue(bcx, llval0, llval1, t, llcmpval);
1740-
}
1737+
make_cmp_glue(bcx, llval0, llval1, t, llcmpval);
17411738
}
1742-
} else {
1743-
bcx.build.RetVoid();
17441739
}
17451740

17461741
// Tie up the llallocas -> lltop edge.

0 commit comments

Comments
 (0)