diff --git a/src/codegen-stubs.c b/src/codegen-stubs.c index dda9bbee184a0..e67ae3b75ea76 100644 --- a/src/codegen-stubs.c +++ b/src/codegen-stubs.c @@ -43,10 +43,11 @@ JL_DLLEXPORT void jl_generate_fptr_for_unspecialized_fallback(jl_code_instance_t jl_atomic_store_release(&unspec->invoke, &jl_fptr_interpret_call); } -JL_DLLEXPORT void jl_compile_codeinst_fallback(jl_code_instance_t *unspec) +JL_DLLEXPORT int jl_compile_codeinst_fallback(jl_code_instance_t *unspec) { // Do nothing. The caller will notice that we failed to provide a an ->invoke and trigger // appropriate fallbacks. + return 0; } JL_DLLEXPORT uint32_t jl_get_LLVM_VERSION_fallback(void) diff --git a/src/gf.c b/src/gf.c index 53496c8feca58..2bab2b2271e0b 100644 --- a/src/gf.c +++ b/src/gf.c @@ -2568,12 +2568,12 @@ jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t } JL_GC_PUSH1(&codeinst); - jl_compile_codeinst(codeinst); + int did_compile = jl_compile_codeinst(codeinst); if (jl_atomic_load_relaxed(&codeinst->invoke) == NULL) { // Something went wrong. Bail to the fallback path. codeinst = NULL; - } else { + } else if (did_compile) { record_precompile_statement(mi); } JL_GC_POP(); diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp index b7fb975515eb4..5f9d7f8a3c6cf 100644 --- a/src/jitlayers.cpp +++ b/src/jitlayers.cpp @@ -461,10 +461,11 @@ void jl_extern_c_impl(jl_value_t *declrt, jl_tupletype_t *sigt) } extern "C" JL_DLLEXPORT_CODEGEN -void jl_compile_codeinst_impl(jl_code_instance_t *ci) +int jl_compile_codeinst_impl(jl_code_instance_t *ci) { + int newly_compiled = 0; if (jl_atomic_load_relaxed(&ci->invoke) != NULL) { - return; + return newly_compiled; } JL_LOCK(&jl_codegen_lock); if (jl_atomic_load_relaxed(&ci->invoke) == NULL) { @@ -472,8 +473,10 @@ void jl_compile_codeinst_impl(jl_code_instance_t *ci) uint64_t start = jl_typeinf_timing_begin(); _jl_compile_codeinst(ci, NULL, *jl_ExecutionEngine->getContext()); jl_typeinf_timing_end(start, 0); + newly_compiled = 1; } JL_UNLOCK(&jl_codegen_lock); // Might GC + return newly_compiled; } extern "C" JL_DLLEXPORT_CODEGEN diff --git a/src/julia_internal.h b/src/julia_internal.h index 79f9e1fba0703..dc93e522b0c4d 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -1727,7 +1727,7 @@ JL_DLLEXPORT uint32_t jl_crc32c(uint32_t crc, const char *buf, size_t len); #define IR_FLAG_INBOUNDS 0x01 JL_DLLIMPORT void jl_generate_fptr_for_unspecialized(jl_code_instance_t *unspec); -JL_DLLIMPORT void jl_compile_codeinst(jl_code_instance_t *unspec); +JL_DLLIMPORT int jl_compile_codeinst(jl_code_instance_t *unspec); JL_DLLIMPORT int jl_compile_extern_c(LLVMOrcThreadSafeModuleRef llvmmod, void *params, void *sysimg, jl_value_t *declrt, jl_value_t *sigt); typedef struct {