@@ -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)
@@ -3816,7 +3817,7 @@ static void emit_unionmove(jl_codectx_t &ctx, Value *dest, MDNode *tbaa_dst, con
38163817 if (jl_is_pointerfree (typ)) {
38173818 emit_guarded_test (ctx, skip, nullptr , [&] {
38183819 unsigned alignment = julia_alignment (typ);
3819- emit_unbox_store (ctx, mark_julia_const (ctx, src.constant ), dest, tbaa_dst, Align (alignment), isVolatile);
3820+ emit_unbox_store (ctx, mark_julia_const (ctx, src.constant ), dest, tbaa_dst, Align (alignment), Align (alignment), isVolatile);
38203821 return nullptr ;
38213822 });
38223823 }
@@ -3826,7 +3827,7 @@ static void emit_unionmove(jl_codectx_t &ctx, Value *dest, MDNode *tbaa_dst, con
38263827 if (jl_is_pointerfree (src.typ )) {
38273828 emit_guarded_test (ctx, skip, nullptr , [&] {
38283829 unsigned alignment = julia_alignment (src.typ );
3829- emit_unbox_store (ctx, src, dest, tbaa_dst, Align (alignment), isVolatile);
3830+ emit_unbox_store (ctx, src, dest, tbaa_dst, Align (alignment), Align (alignment), isVolatile);
38303831 return nullptr ;
38313832 });
38323833 }
@@ -4289,6 +4290,8 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
42894290 }
42904291 }
42914292 else {
4293+ Align align_dst (jl_field_align (sty, i));
4294+ Align align_src (julia_alignment (jtype));
42924295 if (field_promotable) {
42934296 fval_info.V ->replaceAllUsesWith (dest);
42944297 cast<Instruction>(fval_info.V )->eraseFromParent ();
@@ -4297,10 +4300,10 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
42974300 fval = emit_unbox (ctx, fty, fval_info, jtype);
42984301 }
42994302 else if (!roots.empty ()) {
4300- 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);
4303+ split_value_into (ctx, fval_info, align_src , dest, align_dst , jl_aliasinfo_t::fromTBAA (ctx, ctx.tbaa ().tbaa_stack ), roots);
43014304 }
43024305 else {
4303- emit_unbox_store (ctx, fval_info, dest, ctx.tbaa ().tbaa_stack , Align ( jl_field_align (sty, i)) );
4306+ emit_unbox_store (ctx, fval_info, dest, ctx.tbaa ().tbaa_stack , align_src, align_dst );
43044307 }
43054308 }
43064309 if (init_as_value) {
0 commit comments