@@ -310,7 +310,7 @@ static Value *emit_pointer_from_objref(jl_codectx_t &ctx, Value *V)
310310}
311311
312312static Value *emit_unbox (jl_codectx_t &ctx, Type *to, const jl_cgval_t &x, jl_value_t *jt);
313- static void emit_unbox_store (jl_codectx_t &ctx, const jl_cgval_t &x, Value* dest, MDNode *tbaa_dest, unsigned alignment, bool isVolatile=false );
313+ static void emit_unbox_store (jl_codectx_t &ctx, const jl_cgval_t &x, Value* dest, MDNode *tbaa_dest, Align alignment, bool isVolatile=false );
314314
315315static Value *get_gc_root_for (jl_codectx_t &ctx, const jl_cgval_t &x)
316316{
@@ -980,11 +980,10 @@ static Value *data_pointer(jl_codectx_t &ctx, const jl_cgval_t &x)
980980}
981981
982982static void emit_memcpy_llvm (jl_codectx_t &ctx, Value *dst, jl_aliasinfo_t const &dst_ai, Value *src,
983- jl_aliasinfo_t const &src_ai, uint64_t sz, unsigned align_dst, unsigned align_src, bool is_volatile)
983+ jl_aliasinfo_t const &src_ai, uint64_t sz, Align align_dst, Align align_src, bool is_volatile)
984984{
985985 if (sz == 0 )
986986 return ;
987- assert (align_dst && " align must be specified" );
988987 // If the types are small and simple, use load and store directly.
989988 // Going through memcpy can cause LLVM (e.g. SROA) to create bitcasts between float and int
990989 // that interferes with other optimizations.
@@ -1026,7 +1025,7 @@ static void emit_memcpy_llvm(jl_codectx_t &ctx, Value *dst, jl_aliasinfo_t const
10261025 if (isa<Instruction>(dst) && !dst->hasName ())
10271026 setName (ctx.emission_context , dst, " memcpy_refined_dst" );
10281027 auto val = src_ai.decorateInst (ctx.builder .CreateAlignedLoad (directel, src, MaybeAlign (align_src), is_volatile));
1029- dst_ai.decorateInst (ctx.builder .CreateAlignedStore (val, dst, Align ( align_dst) , is_volatile));
1028+ dst_ai.decorateInst (ctx.builder .CreateAlignedStore (val, dst, align_dst, is_volatile));
10301029 ++SkippedMemcpys;
10311030 return ;
10321031 }
@@ -1044,12 +1043,12 @@ static void emit_memcpy_llvm(jl_codectx_t &ctx, Value *dst, jl_aliasinfo_t const
10441043 // above problem won't be as serious.
10451044
10461045 auto merged_ai = dst_ai.merge (src_ai);
1047- ctx.builder .CreateMemCpy (dst, Align ( align_dst) , src, Align ( align_src) , sz, is_volatile,
1046+ ctx.builder .CreateMemCpy (dst, align_dst, src, align_src, sz, is_volatile,
10481047 merged_ai.tbaa , merged_ai.tbaa_struct , merged_ai.scope , merged_ai.noalias );
10491048}
10501049
10511050static void emit_memcpy_llvm (jl_codectx_t &ctx, Value *dst, jl_aliasinfo_t const &dst_ai, Value *src,
1052- jl_aliasinfo_t const &src_ai, Value *sz, unsigned align_dst, unsigned align_src, bool is_volatile)
1051+ jl_aliasinfo_t const &src_ai, Value *sz, Align align_dst, Align align_src, bool is_volatile)
10531052{
10541053 if (auto const_sz = dyn_cast<ConstantInt>(sz)) {
10551054 emit_memcpy_llvm (ctx, dst, dst_ai, src, src_ai, const_sz->getZExtValue (), align_dst, align_src, is_volatile);
@@ -1058,20 +1057,20 @@ static void emit_memcpy_llvm(jl_codectx_t &ctx, Value *dst, jl_aliasinfo_t const
10581057 ++EmittedMemcpys;
10591058
10601059 auto merged_ai = dst_ai.merge (src_ai);
1061- ctx.builder .CreateMemCpy (dst, MaybeAlign ( align_dst) , src, MaybeAlign ( align_src) , sz, is_volatile,
1060+ ctx.builder .CreateMemCpy (dst, align_dst, src, align_src, sz, is_volatile,
10621061 merged_ai.tbaa , merged_ai.tbaa_struct , merged_ai.scope , merged_ai.noalias );
10631062}
10641063
10651064template <typename T1>
10661065static void emit_memcpy (jl_codectx_t &ctx, Value *dst, jl_aliasinfo_t const &dst_ai, Value *src,
1067- jl_aliasinfo_t const &src_ai, T1 &&sz, unsigned align_dst, unsigned align_src, bool is_volatile=false )
1066+ jl_aliasinfo_t const &src_ai, T1 &&sz, Align align_dst, Align align_src, bool is_volatile=false )
10681067{
10691068 emit_memcpy_llvm (ctx, dst, dst_ai, src, src_ai, sz, align_dst, align_src, is_volatile);
10701069}
10711070
10721071template <typename T1>
10731072static void emit_memcpy (jl_codectx_t &ctx, Value *dst, jl_aliasinfo_t const &dst_ai, const jl_cgval_t &src,
1074- T1 &&sz, unsigned align_dst, unsigned align_src, bool is_volatile=false )
1073+ T1 &&sz, Align align_dst, Align align_src, bool is_volatile=false )
10751074{
10761075 auto src_ai = jl_aliasinfo_t::fromTBAA (ctx, src.tbaa );
10771076 emit_memcpy_llvm (ctx, dst, dst_ai, data_pointer (ctx, src), src_ai, sz, align_dst, align_src, is_volatile);
@@ -1972,7 +1971,7 @@ static jl_cgval_t typed_load(jl_codectx_t &ctx, Value *ptr, Value *idx_0based, j
19721971 else if (!alignment)
19731972 alignment = julia_alignment (jltype);
19741973 if (intcast && Order == AtomicOrdering::NotAtomic) {
1975- emit_memcpy (ctx, intcast, jl_aliasinfo_t::fromTBAA (ctx, ctx.tbaa ().tbaa_stack ), data, jl_aliasinfo_t::fromTBAA (ctx, tbaa), nb, alignment, intcast->getAlign (). value ());
1974+ emit_memcpy (ctx, intcast, jl_aliasinfo_t::fromTBAA (ctx, ctx.tbaa ().tbaa_stack ), data, jl_aliasinfo_t::fromTBAA (ctx, tbaa), nb, Align ( alignment) , intcast->getAlign ());
19761975 }
19771976 else {
19781977 if (!isboxed && jl_is_genericmemoryref_type (jltype)) {
@@ -2152,7 +2151,7 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
21522151 }
21532152 else {
21542153 assert (Order == AtomicOrdering::NotAtomic && !isboxed && rhs.typ == jltype);
2155- emit_unbox_store (ctx, rhs, ptr, tbaa, alignment);
2154+ emit_unbox_store (ctx, rhs, ptr, tbaa, Align ( alignment) );
21562155 }
21572156 }
21582157 else if (isswapfield) {
@@ -2304,7 +2303,7 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
23042303 }
23052304 else {
23062305 assert (!isboxed && rhs.typ == jltype);
2307- emit_unbox_store (ctx, rhs, ptr, tbaa, alignment);
2306+ emit_unbox_store (ctx, rhs, ptr, tbaa, Align ( alignment) );
23082307 }
23092308 ctx.builder .CreateBr (DoneBB);
23102309 instr = load;
@@ -2617,7 +2616,7 @@ static jl_cgval_t emit_unionload(jl_codectx_t &ctx, Value *addr, Value *ptindex,
26172616 if (al > 1 )
26182617 lv->setAlignment (Align (al));
26192618 jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA (ctx, tbaa);
2620- emit_memcpy (ctx, lv, ai, addr, ai, fsz, al, al );
2619+ emit_memcpy (ctx, lv, ai, addr, ai, fsz, Align (al), Align (al) );
26212620 addr = lv;
26222621 }
26232622 return mark_julia_slot (fsz > 0 ? addr : nullptr , jfty, tindex, tbaa);
@@ -2960,20 +2959,20 @@ static Value *emit_genericmemoryowner(jl_codectx_t &ctx, Value *t)
29602959static Value *emit_allocobj (jl_codectx_t &ctx, jl_datatype_t *jt, bool fully_initialized);
29612960
29622961static void init_bits_value (jl_codectx_t &ctx, Value *newv, Value *v, MDNode *tbaa,
2963- unsigned alignment = sizeof (void *)) // min alignment in julia's gc is pointer-aligned
2962+ Align alignment = Align( sizeof (void *) )) // min alignment in julia's gc is pointer-aligned
29642963{
29652964 jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA (ctx, tbaa);
29662965 // newv should already be tagged
29672966 ai.decorateInst (ctx.builder .CreateAlignedStore (v, emit_bitcast (ctx, newv,
2968- PointerType::get (v->getType (), 0 )), Align ( alignment) ));
2967+ PointerType::get (v->getType (), 0 )), alignment));
29692968}
29702969
29712970static void init_bits_cgval (jl_codectx_t &ctx, Value *newv, const jl_cgval_t & v, MDNode *tbaa)
29722971{
29732972 // newv should already be tagged
29742973 if (v.ispointer ()) {
29752974 unsigned align = std::max (julia_alignment (v.typ ), (unsigned )sizeof (void *));
2976- emit_memcpy (ctx, newv, jl_aliasinfo_t::fromTBAA (ctx, tbaa), v, jl_datatype_size (v.typ ), align, julia_alignment (v.typ ));
2975+ emit_memcpy (ctx, newv, jl_aliasinfo_t::fromTBAA (ctx, tbaa), v, jl_datatype_size (v.typ ), Align ( align), Align ( julia_alignment (v.typ ) ));
29772976 }
29782977 else {
29792978 init_bits_value (ctx, newv, v.V , tbaa);
@@ -3432,7 +3431,7 @@ static void emit_unionmove(jl_codectx_t &ctx, Value *dest, MDNode *tbaa_dst, con
34323431 if (jl_is_pointerfree (typ)) {
34333432 unsigned alignment = julia_alignment (typ);
34343433 if (!src.ispointer () || src.constant ) {
3435- emit_unbox_store (ctx, src, dest, tbaa_dst, alignment, isVolatile);
3434+ emit_unbox_store (ctx, src, dest, tbaa_dst, Align ( alignment) , isVolatile);
34363435 }
34373436 else {
34383437 Value *src_ptr = data_pointer (ctx, src);
@@ -3442,7 +3441,7 @@ static void emit_unionmove(jl_codectx_t &ctx, Value *dest, MDNode *tbaa_dst, con
34423441 // if (skip) src_ptr = ctx.builder.CreateSelect(skip, dest, src_ptr);
34433442 auto f = [&] {
34443443 (void )emit_memcpy (ctx, dest, jl_aliasinfo_t::fromTBAA (ctx, tbaa_dst), src_ptr,
3445- jl_aliasinfo_t::fromTBAA (ctx, src.tbaa ), nb, alignment, alignment, isVolatile);
3444+ jl_aliasinfo_t::fromTBAA (ctx, src.tbaa ), nb, Align ( alignment), Align ( alignment) , isVolatile);
34463445 return nullptr ;
34473446 };
34483447 if (skip)
@@ -3479,7 +3478,7 @@ static void emit_unionmove(jl_codectx_t &ctx, Value *dest, MDNode *tbaa_dst, con
34793478 return ;
34803479 } else {
34813480 emit_memcpy (ctx, dest, jl_aliasinfo_t::fromTBAA (ctx, tbaa_dst), src_ptr,
3482- jl_aliasinfo_t::fromTBAA (ctx, src.tbaa ), nb, alignment, alignment, isVolatile);
3481+ jl_aliasinfo_t::fromTBAA (ctx, src.tbaa ), nb, Align ( alignment), Align ( alignment) , isVolatile);
34833482 }
34843483 }
34853484 ctx.builder .CreateBr (postBB);
@@ -3505,7 +3504,7 @@ static void emit_unionmove(jl_codectx_t &ctx, Value *dest, MDNode *tbaa_dst, con
35053504 Value *datatype = emit_typeof (ctx, src, false , false );
35063505 Value *copy_bytes = emit_datatype_size (ctx, datatype);
35073506 (void )emit_memcpy (ctx, dest, jl_aliasinfo_t::fromTBAA (ctx, tbaa_dst), data_pointer (ctx, src),
3508- jl_aliasinfo_t::fromTBAA (ctx, src.tbaa ), copy_bytes, 1 , 1 , isVolatile);
3507+ jl_aliasinfo_t::fromTBAA (ctx, src.tbaa ), copy_bytes, Align ( 1 ), Align ( 1 ) , isVolatile);
35093508 return nullptr ;
35103509 };
35113510 if (skip)
@@ -3922,7 +3921,7 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
39223921 } else if (init_as_value) {
39233922 fval = emit_unbox (ctx, fty, fval_info, jtype);
39243923 } else {
3925- emit_unbox_store (ctx, fval_info, dest, ctx.tbaa ().tbaa_stack , jl_field_align (sty, i));
3924+ emit_unbox_store (ctx, fval_info, dest, ctx.tbaa ().tbaa_stack , Align ( jl_field_align (sty, i) ));
39263925 }
39273926 }
39283927 if (init_as_value) {
0 commit comments