@@ -3808,7 +3808,29 @@ static void emit_assignment(jl_value_t *l, jl_value_t *r, jl_codectx_t *ctx)
3808
3808
if (vi.value .V == NULL ) {
3809
3809
// all ghost values in destination - nothing to copy or store
3810
3810
}
3811
- else if (rval_info.ispointer ()) {
3811
+ else if (rval_info.constant || !rval_info.ispointer ()) {
3812
+ if (rval_info.isghost ) {
3813
+ // all ghost values in source - nothing to copy or store
3814
+ }
3815
+ else {
3816
+ if (rval_info.typ != vi.value .typ && !vi.pTIndex && !rval_info.TIndex ) {
3817
+ // isbits cast-on-assignment is invalid. this branch should be dead-code.
3818
+ CreateTrap (builder);
3819
+ }
3820
+ else {
3821
+ Value *dest = vi.value .V ;
3822
+ Type *store_ty = julia_type_to_llvm (rval_info.constant ? jl_typeof (rval_info.constant ) : rval_info.typ );
3823
+ Type *dest_ty = store_ty->getPointerTo ();
3824
+ if (dest_ty != dest->getType ())
3825
+ dest = emit_bitcast (dest, dest_ty);
3826
+ tbaa_decorate (tbaa_stack, builder.CreateStore (
3827
+ emit_unbox (store_ty, rval_info, rval_info.typ ),
3828
+ dest,
3829
+ vi.isVolatile ));
3830
+ }
3831
+ }
3832
+ }
3833
+ else {
3812
3834
MDNode *tbaa = rval_info.tbaa ;
3813
3835
// the memcpy intrinsic does not allow to specify different alias tags
3814
3836
// for the load part (x.tbaa) and the store part (tbaa_stack).
@@ -3833,26 +3855,6 @@ static void emit_assignment(jl_value_t *l, jl_value_t *r, jl_codectx_t *ctx)
3833
3855
vi.isVolatile ,
3834
3856
tbaa);
3835
3857
}
3836
- else if (rval_info.V == NULL ) {
3837
- // all ghost values in source - nothing to copy or store
3838
- }
3839
- else {
3840
- if (rval_info.typ != vi.value .typ && !vi.pTIndex && !rval_info.TIndex ) {
3841
- // isbits cast-on-assignment is invalid. this branch should be dead-code.
3842
- CreateTrap (builder);
3843
- }
3844
- else {
3845
- Value *dest = vi.value .V ;
3846
- Type *store_ty = julia_type_to_llvm (rval_info.typ );
3847
- Type *dest_ty = store_ty->getPointerTo ();
3848
- if (dest_ty != dest->getType ())
3849
- dest = emit_bitcast (dest, dest_ty);
3850
- tbaa_decorate (tbaa_stack, builder.CreateStore (
3851
- emit_unbox (store_ty, rval_info, rval_info.typ ),
3852
- dest,
3853
- vi.isVolatile ));
3854
- }
3855
- }
3856
3858
}
3857
3859
else {
3858
3860
assert (vi.pTIndex == NULL );
0 commit comments