Skip to content

Commit

Permalink
Merge pull request #27873 from JuliaLang/jn/codegen-tbaa
Browse files Browse the repository at this point in the history
codegen: mark tbaa information in more places
  • Loading branch information
vtjnash authored Jul 2, 2018
2 parents 7cf81b9 + a57189f commit 8a78344
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 234 deletions.
4 changes: 2 additions & 2 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ julia> Base.isbitsunion(Union{Float64, String})
false
```
"""
isbitsunion(u::Union) = ccall(:jl_array_store_unboxed, Cint, (Any,), u) == Cint(1)
isbitsunion(u::Union) = ccall(:jl_array_store_unboxed, Cint, (Any,), u) != Cint(0)
isbitsunion(x) = false

"""
Expand All @@ -167,7 +167,7 @@ julia> Base.bitsunionsize(Union{Float64, UInt8, Int128})
function bitsunionsize(u::Union)
sz = Ref{Csize_t}(0)
algn = Ref{Csize_t}(0)
@assert ccall(:jl_islayout_inline, Cint, (Any, Ptr{Csize_t}, Ptr{Csize_t}), u, sz, algn) == Cint(1)
@assert ccall(:jl_islayout_inline, Cint, (Any, Ptr{Csize_t}, Ptr{Csize_t}), u, sz, algn) != Cint(0)
return sz[]
end

Expand Down
14 changes: 7 additions & 7 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ static Value *julia_to_address(
}
ai->setAlignment(16);
// minimum gc-alignment in julia is pointer size
emit_memcpy(ctx, ai, jvinfo, nbytes, sizeof(void*));
emit_memcpy(ctx, ai, jvinfo.tbaa, jvinfo, nbytes, sizeof(void*));
return ctx.builder.CreatePtrToInt(ai, to);
}
}
Expand All @@ -596,7 +596,7 @@ static Value *julia_to_address(
Value *nbytes = emit_datatype_size(ctx, jvt);
AllocaInst *ai = ctx.builder.CreateAlloca(T_int8, nbytes);
ai->setAlignment(16);
emit_memcpy(ctx, ai, jvinfo, nbytes, sizeof(void*)); // minimum gc-alignment in julia is pointer size
emit_memcpy(ctx, ai, jvinfo.tbaa, jvinfo, nbytes, sizeof(void*)); // minimum gc-alignment in julia is pointer size
Value *p2 = ctx.builder.CreatePtrToInt(ai, to);
ctx.builder.CreateBr(afterBB);
ctx.builder.SetInsertPoint(afterBB);
Expand All @@ -611,10 +611,10 @@ static Value *julia_to_address(
// since those are immutable.
Value *slot = emit_static_alloca(ctx, slottype);
if (!jvinfo.ispointer()) {
ctx.builder.CreateStore(emit_unbox(ctx, slottype, jvinfo, ety), slot);
tbaa_decorate(jvinfo.tbaa, ctx.builder.CreateStore(emit_unbox(ctx, slottype, jvinfo, ety), slot));
}
else {
emit_memcpy(ctx, slot, jvinfo, jl_datatype_size(ety), jl_datatype_align(ety));
emit_memcpy(ctx, slot, jvinfo.tbaa, jvinfo, jl_datatype_size(ety), jl_datatype_align(ety));
}
return ctx.builder.CreatePtrToInt(slot, to);
}
Expand Down Expand Up @@ -646,10 +646,10 @@ static Value *julia_to_native(
// since those are immutable.
Value *slot = emit_static_alloca(ctx, to);
if (!jvinfo.ispointer()) {
ctx.builder.CreateStore(emit_unbox(ctx, to, jvinfo, jlto), slot);
tbaa_decorate(jvinfo.tbaa, ctx.builder.CreateStore(emit_unbox(ctx, to, jvinfo, jlto), slot));
}
else {
emit_memcpy(ctx, slot, jvinfo, jl_datatype_size(jlto), jl_datatype_align(jlto));
emit_memcpy(ctx, slot, jvinfo.tbaa, jvinfo, jl_datatype_size(jlto), jl_datatype_align(jlto));
}
return slot;
}
Expand Down Expand Up @@ -2096,7 +2096,7 @@ jl_cgval_t function_sig_t::emit_a_ccall(
auto slot = emit_static_alloca(ctx, resultTy);
slot->setAlignment(boxalign);
ctx.builder.CreateAlignedStore(result, slot, boxalign);
emit_memcpy(ctx, strct, slot, rtsz, boxalign, tbaa);
emit_memcpy(ctx, strct, tbaa, slot, tbaa, rtsz, boxalign, tbaa);
}
else {
init_bits_value(ctx, strct, result, tbaa, boxalign);
Expand Down
Loading

0 comments on commit 8a78344

Please sign in to comment.