Skip to content

Commit

Permalink
Merge f6bd488 into feaee9e
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash authored Jul 6, 2018
2 parents feaee9e + f6bd488 commit 2ba2025
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 101 deletions.
3 changes: 3 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ FLAGS := \
ifneq ($(USEMSVC), 1)
FLAGS += -Wall -Wno-strict-aliasing -fno-omit-frame-pointer -fvisibility=hidden -fno-common \
-Wpointer-arith -Wundef
ifeq ($(USEGCC),1) # GCC bug #25509 (void)__attribute__((warn_unused_result))
FLAGS += -Wno-unused-result
endif
override CFLAGS += -Wold-style-definition -Wstrict-prototypes -Wc++-compat
endif

Expand Down
60 changes: 0 additions & 60 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1632,32 +1632,6 @@ static bool arraytype_constshape(jl_value_t *ty)
jl_is_long(jl_tparam1(ty)) && jl_unbox_long(jl_tparam1(ty)) != 1);
}

static void maybe_alloc_arrayvar(jl_codectx_t &ctx, int s)
{
jl_value_t *jt = ctx.slots[s].value.typ;
if (arraytype_constshape(jt)) {
// TODO: this optimization does not yet work with 1-d arrays, since the
// length and data pointer can change at any time via push!
// we could make it work by reloading the metadata when the array is
// passed to an external function (ideally only impure functions)
int ndims = jl_unbox_long(jl_tparam1(jt));
jl_value_t *jelt = jl_tparam0(jt);
bool isboxed = !jl_array_store_unboxed(jelt);
Type *elt = julia_type_to_llvm(jelt);
if (type_is_ghost(elt))
return;
if (isboxed)
elt = T_prjlvalue;
// CreateAlloca is OK here because maybe_alloc_arrayvar is only called in the prologue setup
jl_arrayvar_t &av = (*ctx.arrayvars)[s];
av.dataptr = ctx.builder.CreateAlloca(PointerType::get(elt, 0));
av.len = ctx.builder.CreateAlloca(T_size);
for (int i = 0; i < ndims - 1; i++)
av.sizes.push_back(ctx.builder.CreateAlloca(T_size));
av.ty = jt;
}
}

static Value *emit_arraysize(jl_codectx_t &ctx, const jl_cgval_t &tinfo, Value *dim)
{
Value *t = boxed(ctx, tinfo);
Expand All @@ -1669,20 +1643,6 @@ static Value *emit_arraysize(jl_codectx_t &ctx, const jl_cgval_t &tinfo, Value *
tbaa, T_psize);
}

static jl_arrayvar_t *arrayvar_for(jl_codectx_t &ctx, jl_value_t *ex)
{
if (ex == NULL)
return NULL;
if (!jl_is_slot(ex))
return NULL;
int sl = jl_slot_number(ex) - 1;
auto av = ctx.arrayvars->find(sl);
if (av != ctx.arrayvars->end())
return &av->second;
//TODO: ssavalue case
return NULL;
}

