@@ -3659,15 +3659,8 @@ static void emit_assignment(jl_value_t *l, jl_value_t *r, jl_codectx_t *ctx)
3659
3659
builder.CreateAnd (slot.TIndex , ConstantInt::get (T_int8, 0x80 )),
3660
3660
ConstantInt::get (T_int8, 0 ));
3661
3661
}
3662
- if (dest) {
3663
- Value *copy_bytes = emit_sizeof (slot, ctx);
3664
- if (isboxed)
3665
- copy_bytes = builder.CreateSelect (isboxed, ConstantInt::get (copy_bytes->getType (), 0 ), copy_bytes);
3666
- builder.CreateMemCpy (dest,
3667
- data_pointer (slot, ctx, T_pint8),
3668
- copy_bytes,
3669
- min_align);
3670
- }
3662
+ if (dest)
3663
+ emit_unionmove (dest, slot, isboxed, false , NULL , ctx);
3671
3664
Value *gcroot = NULL ;
3672
3665
if (isboxed) {
3673
3666
if (slot.gcroot )
@@ -3770,6 +3763,8 @@ static void emit_assignment(jl_value_t *l, jl_value_t *r, jl_codectx_t *ctx)
3770
3763
tindex = compute_tindex_unboxed (rval_info, vi.value .typ , ctx);
3771
3764
if (vi.boxroot )
3772
3765
tindex = builder.CreateOr (tindex, ConstantInt::get (T_int8, 0x80 ));
3766
+ if (!vi.boxroot )
3767
+ rval_info.TIndex = tindex;
3773
3768
}
3774
3769
builder.CreateStore (tindex, vi.pTIndex , vi.isVolatile );
3775
3770
}
@@ -3838,22 +3833,19 @@ static void emit_assignment(jl_value_t *l, jl_value_t *r, jl_codectx_t *ctx)
3838
3833
// x.tbaa ∪ tbaa_stack = tbaa_root if x.tbaa != tbaa_stack
3839
3834
if (tbaa != tbaa_stack)
3840
3835
tbaa = NULL ;
3841
- Value *copy_bytes;
3842
3836
if (vi.pTIndex == NULL ) {
3843
3837
assert (jl_is_leaf_type (vi.value .typ ));
3844
- copy_bytes = ConstantInt::get (T_int32, jl_datatype_size (vi.value .typ ));
3838
+ Value *copy_bytes = ConstantInt::get (T_int32, jl_datatype_size (vi.value .typ ));
3839
+ builder.CreateMemCpy (vi.value .V ,
3840
+ data_pointer (rval_info, ctx, T_pint8),
3841
+ copy_bytes,
3842
+ /* TODO: min_align*/ 1 ,
3843
+ vi.isVolatile ,
3844
+ tbaa);
3845
3845
}
3846
3846
else {
3847
- copy_bytes = emit_sizeof (rval_info, ctx);
3848
- if (isboxed)
3849
- copy_bytes = builder.CreateSelect (isboxed, ConstantInt::get (copy_bytes->getType (), 0 ), copy_bytes);
3847
+ emit_unionmove (vi.value .V , rval_info, isboxed, vi.isVolatile , tbaa, ctx);
3850
3848
}
3851
- builder.CreateMemCpy (vi.value .V ,
3852
- data_pointer (rval_info, ctx, T_pint8),
3853
- copy_bytes,
3854
- /* TODO: min_align*/ 1 ,
3855
- vi.isVolatile ,
3856
- tbaa);
3857
3849
}
3858
3850
}
3859
3851
else {
@@ -5965,7 +5957,7 @@ static std::unique_ptr<Module> emit_function(
5965
5957
continue ;
5966
5958
}
5967
5959
5968
- Value *isunboxed_union = NULL ;
5960
+ Value *isboxed_union = NULL ;
5969
5961
Value *retval;
5970
5962
Value *sret = ctx.has_sret ? &*f->arg_begin () : NULL ;
5971
5963
Type *retty = f->getReturnType ();
@@ -5996,10 +5988,10 @@ static std::unique_ptr<Module> emit_function(
5996
5988
if (retvalinfo.ispointer () && !isa<AllocaInst>(retvalinfo.V )) {
5997
5989
// also need to account for the possibility the return object is boxed
5998
5990
// and avoid / skip copying it to the stack
5999
- isunboxed_union = builder.CreateICmpEQ (
5991
+ isboxed_union = builder.CreateICmpNE (
6000
5992
builder.CreateAnd (tindex, ConstantInt::get (T_int8, 0x80 )),
6001
5993
ConstantInt::get (T_int8, 0 ));
6002
- data = builder.CreateSelect (isunboxed_union, data, emit_bitcast (retvalinfo.V , T_pjlvalue));
5994
+ data = builder.CreateSelect (isboxed_union, emit_bitcast (retvalinfo.V , T_pjlvalue), data );
6003
5995
}
6004
5996
}
6005
5997
}
@@ -6022,20 +6014,17 @@ static std::unique_ptr<Module> emit_function(
6022
6014
}
6023
6015
if (sret) {
6024
6016
if (retvalinfo.ispointer ()) {
6025
- Value *copy_bytes;
6026
6017
if (returninfo.cc == jl_returninfo_t ::SRet) {
6027
6018
assert (jl_is_leaf_type (jlrettype));
6028
- copy_bytes = ConstantInt::get (T_int32, jl_datatype_size (jlrettype));
6019
+ Value *copy_bytes = ConstantInt::get (T_int32, jl_datatype_size (jlrettype));
6020
+ builder.CreateMemCpy (sret,
6021
+ data_pointer (retvalinfo, &ctx, T_pint8),
6022
+ copy_bytes,
6023
+ returninfo.union_minalign );
6029
6024
}
6030
6025
else {
6031
- copy_bytes = emit_sizeof (retvalinfo, &ctx);
6032
- if (isunboxed_union)
6033
- copy_bytes = builder.CreateSelect (isunboxed_union, copy_bytes, ConstantInt::get (copy_bytes->getType (), 0 ));
6026
+ emit_unionmove (sret, retvalinfo, isboxed_union, false , NULL , &ctx);
6034
6027
}
6035
- builder.CreateMemCpy (sret,
6036
- data_pointer (retvalinfo, &ctx, T_pint8),
6037
- copy_bytes,
6038
- returninfo.union_minalign );
6039
6028
}
6040
6029
else {
6041
6030
Type *store_ty = julia_type_to_llvm (retvalinfo.typ );
0 commit comments