@@ -5054,7 +5054,7 @@ static jl_cgval_t emit_call_specfun_other(jl_codectx_t &ctx, bool is_opaque_clos
50545054 break ;
50555055 case jl_returninfo_t ::SRet:
50565056 assert (result);
5057- retval = mark_julia_slot (result, jlretty, NULL , ctx.tbaa ().tbaa_gcframe , load_gc_roots (ctx, return_roots, returninfo.return_roots ));
5057+ retval = mark_julia_slot (result, jlretty, NULL , ctx.tbaa ().tbaa_gcframe , load_gc_roots (ctx, return_roots, returninfo.return_roots , ctx. tbaa (). tbaa_gcframe ));
50585058 break ;
50595059 case jl_returninfo_t ::Union: {
50605060 Value *box = ctx.builder .CreateExtractValue (call, 0 );
@@ -5603,7 +5603,7 @@ static jl_cgval_t emit_varinfo(jl_codectx_t &ctx, jl_varinfo_t &vi, jl_sym_t *va
56035603 T_prjlvalue = AT->getElementType ();
56045604 }
56055605 assert (T_prjlvalue == ctx.types ().T_prjlvalue );
5606- v.inline_roots = load_gc_roots (ctx, varslot, nroots, vi.isVolatile );
5606+ v.inline_roots = load_gc_roots (ctx, varslot, nroots, ctx. tbaa (). tbaa_gcframe , vi.isVolatile );
56075607 }
56085608 if (vi.usedUndef ) {
56095609 assert (vi.defFlag );
@@ -6927,7 +6927,7 @@ static void emit_specsig_to_specsig(
69276927 auto tracked = CountTrackedPointers (et);
69286928 SmallVector<Value*,0 > roots;
69296929 if (tracked.count && !tracked.all ) {
6930- roots = load_gc_roots (ctx, &*AI, tracked.count );
6930+ roots = load_gc_roots (ctx, &*AI, tracked.count , ctx. tbaa (). tbaa_const );
69316931 ++AI;
69326932 }
69336933 myargs[i] = mark_julia_slot (arg_v, jt, NULL , ctx.tbaa ().tbaa_const , roots);
@@ -8511,7 +8511,7 @@ static jl_llvm_functions_t
85118511 ctx.spvals_ptr = &*AI++;
85128512 }
85138513 }
8514- // step 6 . set up GC frame and special arguments
8514+ // step 6a . set up special arguments and attributes
85158515 Function::arg_iterator AI = f->arg_begin ();
85168516 SmallVector<AttributeSet, 0 > attrs (f->arg_size ()); // function declaration attributes
85178517
@@ -8558,7 +8558,11 @@ static jl_llvm_functions_t
85588558 attrs[Arg->getArgNo ()] = AttributeSet::get (Arg->getContext (), param);
85598559 }
85608560
8561+ // step 6b. Setup the GC frame and entry safepoint before any loads
85618562 allocate_gc_frame (ctx, b0);
8563+ if (params.safepoint_on_entry && JL_FEAT_TEST (ctx, safepoint_on_entry))
8564+ emit_gc_safepoint (ctx.builder , ctx.types ().T_size , get_current_ptls (ctx), ctx.tbaa ().tbaa_const );
8565+
85628566 Value *last_age = NULL ;
85638567 Value *world_age_field = NULL ;
85648568 if (ctx.is_opaque_closure ) {
@@ -8716,7 +8720,14 @@ static jl_llvm_functions_t
87168720 SmallVector<Value*,0 > roots;
87178721 auto tracked = CountTrackedPointers (llvmArgType);
87188722 if (tracked.count && !tracked.all ) {
8719- roots = load_gc_roots (ctx, &*AI, tracked.count );
8723+ Argument *RootArg = &*AI;
8724+ roots = load_gc_roots (ctx, RootArg, tracked.count , ctx.tbaa ().tbaa_const );
8725+ AttrBuilder param (ctx.builder .getContext (), f->getAttributes ().getParamAttrs (Arg->getArgNo ()));
8726+ param.addAttribute (Attribute::NonNull);
8727+ param.addAttribute (Attribute::NoUndef);
8728+ param.addDereferenceableAttr (tracked.count * sizeof (void *));
8729+ param.addAlignmentAttr (alignof (void *));
8730+ attrs[RootArg->getArgNo ()] = AttributeSet::get (Arg->getContext (), param);
87208731 ++AI;
87218732 }
87228733 theArg = mark_julia_slot (Arg, argType, NULL , ctx.tbaa ().tbaa_const , roots); // this argument is by-pointer
@@ -9026,11 +9037,7 @@ static jl_llvm_functions_t
90269037
90279038 Instruction &prologue_end = ctx.builder .GetInsertBlock ()->back ();
90289039
9029- // step 11a. Emit the entry safepoint
9030- if (params.safepoint_on_entry && JL_FEAT_TEST (ctx, safepoint_on_entry))
9031- emit_gc_safepoint (ctx.builder , ctx.types ().T_size , get_current_ptls (ctx), ctx.tbaa ().tbaa_const );
9032-
9033- // step 11b. Do codegen in control flow order
9040+ // step 11. Do codegen in control flow order
90349041 SmallVector<int , 0 > workstack;
90359042 DenseMap<size_t , BasicBlock*> BB;
90369043 DenseMap<size_t , BasicBlock*> come_from_bb;
0 commit comments