diff --git a/src/codegen.cpp b/src/codegen.cpp index 6e93c012045df..c97e959fb5683 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -7806,6 +7806,13 @@ static jl_llvm_functions_t ctx.builder.SetInsertPoint(tryblk); } else { + if (!jl_is_method(ctx.linfo->def.method) && !ctx.is_opaque_closure) { + // TODO: inference is invalid if this has any effect (which it often does) + LoadInst *world = ctx.builder.CreateAlignedLoad(getSizeTy(ctx.builder.getContext()), + prepare_global_in(jl_Module, jlgetworld_global), Align(sizeof(size_t))); + world->setOrdering(AtomicOrdering::Monotonic); + ctx.builder.CreateAlignedStore(world, world_age_field, Align(sizeof(size_t))); + } emit_stmtpos(ctx, stmt, cursor); mallocVisitStmt(debuginfoloc, nullptr); }