Skip to content

Commit 1aa8c68

Browse files
authored
Merge pull request #31687 from JuliaLang/tb/uncached_codeinst
Fix regressed compilation of uncached code.
2 parents 20834c3 + d02b01e commit 1aa8c68

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/codegen.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,16 +1177,12 @@ jl_code_instance_t *jl_compile_linfo(jl_method_instance_t *mi, jl_code_info_t *s
11771177
jl_ptls_t ptls = jl_get_ptls_states();
11781178
jl_code_instance_t *uncached = (jl_code_instance_t*)jl_gc_alloc(ptls, sizeof(jl_code_instance_t),
11791179
jl_code_instance_type);
1180-
uncached->min_world = codeinst->min_world;
1181-
uncached->max_world = codeinst->max_world;
1180+
*uncached = *codeinst;
11821181
uncached->functionObjectsDecls.functionObject = NULL;
11831182
uncached->functionObjectsDecls.specFunctionObject = NULL;
1184-
uncached->rettype = codeinst->rettype;
11851183
uncached->inferred = jl_nothing;
1186-
uncached->rettype_const = codeinst->rettype_const;
1187-
uncached->invoke = NULL;
1188-
if (codeinst->invoke == jl_fptr_const_return)
1189-
uncached->invoke = jl_fptr_const_return;
1184+
if (uncached->invoke != jl_fptr_const_return)
1185+
uncached->invoke = NULL;
11901186
uncached->specptr.fptr = NULL;
11911187
codeinst = uncached;
11921188
}
@@ -3204,6 +3200,7 @@ static jl_cgval_t emit_invoke(jl_codectx_t &ctx, jl_expr_t *ex, jl_value_t *rt)
32043200
assert(jl_is_method_instance(mi));
32053201
jl_code_instance_t *codeinst = jl_compile_linfo(mi, NULL, ctx.world, ctx.params);
32063202
if (codeinst && codeinst->inferred) {
3203+
JL_GC_PUSH1(&codeinst);
32073204
const jl_llvm_functions_t &decls = codeinst->functionObjectsDecls;
32083205
if (codeinst->invoke == jl_fptr_const_return) {
32093206
assert(codeinst->rettype_const);
@@ -3219,6 +3216,7 @@ static jl_cgval_t emit_invoke(jl_codectx_t &ctx, jl_expr_t *ex, jl_value_t *rt)
32193216
handled = true;
32203217
}
32213218
}
3219+
JL_GC_POP();
32223220
}
32233221
}
32243222
if (!handled) {

test/reflection.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,3 +870,15 @@ function _test_at_locals2(a::Any, ::Any)
870870
@test @locals() == Dict{Symbol,Any}(:x=>2,:a=>a)
871871
end
872872
_test_at_locals2(1,1)
873+
874+
@testset "issue #31687" begin
875+
import InteractiveUtils._dump_function
876+
877+
@noinline f31687_child(i) = f31687_nonexistent(i)
878+
f31687_parent() = f31687_child(0)
879+
params = Base.CodegenParams(cached=false)
880+
_dump_function(f31687_parent, Tuple{},
881+
#=native=#false, #=wrapper=#false, #=strip=#false,
882+
#=dump_module=#true, #=syntax=#:att, #=optimize=#false, :none,
883+
params)
884+
end

0 commit comments

Comments
 (0)