diff --git a/src/ast.c b/src/ast.c index 70ee915475651..028ea4d097172 100644 --- a/src/ast.c +++ b/src/ast.c @@ -722,6 +722,7 @@ static value_t julia_to_list2_noalloc(fl_context_t *fl_ctx, jl_value_t *a, jl_va static value_t julia_to_scm_(fl_context_t *fl_ctx, jl_value_t *v, int check_valid) { + PTR_PIN(v); value_t retval; if (julia_to_scm_noalloc1(fl_ctx, v, &retval)) return retval; diff --git a/src/cgutils.cpp b/src/cgutils.cpp index 8ce84acb30901..a302d3e9c1cf5 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -472,7 +472,9 @@ static Value *literal_pointer_val(jl_codectx_t &ctx, jl_value_t *p) if (p == NULL) return Constant::getNullValue(ctx.types().T_pjlvalue); if (!ctx.emission_context.imaging) + // literal_static_pointer_val will pin p. return literal_static_pointer_val(p, ctx.types().T_pjlvalue); + PTR_PIN(p); Value *pgv = literal_pointer_val_slot(ctx, p); jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_const); return ai.decorateInst(maybe_mark_load_dereferenceable( @@ -487,7 +489,9 @@ static Value *literal_pointer_val(jl_codectx_t &ctx, jl_binding_t *p) if (p == NULL) return Constant::getNullValue(ctx.types().T_pjlvalue); if (!ctx.emission_context.imaging) + // literal_static_pointer_val will pin p. return literal_static_pointer_val(p, ctx.types().T_pjlvalue); + PTR_PIN(p); // bindings are prefixed with jl_bnd# Value *pgv = julia_pgv(ctx, "jl_bnd#", p->name, p->owner, p); jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_const); diff --git a/src/jitlayers.h b/src/jitlayers.h index 312d366f659b7..c1061e727db79 100644 --- a/src/jitlayers.h +++ b/src/jitlayers.h @@ -242,6 +242,7 @@ void add_named_global(StringRef name, void *addr); static inline Constant *literal_static_pointer_val(const void *p, Type *T) { + PTR_PIN((void*)p); // this function will emit a static pointer into the generated code // the generated code will only be valid during the current session, // and thus, this should typically be avoided in new API's