Skip to content

Commit f579da0

Browse files
committed
Fix aotcompile.cpp
1 parent 4f4b97c commit f579da0

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/aotcompile.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,13 @@ static void jl_ci_cache_lookup(const jl_cgparams_t &cgparams, jl_method_instance
240240
jl_method_t *def = codeinst->def->def.method;
241241
if ((jl_value_t*)*src_out == jl_nothing)
242242
*src_out = NULL;
243-
if (*src_out && jl_is_method(def))
243+
if (*src_out && jl_is_method(def)) {
244+
PTR_PIN(def);
245+
PTR_PIN(codeinst);
244246
*src_out = jl_uncompress_ir(def, codeinst, (jl_array_t*)*src_out);
247+
PTR_UNPIN(codeinst);
248+
PTR_UNPIN(def);
249+
}
245250
}
246251
if (*src_out == NULL || !jl_is_code_info(*src_out)) {
247252
if (cgparams.lookup != jl_rettype_inferred) {
@@ -341,7 +346,9 @@ void *jl_create_native_impl(jl_array_t *methods, LLVMOrcThreadSafeModuleRef llvm
341346
params.tsctx, params.imaging,
342347
clone.getModuleUnlocked()->getDataLayout(),
343348
Triple(clone.getModuleUnlocked()->getTargetTriple()));
349+
PTR_PIN(codeinst->rettype);
344350
jl_llvm_functions_t decls = jl_emit_code(result_m, mi, src, codeinst->rettype, params);
351+
PTR_UNPIN(codeinst->rettype);
345352
if (result_m)
346353
emitted[codeinst] = {std::move(result_m), std::move(decls)};
347354
}

test/clangsa/MissingPinning.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "julia_internal.h"
77

88
extern void look_at_value(jl_value_t *v);
9+
extern void process_unrooted(jl_value_t *maybe_unrooted JL_MAYBE_UNROOTED JL_MAYBE_UNPINNED);
910

1011
void unpinned_argument() {
1112
jl_svec_t *val = jl_svec1(NULL); // expected-note{{Started tracking value here}}
@@ -14,6 +15,11 @@ void unpinned_argument() {
1415
// expected-note@-1{{Passing non-pinned value as argument to function that may GC}}
1516
}
1617

18+
int allow_unpinned() {
19+
jl_svec_t *val = jl_svec1(NULL);
20+
process_unrooted((jl_value_t*)val);
21+
}
22+
1723
void pinned_argument() {
1824
jl_svec_t *val = jl_svec1(NULL);
1925
JL_GC_PROMISE_ROOTED(val);

0 commit comments

Comments
 (0)