Skip to content

Commit

Permalink
Only ever attach zext/sext to integer types.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Oct 4, 2023
1 parent e19b9f9 commit b01110b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/jl_exported_data.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
2 changes: 1 addition & 1 deletion src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/staticdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit b01110b

Please sign in to comment.