Skip to content

Commit

Permalink
Fix crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arch D. Robison committed Apr 6, 2016
1 parent 0ba9dd8 commit d6ff149
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export
SimpleVector, AbstractArray, DenseArray,
# special objects
Function, LambdaInfo, Method, MethodTable,
Module, Symbol, Task, Array, WeakRef, VecElement
Module, Symbol, Task, Array, WeakRef, VecElement,
# numeric types
Number, Real, Integer, Bool, Ref, Ptr,
AbstractFloat, Float16, Float32, Float64,
Expand Down
6 changes: 5 additions & 1 deletion src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,10 @@ static unsigned julia_alignment(Value* /*ptr*/, jl_value_t *jltype, unsigned ali
return alignment;
}

static LoadInst *build_load (Value *ptr, jl_value_t *jltype) {
return builder.CreateAlignedLoad(ptr, julia_alignment(ptr, jltype, 0));
}

static Value *emit_unbox(Type *to, const jl_cgval_t &x, jl_value_t *jt);

static jl_cgval_t typed_load(Value *ptr, Value *idx_0based, jl_value_t *jltype,
Expand Down Expand Up @@ -1422,7 +1426,7 @@ static Value *boxed(const jl_cgval_t &vinfo, jl_codectx_t *ctx, bool gcrooted)
assert(!type_is_ghost(t)); // should have been handled by isghost above!

if (vinfo.ispointer)
v = builder.CreateLoad(builder.CreatePointerCast(v, t->getPointerTo()));
v = build_load( builder.CreatePointerCast(v, t->getPointerTo()), vinfo.typ );

if (t == T_int1)
return julia_bool(v);
Expand Down
2 changes: 1 addition & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3961,7 +3961,7 @@ static Function *gen_jlcall_wrapper(jl_lambda_info_t *lam, jl_expr_t *ast, Funct
if (lty != NULL && !isboxed) {
theArg = builder.CreatePointerCast(theArg, PointerType::get(lty,0));
if (!lty->isAggregateType()) // keep "aggregate" type values in place as pointers
theArg = builder.CreateAlignedLoad(theArg, julia_alignment(theArg, ty, 0));
theArg = build_load(theArg, ty);
}
assert(dyn_cast<UndefValue>(theArg) == NULL);
args[idx] = theArg;
Expand Down
2 changes: 1 addition & 1 deletion src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static Value *emit_unbox(Type *to, const jl_cgval_t &x, jl_value_t *jt)
if (x.isboxed)
return builder.CreateAlignedLoad(p, 16); // julia's gc gives 16-byte aligned addresses
else if (jt)
return builder.CreateAlignedLoad(p, julia_alignment(p, jt, 0));
return build_load(p, jt);
else
// stack has default alignment
return builder.CreateLoad(p);
Expand Down

0 comments on commit d6ff149

Please sign in to comment.