Skip to content

Commit

Permalink
Merge pull request #21308 from JuliaLang/kf/moreprecisetbaa
Browse files Browse the repository at this point in the history
Make TBAA for non leaftypes more precise
  • Loading branch information
Keno authored Apr 17, 2017
2 parents 2e89bc1 + afeecd0 commit 37d84dd
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,17 @@ static bool isbits_spec(jl_value_t *jt, bool allow_singleton = true)
(allow_singleton || (jl_datatype_size(jt) > 0) || (jl_datatype_nfields(jt) > 0));
}

static MDNode *best_tbaa(jl_value_t *jt) {
jt = jl_unwrap_unionall(jt);
if (!jl_is_datatype(jt))
return tbaa_value;
if (jl_is_abstracttype(jt))
return tbaa_value;
// If we're here, we know all subtypes are (im)mutable, even if we
// don't know what the exact type is
return jl_is_mutable(jt) ? tbaa_mutab : tbaa_immut;
}

// metadata tracking for a llvm Value* during codegen
struct jl_cgval_t {
Value *V; // may be of type T* or T, or set to NULL if ghost (or if the value has not been initialized yet, for a variable definition)
Expand Down Expand Up @@ -464,9 +475,7 @@ struct jl_cgval_t {
isboxed(isboxed),
isghost(false),
isimmutable(isboxed && jl_is_immutable_datatype(typ)),
tbaa(isboxed ? (jl_is_leaf_type(typ) ?
(jl_is_mutable(typ) ? tbaa_mutab : tbaa_immut) :
tbaa_value) : nullptr)
tbaa(isboxed ? best_tbaa(typ) : nullptr)
{
assert(!(isboxed && TIndex != NULL));
assert(TIndex == NULL || TIndex->getType() == T_int8);
Expand Down

0 comments on commit 37d84dd

Please sign in to comment.