Skip to content

Split TBAA for array buffers #21262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ static MDNode *tbaa_binding; // jl_binding_t::value
static MDNode *tbaa_value; // jl_value_t, that is not jl_array_t
static MDNode *tbaa_mutab; // mutable type
static MDNode *tbaa_immut; // immutable type
static MDNode *tbaa_arraybuf; // Data in an array
static MDNode *tbaa_ptrarraybuf; // Data in an array of boxed values
static MDNode *tbaa_arraybuf; // Data in an array of POD
static MDNode *tbaa_array; // jl_array_t
static MDNode *tbaa_arrayptr; // The pointer inside a jl_array_t
static MDNode *tbaa_arraysize; // A size in a jl_array_t
Expand Down Expand Up @@ -2827,7 +2828,8 @@ static bool emit_builtin_call(jl_cgval_t *ret, jl_value_t *f, jl_value_t **args,
*ret = ghostValue(ety);
}
else {
*ret = typed_load(emit_arrayptr(ary, args[1], ctx), idx, ety, ctx, tbaa_arraybuf);
*ret = typed_load(emit_arrayptr(ary, args[1], ctx), idx, ety, ctx,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems that you can have a bool isboxed a few lines above for this one too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did not get addressed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small cleanup, will get it in separately.

jl_array_store_unboxed(ety) ? tbaa_arraybuf : tbaa_ptrarraybuf);
}
JL_GC_POP();
return true;
Expand All @@ -2850,14 +2852,14 @@ static bool emit_builtin_call(jl_cgval_t *ret, jl_value_t *f, jl_value_t **args,
if (jl_is_array_type(aty_dt) && indexes_ok) {
jl_value_t *ety = jl_tparam0(aty_dt);
if (!jl_has_free_typevars(ety) && jl_subtype(vty, ety)) { // TODO: jn/foreigncall branch has a better predicate
if (!jl_array_store_unboxed(ety))
bool isboxed = !jl_array_store_unboxed(ety);
if (isboxed)
ety = (jl_value_t*)jl_any_type;
jl_value_t *ndp = jl_tparam1(aty_dt);
if (jl_is_long(ndp) || nargs==3) {
jl_cgval_t ary = emit_expr(args[1], ctx);
ssize_t nd = jl_is_long(ndp) ? jl_unbox_long(ndp) : -1;
Value *idx = emit_array_nd_index(ary, args[1], nd, &args[3], nargs-2, ctx);
bool isboxed = !jl_array_store_unboxed(ety);
if (!isboxed && jl_datatype_size(ety) == 0) {
// no-op, but emit expr for possible effects
assert(jl_is_datatype(ety));
Expand Down Expand Up @@ -2906,7 +2908,7 @@ static bool emit_builtin_call(jl_cgval_t *ret, jl_value_t *f, jl_value_t **args,
data_owner->addIncoming(own_ptr, ownedBB);
}
typed_store(emit_arrayptr(ary,args[1],ctx), idx, v,
ety, ctx, tbaa_arraybuf, data_owner, 0,
ety, ctx, !isboxed ? tbaa_arraybuf : tbaa_ptrarraybuf, data_owner, 0,
false); // don't need to root the box if we had to make one since it's being stored in the array immediatly
}
*ret = ary;
Expand Down Expand Up @@ -6309,6 +6311,7 @@ static void init_julia_llvm_meta(void)
tbaa_mutab = tbaa_make_child("jtbaa_mutab", tbaa_value_scalar).first;
tbaa_immut = tbaa_make_child("jtbaa_immut", tbaa_value_scalar).first;
tbaa_arraybuf = tbaa_make_child("jtbaa_arraybuf", tbaa_data_scalar).first;
tbaa_ptrarraybuf = tbaa_make_child("jtbaa_ptrarraybuf", tbaa_data_scalar).first;
MDNode *tbaa_array_scalar;
std::tie(tbaa_array, tbaa_array_scalar) = tbaa_make_child("jtbaa_array");
tbaa_arrayptr = tbaa_make_child("jtbaa_arrayptr", tbaa_array_scalar).first;
Expand Down