From b01110b0158a10d7f164b0b54786074676a715f6 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Tue, 3 Oct 2023 10:48:59 +0200 Subject: [PATCH] Only ever attach zext/sext to integer types. --- src/ccall.cpp | 3 ++- src/codegen.cpp | 3 ++- src/jl_exported_data.inc | 1 + src/jltypes.c | 2 +- src/julia.h | 1 + src/staticdata.c | 3 ++- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ccall.cpp b/src/ccall.cpp index cb069b58c37613..24022ac19c3b5b 100644 --- a/src/ccall.cpp +++ b/src/ccall.cpp @@ -1123,7 +1123,8 @@ std::string generate_func_sig(const char *fname) isboxed = false; } else { - if (jl_is_primitivetype(tti)) { + if (jl_is_primitivetype(tti) && + jl_integer_type && jl_subtype(tti, (jl_value_t*)jl_integer_type)) { // see pull req #978. need to annotate signext/zeroext for // small integer arguments. jl_datatype_t *bt = (jl_datatype_t*)tti; diff --git a/src/codegen.cpp b/src/codegen.cpp index 20f2dfe28165f5..6187bf85c9da0c 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -7149,7 +7149,8 @@ static jl_returninfo_t get_specsig_function(jl_codectx_t &ctx, Module *M, Value else if (isboxed && jl_is_immutable_datatype(jt)) { param.addAttribute(Attribute::ReadOnly); } - else if (jl_is_primitivetype(jt) && ty->isIntegerTy()) { + else if (jl_is_primitivetype(jt) && jl_integer_type && + jl_subtype(jt, (jl_value_t*)jl_integer_type)) { bool issigned = jl_signed_type && jl_subtype(jt, (jl_value_t*)jl_signed_type); Attribute::AttrKind attr = issigned ? Attribute::SExt : Attribute::ZExt; param.addAttribute(attr); diff --git a/src/jl_exported_data.inc b/src/jl_exported_data.inc index aa23b9d7b82054..3bb991ae82ecce 100644 --- a/src/jl_exported_data.inc +++ b/src/jl_exported_data.inc @@ -50,6 +50,7 @@ XX(jl_gotoifnot_type) \ XX(jl_gotonode_type) \ XX(jl_initerror_type) \ + XX(jl_integer_type) \ XX(jl_int16_type) \ XX(jl_int32_type) \ XX(jl_int64_type) \ diff --git a/src/jltypes.c b/src/jltypes.c index 33b52158488a3e..8c005f5966d1de 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -3409,7 +3409,7 @@ void post_boot_hooks(void) jl_number_type = (jl_datatype_t*)core("Number"); jl_signed_type = (jl_datatype_t*)core("Signed"); jl_datatype_t *jl_unsigned_type = (jl_datatype_t*)core("Unsigned"); - jl_datatype_t *jl_integer_type = (jl_datatype_t*)core("Integer"); + jl_integer_type = (jl_datatype_t*)core("Integer"); jl_bool_type->super = jl_integer_type; jl_uint8_type->super = jl_unsigned_type; diff --git a/src/julia.h b/src/julia.h index a357bdf5583601..842bc16068b76e 100644 --- a/src/julia.h +++ b/src/julia.h @@ -853,6 +853,7 @@ extern JL_DLLIMPORT jl_datatype_t *jl_floatingpoint_type JL_GLOBALLY_ROOTED; extern JL_DLLIMPORT jl_datatype_t *jl_number_type JL_GLOBALLY_ROOTED; extern JL_DLLIMPORT jl_datatype_t *jl_void_type JL_GLOBALLY_ROOTED; // deprecated extern JL_DLLIMPORT jl_datatype_t *jl_nothing_type JL_GLOBALLY_ROOTED; +extern JL_DLLIMPORT jl_datatype_t *jl_integer_type JL_GLOBALLY_ROOTED; extern JL_DLLIMPORT jl_datatype_t *jl_signed_type JL_GLOBALLY_ROOTED; extern JL_DLLIMPORT jl_datatype_t *jl_voidpointer_type JL_GLOBALLY_ROOTED; extern JL_DLLIMPORT jl_datatype_t *jl_uint8pointer_type JL_GLOBALLY_ROOTED; diff --git a/src/staticdata.c b/src/staticdata.c index df5652a5719c43..4d1be4bd295e33 100644 --- a/src/staticdata.c +++ b/src/staticdata.c @@ -99,7 +99,7 @@ extern "C" { // TODO: put WeakRefs on the weak_refs list during deserialization // TODO: handle finalizers -#define NUM_TAGS 160 +#define NUM_TAGS 161 // An array of references that need to be restored from the sysimg // This is a manually constructed dual of the gvars array, which would be produced by codegen for Julia code, for C. @@ -197,6 +197,7 @@ jl_value_t **const*const get_tags(void) { INSERT_TAG(jl_bfloat16_type); INSERT_TAG(jl_floatingpoint_type); INSERT_TAG(jl_number_type); + INSERT_TAG(jl_integer_type); INSERT_TAG(jl_signed_type); INSERT_TAG(jl_pair_type);