Skip to content

Commit

Permalink
ensure the lazy memloc local_slot creation is moved to the right basi…
Browse files Browse the repository at this point in the history
…cblock to dominate the function
  • Loading branch information
vtjnash committed Aug 25, 2015
1 parent e20f4c0 commit 6ae7707
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3022,8 +3022,12 @@ static void emit_assignment(jl_value_t *l, jl_value_t *r, jl_codectx_t *ctx)

if (!bp && !vi.hasGCRoot && vi.used && !vi.isArgument &&
!is_stable_expr(r, ctx)) {
vi.hasGCRoot = true; // this has been discovered to need a gc root
vi.memvalue = bp = emit_local_slot(ctx->gc.argSpaceSize++, ctx);
Instruction *newroot = cast<Instruction>(emit_local_slot(ctx->gc.argSpaceSize++, ctx));
newroot->removeFromParent(); // move it to the gc frame basic block so it can be reused as needed
newroot->insertAfter(ctx->gc.last_gcframe_inst);
vi.memvalue = bp = newroot;
vi.hasGCRoot = true; // this has been discovered to need a gc root, add it now
//TODO: move this logic after the emit_expr
}
Value *rval = emit_assignment(bp, r, vi.declType, vi.isVolatile, vi.used, ctx);

Expand Down Expand Up @@ -3503,7 +3507,7 @@ static void finalize_gc_frame(jl_codectx_t *ctx)
}
BasicBlock::iterator bbi(gc->gcframe);
AllocaInst *newgcframe = gc->gcframe;
builder.SetInsertPoint(++gc->last_gcframe_inst); // set insert *before* point
builder.SetInsertPoint(++gc->last_gcframe_inst); // set insert *before* point, e.g. after the gcframe
// Allocate the real GC frame
// n_frames++;
newgcframe->setOperand(0, ConstantInt::get(T_int32, 2 + gc->argSpaceSize + gc->maxDepth)); // fix up the size of the gc frame
Expand Down Expand Up @@ -4548,6 +4552,9 @@ static Function *emit_function(jl_lambda_info_t *lam)
assert(false);
}
}
else {
assert(vi.memvalue == NULL);
}
}

// step 14. associate labels with basic blocks to resolve forward jumps
Expand Down

0 comments on commit 6ae7707

Please sign in to comment.