Skip to content

Commit

Permalink
Fix a few problems in tuple codegen code. Fix #5069
Browse files Browse the repository at this point in the history
Refs #5108
  • Loading branch information
Keno committed Dec 12, 2013
1 parent 163fb01 commit c5364db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ static Value *literal_pointer_val(void *p)

static Type *julia_struct_to_llvm(jl_value_t *jt);

static bool jltupleisbits(jl_value_t *jt, bool allow_unsized = true);

static Type *julia_type_to_llvm(jl_value_t *jt)
{
if (jt == (jl_value_t*)jl_bool_type) return T_int1;
Expand All @@ -76,7 +78,7 @@ static Type *julia_type_to_llvm(jl_value_t *jt)
Type *type = NULL;
for (size_t i = 0; i < ntypes; ++i) {
jl_value_t *elt = jl_tupleref(jt,i);
purebits &= jl_isbits(elt);
purebits &= jltupleisbits(elt);
Type *newtype = julia_struct_to_llvm(elt);
if (type != NULL && type != newtype)
isvector = false;
Expand All @@ -91,7 +93,7 @@ static Type *julia_type_to_llvm(jl_value_t *jt)
Type *ret = NULL;
if (type == T_void)
return T_void;
if (type->isSingleValueType())
if (type->isSingleValueType() && !type->isVectorTy())
ret = VectorType::get(type,ntypes);
else
ret = ArrayType::get(type,ntypes);
Expand Down
5 changes: 3 additions & 2 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ static bool is_getfield_nonallocating(jl_datatype_t *ty, jl_value_t *fld)
return true;
}

static bool jltupleisbits(jl_value_t *jt, bool allow_unsized = true)
static bool jltupleisbits(jl_value_t *jt, bool allow_unsized)
{
if (!jl_is_tuple(jt))
return jl_isbits(jt) && (allow_unsized ||
Expand Down Expand Up @@ -2470,7 +2470,8 @@ static Value *alloc_local(jl_sym_t *s, jl_codectx_t *ctx)
jl_value_t *jt = vi.declType;
Value *lv = NULL;
assert(store_unboxed_p(s,ctx));
Type *vtype = julia_type_to_llvm(jt);
Type *vtype = julia_struct_to_llvm(jt);
assert(vtype != jl_pvalue_llvmt);
if (vtype != T_void) {
lv = builder.CreateAlloca(vtype, 0, s->name);
if (vtype != jl_pvalue_llvmt)
Expand Down
2 changes: 1 addition & 1 deletion src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static Value *emit_unbox(Type *to, Value *x, jl_value_t *jt)
if (ety == T_void)
continue;
Value *ref = emit_tupleref(x,ConstantInt::get(T_size,i+1),jt,NULL);
Value *elt = emit_unbox(ety,ref,julia_type_of(ref));
Value *elt = emit_unbox(ety,ref,jl_tupleref(jt,i));
tpl = emit_tupleset(tpl,ConstantInt::get(T_size,i+1),elt,jt,NULL);
}
return tpl;
Expand Down

0 comments on commit c5364db

Please sign in to comment.