Skip to content

Commit

Permalink
Do codegen in control flow order
Browse files Browse the repository at this point in the history
* Fix codegen of `SSAValue` whose assignment appears later than the user
  in syntactic order due to backward branches.
* Disallow more expression types in value position
* Use improved debug info metadata in coverage and allocation tracking too
  • Loading branch information
yuyichao committed Aug 23, 2016
1 parent 3f29b37 commit 3e17c50
Show file tree
Hide file tree
Showing 3 changed files with 411 additions and 293 deletions.
18 changes: 2 additions & 16 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,26 +741,12 @@ static void emit_typecheck(const jl_cgval_t &x, jl_value_t *type, const std::str
builder.SetInsertPoint(passBB);
}

static bool is_inbounds(jl_codectx_t *ctx)
{
// inbounds rule is either of top two values on inbounds stack are true
bool inbounds = !ctx->inbounds.empty() && ctx->inbounds.back();
if (ctx->inbounds.size() > 1)
inbounds |= ctx->inbounds[ctx->inbounds.size()-2];
return inbounds;
}

static bool is_bounds_check_block(jl_codectx_t *ctx)
{
return !ctx->boundsCheck.empty() && ctx->boundsCheck.back();
}

#define CHECK_BOUNDS 1
static Value *emit_bounds_check(const jl_cgval_t &ainfo, jl_value_t *ty, Value *i, Value *len, jl_codectx_t *ctx)
{
Value *im1 = builder.CreateSub(i, ConstantInt::get(T_size, 1));
#if CHECK_BOUNDS==1
if ((!is_inbounds(ctx) &&
if ((!ctx->is_inbounds &&
jl_options.check_bounds != JL_OPTIONS_CHECK_BOUNDS_OFF) ||
jl_options.check_bounds == JL_OPTIONS_CHECK_BOUNDS_ON) {
Value *ok = builder.CreateICmpULT(im1, len);
Expand Down Expand Up @@ -1269,7 +1255,7 @@ static Value *emit_array_nd_index(const jl_cgval_t &ainfo, jl_value_t *ex, size_
Value *i = ConstantInt::get(T_size, 0);
Value *stride = ConstantInt::get(T_size, 1);
#if CHECK_BOUNDS==1
bool bc = (!is_inbounds(ctx) &&
bool bc = (!ctx->is_inbounds &&
jl_options.check_bounds != JL_OPTIONS_CHECK_BOUNDS_OFF) ||
jl_options.check_bounds == JL_OPTIONS_CHECK_BOUNDS_ON;
BasicBlock *failBB=NULL, *endBB=NULL;
Expand Down
Loading

0 comments on commit 3e17c50

Please sign in to comment.