@@ -238,7 +238,7 @@ static void jl_ci_cache_lookup(const jl_cgparams_t &cgparams, jl_method_instance
238238 if ((jl_value_t *)*src_out == jl_nothing)
239239 *src_out = NULL ;
240240 if (*src_out && jl_is_method (def))
241- *src_out = jl_uncompress_ir (def, codeinst, (jl_array_t *)*src_out);
241+ *src_out = jl_uncompress_ir (def, codeinst, (jl_value_t *)*src_out);
242242 }
243243 if (*src_out == NULL || !jl_is_code_info (*src_out)) {
244244 if (cgparams.lookup != jl_rettype_inferred) {
@@ -1575,6 +1575,14 @@ void jl_dump_native_impl(void *native_code,
15751575 GlobalVariable::ExternalLinkage,
15761576 jlRTLD_DEFAULT_var,
15771577 " jl_RTLD_DEFAULT_handle_pointer" ), TheTriple);
1578+
1579+ // let the compiler know we are going to internalize a copy of this,
1580+ // if it has a current usage with ExternalLinkage
1581+ auto small_typeof_copy = dataM->getGlobalVariable (" small_typeof" );
1582+ if (small_typeof_copy) {
1583+ small_typeof_copy->setVisibility (GlobalValue::HiddenVisibility);
1584+ small_typeof_copy->setDSOLocal (true );
1585+ }
15781586 }
15791587
15801588 // Reserve space for the output files and names
@@ -1651,13 +1659,21 @@ void jl_dump_native_impl(void *native_code,
16511659 auto shards = emit_shard_table (*sysimageM, T_size, T_psize, threads);
16521660 auto ptls = emit_ptls_table (*sysimageM, T_size, T_psize);
16531661 auto header = emit_image_header (*sysimageM, threads, nfvars, ngvars);
1654- auto AT = ArrayType::get (T_psize, 4 );
1662+ auto AT = ArrayType::get (T_size, sizeof (small_typeof) / sizeof (void *));
1663+ auto small_typeof_copy = new GlobalVariable (*sysimageM, AT, false ,
1664+ GlobalVariable::ExternalLinkage,
1665+ Constant::getNullValue (AT),
1666+ " small_typeof" );
1667+ small_typeof_copy->setVisibility (GlobalValue::HiddenVisibility);
1668+ small_typeof_copy->setDSOLocal (true );
1669+ AT = ArrayType::get (T_psize, 5 );
16551670 auto pointers = new GlobalVariable (*sysimageM, AT, false ,
16561671 GlobalVariable::ExternalLinkage,
16571672 ConstantArray::get (AT, {
16581673 ConstantExpr::getBitCast (header, T_psize),
16591674 ConstantExpr::getBitCast (shards, T_psize),
16601675 ConstantExpr::getBitCast (ptls, T_psize),
1676+ ConstantExpr::getBitCast (small_typeof_copy, T_psize),
16611677 ConstantExpr::getBitCast (target_ids, T_psize)
16621678 }),
16631679 " jl_image_pointers" );
@@ -2012,17 +2028,18 @@ void jl_get_llvmf_defn_impl(jl_llvmf_dump_t* dump, jl_method_instance_t *mi, siz
20122028 jl_value_t *jlrettype = (jl_value_t *)jl_any_type;
20132029 jl_code_info_t *src = NULL ;
20142030 JL_GC_PUSH2 (&src, &jlrettype);
2015- if (jl_is_method (mi->def .method ) && mi->def .method ->source != NULL && jl_ir_flag_inferred (( jl_array_t *) mi->def .method ->source )) {
2031+ if (jl_is_method (mi->def .method ) && mi->def .method ->source != NULL && mi-> def . method -> source != jl_nothing && jl_ir_flag_inferred (mi->def .method ->source )) {
20162032 src = (jl_code_info_t *)mi->def .method ->source ;
20172033 if (src && !jl_is_code_info (src))
2018- src = jl_uncompress_ir (mi->def .method , NULL , (jl_array_t *)src);
2019- } else {
2034+ src = jl_uncompress_ir (mi->def .method , NULL , (jl_value_t *)src);
2035+ }
2036+ else {
20202037 jl_value_t *ci = jl_rettype_inferred (mi, world, world);
20212038 if (ci != jl_nothing) {
20222039 jl_code_instance_t *codeinst = (jl_code_instance_t *)ci;
20232040 src = (jl_code_info_t *)jl_atomic_load_relaxed (&codeinst->inferred );
20242041 if ((jl_value_t *)src != jl_nothing && !jl_is_code_info (src) && jl_is_method (mi->def .method ))
2025- src = jl_uncompress_ir (mi->def .method , codeinst, (jl_array_t *)src);
2042+ src = jl_uncompress_ir (mi->def .method , codeinst, (jl_value_t *)src);
20262043 jlrettype = codeinst->rettype ;
20272044 }
20282045 if (!src || (jl_value_t *)src == jl_nothing) {
@@ -2031,8 +2048,8 @@ void jl_get_llvmf_defn_impl(jl_llvmf_dump_t* dump, jl_method_instance_t *mi, siz
20312048 jlrettype = src->rettype ;
20322049 else if (jl_is_method (mi->def .method )) {
20332050 src = mi->def .method ->generator ? jl_code_for_staged (mi, world) : (jl_code_info_t *)mi->def .method ->source ;
2034- if (src && !jl_is_code_info (src) && jl_is_method (mi->def .method ))
2035- src = jl_uncompress_ir (mi->def .method , NULL , (jl_array_t *)src);
2051+ if (src && ( jl_value_t *)src != jl_nothing && !jl_is_code_info (src) && jl_is_method (mi->def .method ))
2052+ src = jl_uncompress_ir (mi->def .method , NULL , (jl_value_t *)src);
20362053 }
20372054 // TODO: use mi->uninferred
20382055 }
0 commit comments