Skip to content

Commit

Permalink
use emit_nthptr_recast to load array sizes
Browse files Browse the repository at this point in the history
doesn't make a big difference, but couldn't hurt
  • Loading branch information
JeffBezanson committed Mar 18, 2015
1 parent f6c68c4 commit ed97120
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,12 +977,20 @@ static Value *emit_nthptr(Value *v, Value *idx, MDNode *tbaa)
return tbaa_decorate(tbaa,builder.CreateLoad(vptr, false));
}

static Value *emit_nthptr_recast(Value *v, size_t n, MDNode *tbaa, Type* ptype) {
static Value *emit_nthptr_recast(Value *v, size_t n, MDNode *tbaa, Type* ptype)
{
// p = (jl_value_t**)v; *(ptype)&p[n]
Value *vptr = emit_nthptr_addr(v, n);
return tbaa_decorate(tbaa,builder.CreateLoad(builder.CreateBitCast(vptr,ptype), false));
}

static Value *emit_nthptr_recast(Value *v, Value *idx, MDNode *tbaa, Type *ptype)
{
// p = (jl_value_t**)v; *(ptype)&p[n]
Value *vptr = emit_nthptr_addr(v, idx);
return tbaa_decorate(tbaa,builder.CreateLoad(builder.CreateBitCast(vptr,ptype), false));
}

static Value *ghostValue(jl_value_t *ty);

static Value *typed_load(Value *ptr, Value *idx_0based, jl_value_t *jltype,
Expand Down Expand Up @@ -1372,10 +1380,9 @@ static Value *emit_arraysize(Value *t, Value *dim)
int o = 3;
#endif
#endif
Value *dbits =
emit_nthptr(t, builder.CreateAdd(dim,
ConstantInt::get(dim->getType(), o)), tbaa_arraysize);
return builder.CreatePtrToInt(dbits, T_size);
return emit_nthptr_recast(t, builder.CreateAdd(dim,
ConstantInt::get(dim->getType(), o)),
tbaa_arraysize, T_psize);
}

static jl_arrayvar_t *arrayvar_for(jl_value_t *ex, jl_codectx_t *ctx)
Expand All @@ -1402,7 +1409,7 @@ static Value *emit_arraylen_prim(Value *t, jl_value_t *ty)
{
#ifdef STORE_ARRAY_LEN
(void)ty;
Value* addr = builder.CreateStructGEP(builder.CreateBitCast(t,jl_parray_llvmt), 2);
Value *addr = builder.CreateStructGEP(builder.CreateBitCast(t,jl_parray_llvmt), 2);
return tbaa_decorate(tbaa_arraylen, builder.CreateLoad(addr, false));
#else
jl_value_t *p1 = jl_tparam1(ty);
Expand Down

0 comments on commit ed97120

Please sign in to comment.