Skip to content

Commit 023fd08

Browse files
committed
make sure precompile statements are printed even for const_return functions
1 parent 32be12d commit 023fd08

File tree

2 files changed

+35
-24
lines changed

2 files changed

+35
-24
lines changed

src/gf.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,36 @@ jl_code_instance_t *jl_method_compiled(jl_method_instance_t *mi, size_t world)
19311931
return NULL;
19321932
}
19331933

1934+
static void record_precompile_statement(jl_method_instance_t *mi)
1935+
{
1936+
static ios_t f_precompile;
1937+
static JL_STREAM* s_precompile = NULL;
1938+
jl_method_t *def = mi->def.method;
1939+
if (jl_options.trace_compile == NULL)
1940+
return;
1941+
if (!jl_is_method(def))
1942+
return;
1943+
1944+
if (s_precompile == NULL) {
1945+
const char *t = jl_options.trace_compile;
1946+
if (!strncmp(t, "stderr", 6)) {
1947+
s_precompile = JL_STDERR;
1948+
}
1949+
else {
1950+
if (ios_file(&f_precompile, t, 1, 1, 1, 1) == NULL)
1951+
jl_errorf("cannot open precompile statement file \"%s\" for writing", t);
1952+
s_precompile = (JL_STREAM*) &f_precompile;
1953+
}
1954+
}
1955+
if (!jl_has_free_typevars(mi->specTypes)) {
1956+
jl_printf(s_precompile, "precompile(");
1957+
jl_static_show(s_precompile, mi->specTypes);
1958+
jl_printf(s_precompile, ")\n");
1959+
if (s_precompile != JL_STDERR)
1960+
ios_flush(&f_precompile);
1961+
}
1962+
}
1963+
19341964
jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t world)
19351965
{
19361966
jl_code_instance_t *codeinst = jl_method_compiled(mi, world);
@@ -1962,6 +1992,7 @@ jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t
19621992
codeinst->rettype_const = unspec->rettype_const;
19631993
codeinst->invoke = unspec->invoke;
19641994
jl_mi_cache_insert(mi, codeinst);
1995+
record_precompile_statement(mi);
19651996
return codeinst;
19661997
}
19671998
}
@@ -1976,6 +2007,7 @@ jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t
19762007
0, 1, ~(size_t)0);
19772008
codeinst->invoke = jl_fptr_interpret_call;
19782009
jl_mi_cache_insert(mi, codeinst);
2010+
record_precompile_statement(mi);
19792011
return codeinst;
19802012
}
19812013
if (compile_option == JL_OPTIONS_COMPILE_OFF) {
@@ -2014,6 +2046,9 @@ jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t
20142046
codeinst->invoke = ucache->invoke;
20152047
jl_mi_cache_insert(mi, codeinst);
20162048
}
2049+
else {
2050+
record_precompile_statement(mi);
2051+
}
20172052
jl_atomic_store_relaxed(&codeinst->precompile, 1);
20182053
return codeinst;
20192054
}

src/jitlayers.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ static jl_callptr_t _jl_compile_codeinst(
8585
jl_code_info_t *src,
8686
size_t world)
8787
{
88-
// TODO: Merge with jl_dump_compiles?
89-
static ios_t f_precompile;
90-
static JL_STREAM* s_precompile = NULL;
91-
9288
// caller must hold codegen_lock
9389
// and have disabled finalizers
9490
uint64_t start_time = 0;
@@ -182,26 +178,6 @@ static jl_callptr_t _jl_compile_codeinst(
182178
// then dump the method-instance specialization type to the stream
183179
jl_method_instance_t *mi = codeinst->def;
184180
if (jl_is_method(mi->def.method)) {
185-
if (jl_options.trace_compile != NULL) {
186-
if (s_precompile == NULL) {
187-
const char* t = jl_options.trace_compile;
188-
if (!strncmp(t, "stderr", 6))
189-
s_precompile = JL_STDERR;
190-
else {
191-
if (ios_file(&f_precompile, t, 1, 1, 1, 1) == NULL)
192-
jl_errorf("cannot open precompile statement file \"%s\" for writing", t);
193-
s_precompile = (JL_STREAM*) &f_precompile;
194-
}
195-
}
196-
if (!jl_has_free_typevars(mi->specTypes)) {
197-
jl_printf(s_precompile, "precompile(");
198-
jl_static_show(s_precompile, mi->specTypes);
199-
jl_printf(s_precompile, ")\n");
200-
201-
if (s_precompile != JL_STDERR)
202-
ios_flush(&f_precompile);
203-
}
204-
}
205181
if (dump_compiles_stream != NULL) {
206182
jl_printf(dump_compiles_stream, "%" PRIu64 "\t\"", end_time - start_time);
207183
jl_static_show(dump_compiles_stream, mi->specTypes);

0 commit comments

Comments
 (0)