static Value *emit_arraysize(jl_codectx_t &ctx, const jl_cgval_t &tinfo, int dim)
{
return emit_arraysize(ctx, tinfo, ConstantInt::get(T_int32, dim));
Expand Down Expand Up @@ -1721,9 +1681,6 @@ static Value *emit_arraylen_prim(jl_codectx_t &ctx, const jl_cgval_t &tinfo)

static Value *emit_arraylen(jl_codectx_t &ctx, const jl_cgval_t &tinfo, jl_value_t *ex)
{
jl_arrayvar_t *av = arrayvar_for(ctx, ex);
if (av != NULL)
return ctx.builder.CreateLoad(av->len);
return emit_arraylen_prim(ctx, tinfo);
}

Expand All @@ -1747,17 +1704,11 @@ static Value *emit_arrayptr(jl_codectx_t &ctx, const jl_cgval_t &tinfo, bool isb

static Value *emit_arrayptr(jl_codectx_t &ctx, const jl_cgval_t &tinfo, jl_value_t *ex, bool isboxed = false)
{
jl_arrayvar_t *av = arrayvar_for(ctx, ex);
if (av!=NULL)
return ctx.builder.CreateLoad(av->dataptr);
return emit_arrayptr(ctx, tinfo, isboxed);
}

static Value *emit_arraysize(jl_codectx_t &ctx, const jl_cgval_t &tinfo, jl_value_t *ex, int dim)
{
jl_arrayvar_t *av = arrayvar_for(ctx, ex);
if (av != NULL && dim <= (int)av->sizes.size())
return ctx.builder.CreateLoad(av->sizes[dim - 1]);
return emit_arraysize(ctx, tinfo, dim);
}

Expand Down Expand Up @@ -1790,17 +1741,6 @@ static Value *emit_arrayelsize(jl_codectx_t &ctx, const jl_cgval_t &tinfo)
return tbaa_decorate(tbaa_const, ctx.builder.CreateLoad(addr));
}

static void assign_arrayvar(jl_codectx_t &ctx, jl_arrayvar_t &av, const jl_cgval_t &ainfo)
{
Value *aptr = emit_bitcast(ctx,
emit_arrayptr(ctx, ainfo),
av.dataptr->getType()->getContainedType(0));
tbaa_decorate(tbaa_arrayptr, ctx.builder.CreateStore(aptr, av.dataptr));
ctx.builder.CreateStore(emit_arraylen_prim(ctx, ainfo), av.len);
for (size_t i = 0; i < av.sizes.size(); i++)
ctx.builder.CreateStore(emit_arraysize(ctx, ainfo, i + 1), av.sizes[i]);
}

// Returns the size of the array represented by `tinfo` for the given dimension `dim` if
// `dim` is a valid dimension, otherwise returns constant one.
static Value *emit_arraysize_for_unsafe_dim(jl_codectx_t &ctx,
Expand Down
26 changes: 0 additions & 26 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,14 +494,6 @@ struct jl_varinfo_t {
}
};

// aggregate of array metadata
typedef struct {
Value *dataptr;
Value *len;
std::vector<Value*> sizes;
jl_value_t *ty;
} jl_arrayvar_t;

struct jl_returninfo_t {
Function *decl;
enum CallingConv {
Expand Down Expand Up @@ -530,7 +522,6 @@ class jl_codectx_t {
std::vector<jl_cgval_t> SAvalues;
std::vector<std::tuple<jl_cgval_t, BasicBlock *, AllocaInst *, PHINode *, jl_value_t *>> PhiNodes;
std::vector<bool> ssavalue_assigned;
std::map<int, jl_arrayvar_t> *arrayvars = NULL;
jl_module_t *module = NULL;
jl_method_instance_t *linfo = NULL;
jl_code_info_t *source = NULL;
Expand Down Expand Up @@ -3637,15 +3628,6 @@ static void emit_varinfo_assign(jl_codectx_t &ctx, jl_varinfo_t &vi, jl_cgval_t
if (rval_info.typ == jl_bottom_type)
return;

// add info to arrayvar list
if (l && rval_info.isboxed) {
// check isboxed in case rval isn't the right type (for example, on a dead branch),
// so we don't try to assign it to the arrayvar info
jl_arrayvar_t *av = arrayvar_for(ctx, l);
if (av != NULL)
assign_arrayvar(ctx, *av, rval_info);
}

// compute / store tindex info
if (vi.pTIndex) {
Value *tindex;
Expand Down Expand Up @@ -5269,9 +5251,7 @@ static std::unique_ptr<Module> emit_function(

//jl_static_show(JL_STDOUT, (jl_value_t*)ast);
//jl_printf(JL_STDOUT, "\n");
std::map<int, jl_arrayvar_t> arrayvars;
std::map<int, BasicBlock*> labels;
ctx.arrayvars = &arrayvars;
ctx.module = jl_is_method(lam->def.method) ? lam->def.method->module : lam->def.module;
ctx.linfo = lam;
ctx.source = src;
Expand Down Expand Up @@ -5703,7 +5683,6 @@ static std::unique_ptr<Module> emit_function(
continue;
}
allocate_local(varinfo, s);
maybe_alloc_arrayvar(ctx, i);
}

std::map<int, int> upsilon_to_phic;
Expand Down Expand Up @@ -5826,11 +5805,6 @@ static std::unique_ptr<Module> emit_function(
Value *argp = boxed(ctx, theArg);
ctx.builder.CreateStore(argp, vi.boxroot);
}
// get arrayvar data if applicable
if (arrayvars.find(i) != arrayvars.end()) {
jl_arrayvar_t av = arrayvars[i];
assign_arrayvar(ctx, av, theArg);
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1834,10 +1834,10 @@ static jl_value_t *jl_deserialize_typemap_entry(jl_serializer_state *s)
jl_deserialize_struct(s, v, 1);
#ifndef NDEBUG
if (te->func.value && jl_typeis(te->func.value, jl_method_instance_type)) {
assert((te->func.linfo->max_world == 0 &&
assert(((te->func.linfo->max_world == 0 &&
te->func.linfo->min_world == 1) ||
(te->func.linfo->max_world >= te->max_world &&
te->func.linfo->min_world <= te->min_world) &&
(te->func.linfo->max_world >= te->max_world &&
te->func.linfo->min_world <= te->min_world)) &&
"corrupt typemap entry structure");
}
#endif
Expand Down
12 changes: 1 addition & 11 deletions src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1325,15 +1325,5 @@ static Function *boxfunc_llvm(FunctionType *ft, const std::string &cname,

static FunctionType *ft1arg(Type *ret, Type *arg)
{
std::vector<Type*> args1(0);
args1.push_back(arg);
return FunctionType::get(ret, args1, false);
}

static FunctionType *ft2arg(Type *ret, Type *arg1, Type *arg2)
{
std::vector<Type*> args2(0);
args2.push_back(arg1);
args2.push_back(arg2);
return FunctionType::get(ret, args2, false);
return FunctionType::get(ret, { arg }, false);
}
2 changes: 1 addition & 1 deletion src/jloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ jl_options_t jl_options = { 0, // quiet
-1, // banner
NULL, // julia_bindir
NULL, // julia_bin
NULL, // project
NULL, // cmds
NULL, // image_file (will be filled in below)
NULL, // cpu_target ("native", "core2", etc...)
0, // nprocs
NULL, // machine_file
NULL, // project
0, // isinteractive
0, // color
JL_OPTIONS_HISTORYFILE_ON, // history file
Expand Down

0 comments on commit 2ba2025

Please sign in to comment.