Skip to content

Commit

Permalink
improve codegen of uncertain ccall return types. part of JuliaLang#5752
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Feb 12, 2014
1 parent 4b37277 commit 82f1d63
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,16 @@ static Value *boxed(Value *v, jl_codectx_t *ctx, jl_value_t *jt)
if (jb == jl_uint32_type) return builder.CreateCall(prepare_call(box_uint32_func), v);
if (jb == jl_uint64_type) return builder.CreateCall(prepare_call(box_uint64_func), v);
if (jb == jl_char_type) return builder.CreateCall(prepare_call(box_char_func), v);
if (!jl_isbits(jt)) {

if (!jl_is_leaf_type(jt)) {
// we can get a sharper type from julia_type_of than expr_type in some
// cases, due to ccall's compile-time evaluations of types. see issue #5752
jl_value_t *jt2 = julia_type_of(v);
if (jl_subtype(jt2, jt, 0))
jt = jt2;
}

if (!jl_isbits(jt) || !jl_is_leaf_type(jt)) {
assert("Don't know how to box this type" && false);
return NULL;
}
Expand Down
4 changes: 3 additions & 1 deletion src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1848,8 +1848,10 @@ static jl_value_t *inst_type_w_(jl_value_t *t, jl_value_t **env, size_t n,
}
if (tn == jl_array_typename)
ndt->pointerfree = 0;
if (jl_tuple_len(ftypes) == 0)
if (jl_tuple_len(ftypes) == 0) {
ndt->alignment = ndt->size = dt->size;
ndt->pointerfree = dt->pointerfree;
}
}
if (cacheable) cache_type_((jl_value_t*)ndt);
result = (jl_value_t*)ndt;
Expand Down

0 comments on commit 82f1d63

Please sign in to comment.