Skip to content

Commit

Permalink
Merge pull request #15312 from JuliaLang/ob/ptrgetf
Browse files Browse the repository at this point in the history
Couple ispointer fixes
  • Loading branch information
carnaval committed Mar 2, 2016
2 parents fd6eade + c679bfb commit cea29d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,15 @@ static bool emit_getfield_unknownidx(jl_cgval_t *ret, const jl_cgval_t &strct, V
jl_value_t *jt = jl_field_type(stt, 0);
idx = emit_bounds_check(strct, (jl_value_t*)stt, idx, ConstantInt::get(T_size, nfields), ctx);
Value *ptr = data_pointer(strct, ctx);
if (!stt->mutabl) {
// just compute the pointer and let user load it when necessary
Type *fty = julia_type_to_llvm(jt);
Value *addr = builder.CreateGEP(builder.CreatePointerCast(ptr, PointerType::get(fty,0)), idx);
jl_cgval_t fieldval = mark_julia_slot(addr, jt);
fieldval.gcroot = strct.gcroot;
*ret = fieldval;
return true;
}
*ret = typed_load(ptr, idx, jt, ctx, stt->mutabl ? tbaa_user : tbaa_immut);
return true;
}
Expand Down Expand Up @@ -1653,7 +1662,9 @@ static jl_cgval_t emit_getfield_knownidx(const jl_cgval_t &strct, unsigned idx,
LLVM37_param(julia_type_to_llvm(strct.typ))
strct.V, 0, idx);
assert(!jt->mutabl);
return typed_load(addr, NULL, jfty, ctx, tbaa_immut);
jl_cgval_t fieldval = mark_julia_slot(addr, jfty);
fieldval.gcroot = strct.gcroot;
return fieldval;
}
else {
assert(strct.V->getType()->isVectorTy());
Expand Down
4 changes: 3 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4713,8 +4713,10 @@ static void emit_function(jl_lambda_info_t *lam, jl_llvm_functions_t *declaratio
else if (specsig) {
if (type_is_ghost(llvmArgType)) // this argument is not actually passed
theArg = ghostValue(argType);
else if (llvmArgType->isAggregateType())
else if (llvmArgType->isAggregateType()) {
theArg = mark_julia_slot(&*AI++, argType); // this argument is by-pointer
theArg.isimmutable = true;
}
else
theArg = mark_julia_type(&*AI++, isboxed, argType, &ctx, /*needsgcroot*/false);
}
Expand Down

0 comments on commit cea29d4

Please sign in to comment.