@@ -238,7 +238,7 @@ static void jl_ci_cache_lookup(const jl_cgparams_t &cgparams, jl_method_instance
238
238
if ((jl_value_t *)*src_out == jl_nothing)
239
239
*src_out = NULL ;
240
240
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);
242
242
}
243
243
if (*src_out == NULL || !jl_is_code_info (*src_out)) {
244
244
if (cgparams.lookup != jl_rettype_inferred) {
@@ -1575,6 +1575,14 @@ void jl_dump_native_impl(void *native_code,
1575
1575
GlobalVariable::ExternalLinkage,
1576
1576
jlRTLD_DEFAULT_var,
1577
1577
" 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
+ }
1578
1586
}
1579
1587
1580
1588
// Reserve space for the output files and names
@@ -1651,13 +1659,21 @@ void jl_dump_native_impl(void *native_code,
1651
1659
auto shards = emit_shard_table (*sysimageM, T_size, T_psize, threads);
1652
1660
auto ptls = emit_ptls_table (*sysimageM, T_size, T_psize);
1653
1661
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 );
1655
1670
auto pointers = new GlobalVariable (*sysimageM, AT, false ,
1656
1671
GlobalVariable::ExternalLinkage,
1657
1672
ConstantArray::get (AT, {
1658
1673
ConstantExpr::getBitCast (header, T_psize),
1659
1674
ConstantExpr::getBitCast (shards, T_psize),
1660
1675
ConstantExpr::getBitCast (ptls, T_psize),
1676
+ ConstantExpr::getBitCast (small_typeof_copy, T_psize),
1661
1677
ConstantExpr::getBitCast (target_ids, T_psize)
1662
1678
}),
1663
1679
" jl_image_pointers" );
@@ -2012,17 +2028,18 @@ void jl_get_llvmf_defn_impl(jl_llvmf_dump_t* dump, jl_method_instance_t *mi, siz
2012
2028
jl_value_t *jlrettype = (jl_value_t *)jl_any_type;
2013
2029
jl_code_info_t *src = NULL ;
2014
2030
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 )) {
2016
2032
src = (jl_code_info_t *)mi->def .method ->source ;
2017
2033
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 {
2020
2037
jl_value_t *ci = jl_rettype_inferred (mi, world, world);
2021
2038
if (ci != jl_nothing) {
2022
2039
jl_code_instance_t *codeinst = (jl_code_instance_t *)ci;
2023
2040
src = (jl_code_info_t *)jl_atomic_load_relaxed (&codeinst->inferred );
2024
2041
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);
2026
2043
jlrettype = codeinst->rettype ;
2027
2044
}
2028
2045
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
2031
2048
jlrettype = src->rettype ;
2032
2049
else if (jl_is_method (mi->def .method )) {
2033
2050
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);
2036
2053
}
2037
2054
// TODO: use mi->uninferred
2038
2055
}
0 commit comments