if simple {
return true;
}
- // FIXME: #9651: C-like enums should also be immediate
- if ty::type_is_c_like_enum(ccx.tcx, ty) {
- return false;
- }
match ty::get(ty).sty {
// FIXME: #9651: small `ty_struct` should also be immediate
ty::ty_struct(def_id, ref substs) => {
(cast_enum, cast_float) => {
let bcx = bcx;
let repr = adt::represent_type(ccx, t_in);
- let lldiscrim_a = adt::trans_get_discr(bcx, repr, llexpr);
+ let slot = Alloca(bcx, ll_t_in, "");
+ Store(bcx, llexpr, slot);
+ let lldiscrim_a = adt::trans_get_discr(bcx, repr, slot);
match k_out {
cast_integral => int_cast(bcx, ll_t_out,
val_ty(lldiscrim_a),
// Ensure that we always have the Rust value indirectly,
// because it makes bitcasting easier.
if !rust_indirect {
- let scratch = base::alloca(bcx, arg_tys[i].ty, "__arg");
+ let scratch = base::alloca(bcx, type_of::type_of(ccx, fn_sig.inputs[i]), "__arg");
Store(bcx, llarg_rust, scratch);
llarg_rust = scratch;
}
use back::{abi};
use lib::llvm::{SequentiallyConsistent, Acquire, Release, Xchg};
-use lib::llvm::{ValueRef, Pointer};
+use lib::llvm::{ValueRef, Pointer, Array, Struct};
use lib;
use middle::trans::base::*;
use middle::trans::build::*;
(Pointer, other) | (other, Pointer) if other != Pointer => {
let tmp = Alloca(bcx, llouttype, "");
Store(bcx, llsrcval, PointerCast(bcx, tmp, llintype.ptr_to()));
- let ll_load = Load(bcx, tmp);
- Ret(bcx, ll_load);
+ Ret(bcx, Load(bcx, tmp));
+ }
+ (Array, _) | (_, Array) | (Struct, _) | (_, Struct) => {
+ let tmp = Alloca(bcx, llouttype, "");
+ Store(bcx, llsrcval, PointerCast(bcx, tmp, llintype.ptr_to()));
+ Ret(bcx, Load(bcx, tmp));
}
_ => {
let llbitcast = BitCast(bcx, llsrcval, llouttype);