Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove global basic pointer types #43754

Merged
merged 2 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Forgot to remove T_psize
  • Loading branch information
pchintalapudi committed Jan 12, 2022
commit e5c100351c5bca8311907b18ffd93cad3ab6cbb8
4 changes: 2 additions & 2 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
len = ConstantInt::get(getSizeTy(ctx.builder.getContext()), jl_svec_len(svecv.constant));
}
else {
auto ptr = emit_bitcast(ctx, boxed(ctx, svecv), T_psize);
auto ptr = emit_bitcast(ctx, boxed(ctx, svecv), getSizePtrTy(ctx.builder.getContext()));
len = ctx.builder.CreateAlignedLoad(getSizeTy(ctx.builder.getContext()), ptr, Align(sizeof(size_t)));
// Only mark with TBAA if we are sure about the type.
// This could otherwise be in a dead branch
Expand Down Expand Up @@ -1756,7 +1756,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
if (val.typ == (jl_value_t*)jl_symbol_type) {
JL_GC_POP();
const int hash_offset = offsetof(jl_sym_t, hash);
Value *ph1 = emit_bitcast(ctx, decay_derived(ctx, boxed(ctx, val)), T_psize);
Value *ph1 = emit_bitcast(ctx, decay_derived(ctx, boxed(ctx, val)), getSizePtrTy(ctx.builder.getContext()));
Value *ph2 = ctx.builder.CreateInBoundsGEP(getSizeTy(ctx.builder.getContext()), ph1, ConstantInt::get(getSizeTy(ctx.builder.getContext()), hash_offset / sizeof(size_t)));
LoadInst *hashval = ctx.builder.CreateAlignedLoad(getSizeTy(ctx.builder.getContext()), ph2, Align(sizeof(size_t)));
tbaa_decorate(ctx.tbaa().tbaa_const, hashval);
Expand Down
2 changes: 1 addition & 1 deletion src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ static Value *emit_datatype_types(jl_codectx_t &ctx, Value *dt)

static Value *emit_datatype_nfields(jl_codectx_t &ctx, Value *dt)
{
Value *type_svec = emit_bitcast(ctx, emit_datatype_types(ctx, dt), T_psize);
Value *type_svec = emit_bitcast(ctx, emit_datatype_types(ctx, dt), getSizePtrTy(ctx.builder.getContext()));
return tbaa_decorate(ctx.tbaa().tbaa_const, ctx.builder.CreateAlignedLoad(getSizeTy(ctx.builder.getContext()), type_svec, Align(sizeof(void*))));
}

Expand Down
21 changes: 13 additions & 8 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ auto getFloatPtrTy(LLVMContext &ctxt) {
auto getDoublePtrTy(LLVMContext &ctxt) {
return Type::getDoublePtrTy(ctxt);
}
auto getSizePtrTy(LLVMContext &ctxt) {
if (sizeof(size_t) > sizeof(uint32_t)) {
return getInt64PtrTy(ctxt);
} else {
return getInt32PtrTy(ctxt);
}
}

typedef Instruction TerminatorInst;

Expand Down Expand Up @@ -228,8 +235,6 @@ static Type *T_pvoidfunc;

static IntegerType *T_sigatomic;

static Type *T_psize;

static Type *T_ppint8;
static Type *T_pppint8;

Expand Down Expand Up @@ -563,7 +568,7 @@ static const auto jlundefvarerror_func = new JuliaFunction{
static const auto jlboundserrorv_func = new JuliaFunction{
XSTR(jl_bounds_error_ints),
[](LLVMContext &C) { return FunctionType::get(getVoidTy(C),
{PointerType::get(T_jlvalue, AddressSpace::CalleeRooted), T_psize, getSizeTy(C)}, false); },
{PointerType::get(T_jlvalue, AddressSpace::CalleeRooted), getSizePtrTy(C), getSizeTy(C)}, false); },
get_attrs_noreturn,
};
static const auto jlboundserror_func = new JuliaFunction{
Expand Down Expand Up @@ -3198,7 +3203,7 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
return true;
}
// String and SimpleVector's length fields have the same layout
auto ptr = emit_bitcast(ctx, boxed(ctx, obj), T_psize);
auto ptr = emit_bitcast(ctx, boxed(ctx, obj), getSizePtrTy(ctx.builder.getContext()));
Value *len = tbaa_decorate(ctx.tbaa().tbaa_const, ctx.builder.CreateAlignedLoad(getSizeTy(ctx.builder.getContext()), ptr, Align(sizeof(size_t))));
MDBuilder MDB(ctx.builder.getContext());
if (sty == jl_simplevector_type) {
Expand Down Expand Up @@ -4904,7 +4909,7 @@ static void emit_last_age_field(jl_codectx_t &ctx)
assert(ctx.builder.GetInsertBlock() == ctx.pgcstack->getParent());
ctx.world_age_field = ctx.builder.CreateInBoundsGEP(
getSizeTy(ctx.builder.getContext()),
ctx.builder.CreateBitCast(ptls, T_psize),
ctx.builder.CreateBitCast(ptls, getSizePtrTy(ctx.builder.getContext())),
ConstantInt::get(getSizeTy(ctx.builder.getContext()), offsetof(jl_task_t, world_age) / sizeof(size_t)),
"world_age");
}
Expand All @@ -4915,7 +4920,7 @@ static Value *get_current_signal_page(jl_codectx_t &ctx)
// return ctx.builder.CreateCall(prepare_call(reuse_signal_page_func));
auto ptls = get_current_ptls(ctx);
int nthfield = offsetof(jl_tls_states_t, safepoint) / sizeof(void *);
return emit_nthptr_recast(ctx, ptls, nthfield, ctx.tbaa().tbaa_const, T_psize);
return emit_nthptr_recast(ctx, ptls, nthfield, ctx.tbaa().tbaa_const, getSizePtrTy(ctx.builder.getContext()));
}

static Function *emit_tojlinvoke(jl_code_instance_t *codeinst, Module *M, jl_codegen_params_t &params)
Expand Down Expand Up @@ -5206,7 +5211,7 @@ static Function* gen_cfun_wrapper(
getSizeTy(ctx.builder.getContext()),
ctx.builder.CreateConstInBoundsGEP1_32(
getSizeTy(ctx.builder.getContext()),
emit_bitcast(ctx, literal_pointer_val(ctx, (jl_value_t*)codeinst), T_psize),
emit_bitcast(ctx, literal_pointer_val(ctx, (jl_value_t*)codeinst), getSizePtrTy(ctx.builder.getContext())),
offsetof(jl_code_instance_t, max_world) / sizeof(size_t)),
Align(sizeof(size_t)));
// XXX: age is always OK if we don't have a TLS. This is a hack required due to `@threadcall` abuse.
Expand Down Expand Up @@ -5746,7 +5751,7 @@ static jl_cgval_t emit_cfunction(jl_codectx_t &ctx, jl_value_t *output_type, con
assert(jl_datatype_size(output_type) == sizeof(void*) * 4);
Value *strct = emit_allocobj(ctx, jl_datatype_size(output_type),
literal_pointer_val(ctx, (jl_value_t*)output_type));
Value *derived_strct = emit_bitcast(ctx, decay_derived(ctx, strct), T_psize);
Value *derived_strct = emit_bitcast(ctx, decay_derived(ctx, strct), getSizePtrTy(ctx.builder.getContext()));
MDNode *tbaa = best_tbaa(ctx.tbaa(), output_type);
tbaa_decorate(tbaa, ctx.builder.CreateStore(F, derived_strct));
tbaa_decorate(tbaa, ctx.builder.CreateStore(
Expand Down
2 changes: 1 addition & 1 deletion src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ static jl_cgval_t emit_pointerset(jl_codectx_t &ctx, jl_cgval_t *argv)
Value *thePtr;
if (ety == (jl_value_t*)jl_any_type) {
// unsafe_store to Ptr{Any} is allowed to implicitly drop GC roots.
thePtr = emit_unbox(ctx, T_psize, e, e.typ);
thePtr = emit_unbox(ctx, getSizePtrTy(ctx.builder.getContext()), e, e.typ);
Instruction *store = ctx.builder.CreateAlignedStore(
ctx.builder.CreatePtrToInt(emit_pointer_from_objref(ctx, boxed(ctx, x)), getSizeTy(ctx.builder.getContext())),
ctx.builder.CreateInBoundsGEP(getSizeTy(ctx.builder.getContext()), thePtr, im1), Align(align_nb));
Expand Down