@@ -301,7 +301,7 @@ static Value *emit_pointer_from_objref(jl_codectx_t &ctx, Value *V)
301301}
302302
303303static Value *emit_unbox (jl_codectx_t &ctx, Type *to, const jl_cgval_t &x, jl_value_t *jt);
304- static void emit_unbox_store (jl_codectx_t &ctx, const jl_cgval_t &x, Value* dest, MDNode *tbaa_dest, Align alignment , bool isVolatile=false );
304+ static void emit_unbox_store (jl_codectx_t &ctx, const jl_cgval_t &x, Value* dest, MDNode *tbaa_dest, MaybeAlign align_src, Align align_dst , bool isVolatile=false );
305305
306306static bool type_is_permalloc (jl_value_t *typ)
307307{
@@ -1090,7 +1090,7 @@ static void split_value_into(jl_codectx_t &ctx, const jl_cgval_t &x, Align align
10901090 return ;
10911091 }
10921092 if (inline_roots_ptr == nullptr ) {
1093- emit_unbox_store (ctx, x, dst, ctx.tbaa ().tbaa_stack , align_dst, isVolatileStore);
1093+ emit_unbox_store (ctx, x, dst, ctx.tbaa ().tbaa_stack , align_src, align_dst, isVolatileStore);
10941094 return ;
10951095 }
10961096 Value *src = data_pointer (ctx, value_to_pointer (ctx, x));
@@ -1152,7 +1152,7 @@ static void split_value_into(jl_codectx_t &ctx, const jl_cgval_t &x, Align align
11521152 return ;
11531153 }
11541154 if (inline_roots.empty ()) {
1155- emit_unbox_store (ctx, x, dst, ctx.tbaa ().tbaa_stack , align_dst);
1155+ emit_unbox_store (ctx, x, dst, ctx.tbaa ().tbaa_stack , align_src, align_dst, false );
11561156 return ;
11571157 }
11581158 Value *src = data_pointer (ctx, value_to_pointer (ctx, x));
@@ -2351,7 +2351,7 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
23512351 r = boxed (ctx, rhs);
23522352 }
23532353 else if (intcast) {
2354- emit_unbox_store (ctx, rhs, intcast, ctx.tbaa ().tbaa_stack , intcast->getAlign ());
2354+ emit_unbox_store (ctx, rhs, intcast, ctx.tbaa ().tbaa_stack , MaybeAlign (), intcast->getAlign ());
23552355 r = ctx.builder .CreateLoad (realelty, intcast);
23562356 }
23572357 else if (aliasscope || Order != AtomicOrdering::NotAtomic || (tracked_pointers && rhs.inline_roots .empty ())) {
@@ -2389,7 +2389,7 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
23892389 }
23902390 else {
23912391 assert (Order == AtomicOrdering::NotAtomic && !isboxed && rhs.typ == jltype);
2392- emit_unbox_store (ctx, rhs, ptr, tbaa, Align (alignment));
2392+ emit_unbox_store (ctx, rhs, ptr, tbaa, MaybeAlign (), Align (alignment));
23932393 }
23942394 }
23952395 else if (isswapfield) {
@@ -2438,7 +2438,7 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
24382438 }
24392439 cmp = update_julia_type (ctx, cmp, jltype);
24402440 if (intcast) {
2441- emit_unbox_store (ctx, cmp, intcast, ctx.tbaa ().tbaa_stack , intcast->getAlign ());
2441+ emit_unbox_store (ctx, cmp, intcast, ctx.tbaa ().tbaa_stack , MaybeAlign (), intcast->getAlign ());
24422442 Compare = ctx.builder .CreateLoad (realelty, intcast);
24432443 }
24442444 else {
@@ -2509,7 +2509,7 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
25092509 r = boxed (ctx, rhs);
25102510 }
25112511 else if (intcast) {
2512- emit_unbox_store (ctx, rhs, intcast, ctx.tbaa ().tbaa_stack , intcast->getAlign ());
2512+ emit_unbox_store (ctx, rhs, intcast, ctx.tbaa ().tbaa_stack , MaybeAlign (), intcast->getAlign ());
25132513 r = ctx.builder .CreateLoad (realelty, intcast);
25142514 if (!tracked_pointers) // oldval is a slot, so put the oldval back
25152515 ctx.builder .CreateStore (realCompare, intcast);
@@ -2556,7 +2556,7 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
25562556 }
25572557 else {
25582558 assert (!isboxed && rhs.typ == jltype);
2559- emit_unbox_store (ctx, rhs, ptr, tbaa, Align (alignment));
2559+ emit_unbox_store (ctx, rhs, ptr, tbaa, MaybeAlign (), Align (alignment));
25602560 }
25612561 ctx.builder .CreateBr (DoneBB);
25622562 instr = load;
@@ -3352,9 +3352,10 @@ static void init_bits_value(jl_codectx_t &ctx, Value *newv, Value *v, MDNode *tb
33523352static void init_bits_cgval (jl_codectx_t &ctx, Value *newv, const jl_cgval_t &v)
33533353{
33543354 MDNode *tbaa = jl_is_mutable (v.typ ) ? ctx.tbaa ().tbaa_mutab : ctx.tbaa ().tbaa_immut ;
3355- Align newv_align{std::max (julia_alignment (v.typ ), (unsigned )sizeof (void *))};
3355+ unsigned alignment = julia_alignment (v.typ );
3356+ unsigned newv_align = std::max (alignment, (unsigned )sizeof (void *));
33563357 newv = maybe_decay_tracked (ctx, newv);
3357- emit_unbox_store (ctx, v, newv, tbaa, newv_align);
3358+ emit_unbox_store (ctx, v, newv, tbaa, Align (alignment), Align ( newv_align) );
33583359}
33593360
33603361static jl_value_t *static_constant_instance (const llvm::DataLayout &DL, Constant *constant, jl_value_t *jt)
@@ -3808,7 +3809,7 @@ static void emit_unionmove(jl_codectx_t &ctx, Value *dest, MDNode *tbaa_dst, con
38083809 if (jl_is_pointerfree (typ)) {
38093810 emit_guarded_test (ctx, skip, nullptr , [&] {
38103811 unsigned alignment = julia_alignment (typ);
3811- emit_unbox_store (ctx, mark_julia_const (ctx, src.constant ), dest, tbaa_dst, Align (alignment), isVolatile);
3812+ emit_unbox_store (ctx, mark_julia_const (ctx, src.constant ), dest, tbaa_dst, Align (alignment), Align (alignment), isVolatile);
38123813 return nullptr ;
38133814 });
38143815 }
@@ -3818,7 +3819,7 @@ static void emit_unionmove(jl_codectx_t &ctx, Value *dest, MDNode *tbaa_dst, con
38183819 if (jl_is_pointerfree (src.typ )) {
38193820 emit_guarded_test (ctx, skip, nullptr , [&] {
38203821 unsigned alignment = julia_alignment (src.typ );
3821- emit_unbox_store (ctx, src, dest, tbaa_dst, Align (alignment), isVolatile);
3822+ emit_unbox_store (ctx, src, dest, tbaa_dst, Align (alignment), Align (alignment), isVolatile);
38223823 return nullptr ;
38233824 });
38243825 }
@@ -4273,6 +4274,8 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
42734274 }
42744275 }
42754276 else {
4277+ Align align_dst (jl_field_align (sty, i));
4278+ Align align_src (julia_alignment (jtype));
42764279 if (field_promotable) {
42774280 fval_info.V ->replaceAllUsesWith (dest);
42784281 cast<Instruction>(fval_info.V )->eraseFromParent ();
@@ -4281,10 +4284,10 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
42814284 fval = emit_unbox (ctx, fty, fval_info, jtype);
42824285 }
42834286 else if (!roots.empty ()) {
4284- split_value_into (ctx, fval_info, Align ( julia_alignment (jtype)) , dest, Align ( jl_field_align (sty, i)) , jl_aliasinfo_t::fromTBAA (ctx, ctx.tbaa ().tbaa_stack ), roots);
4287+ split_value_into (ctx, fval_info, align_src , dest, align_dst , jl_aliasinfo_t::fromTBAA (ctx, ctx.tbaa ().tbaa_stack ), roots);
42854288 }
42864289 else {
4287- emit_unbox_store (ctx, fval_info, dest, ctx.tbaa ().tbaa_stack , Align ( jl_field_align (sty, i)) );
4290+ emit_unbox_store (ctx, fval_info, dest, ctx.tbaa ().tbaa_stack , align_src, align_dst );
42884291 }
42894292 }
42904293 if (init_as_value) {
0 commit comments