Skip to content

Commit

Permalink
Fix aotcompile.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
qinsoon committed May 17, 2024
1 parent df4eb8e commit 445f790
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/aotcompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,13 @@ static void jl_ci_cache_lookup(const jl_cgparams_t &cgparams, jl_method_instance
jl_method_t *def = codeinst->def->def.method;
if ((jl_value_t*)*src_out == jl_nothing)
*src_out = NULL;
if (*src_out && jl_is_method(def))
if (*src_out && jl_is_method(def)) {
PTR_PIN(def);
PTR_PIN(codeinst);
*src_out = jl_uncompress_ir(def, codeinst, (jl_array_t*)*src_out);
PTR_UNPIN(codeinst);
PTR_UNPIN(def);
}
}
if (*src_out == NULL || !jl_is_code_info(*src_out)) {
if (cgparams.lookup != jl_rettype_inferred) {
Expand Down Expand Up @@ -341,7 +346,9 @@ void *jl_create_native_impl(jl_array_t *methods, LLVMOrcThreadSafeModuleRef llvm
params.tsctx, params.imaging,
clone.getModuleUnlocked()->getDataLayout(),
Triple(clone.getModuleUnlocked()->getTargetTriple()));
PTR_PIN(codeinst->rettype);
jl_llvm_functions_t decls = jl_emit_code(result_m, mi, src, codeinst->rettype, params);
PTR_UNPIN(codeinst->rettype);
if (result_m)
emitted[codeinst] = {std::move(result_m), std::move(decls)};
}
Expand Down
6 changes: 6 additions & 0 deletions test/clangsa/MissingPinning.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "julia_internal.h"

extern void look_at_value(jl_value_t *v);
extern void process_unrooted(jl_value_t *maybe_unrooted JL_MAYBE_UNROOTED JL_MAYBE_UNPINNED);

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

int allow_unpinned() {
jl_svec_t *val = jl_svec1(NULL);
process_unrooted((jl_value_t*)val);
}

void pinned_argument() {
jl_svec_t *val = jl_svec1(NULL);
JL_GC_PROMISE_ROOTED(val);
Expand Down

0 comments on commit 445f790

Please sign in to comment.