Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/APInt-C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const unsigned int host_char_bit = 8;
/* TODO: this memcpy assumes little-endian,
* for big-endian, need to align the copy to the other end */ \
memcpy(data_a64, p##s, RoundUpToAlignment(numbits, host_char_bit) / host_char_bit); \
s = APInt(numbits, makeArrayRef(data_a64, nbytes / sizeof(integerPart))); \
s = APInt(numbits, ArrayRef<uint64_t>(data_a64, nbytes / sizeof(integerPart))); \
} \
else { \
s = APInt(numbits, makeArrayRef(p##s, numbits / integerPartWidth)); \
s = APInt(numbits, ArrayRef<uint64_t>(p##s, numbits / integerPartWidth)); \
}

/* assign to "integerPart *pr" from "APInt a" */
Expand Down
4 changes: 4 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ endif

RT_LLVM_LIBS := support

ifeq ($(LLVM_VER_MAJ),16)
RT_LLVM_LIBS += targetparser
endif

ifeq ($(OS),WINNT)
SRCS += win32_ucontext
endif
Expand Down
5 changes: 3 additions & 2 deletions src/aotcompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ using namespace llvm;
#include "jitlayers.h"
#include "serialize.h"
#include "julia_assert.h"
#include "llvm-codegen-shared.h"
#include "processor.h"

#define DEBUG_TYPE "julia_aotcompile"
Expand Down Expand Up @@ -1004,7 +1003,7 @@ static AOTOutputs add_output_impl(Module &M, TargetMachine &SourceTM, ShardTimer
SourceTM.getRelocationModel(),
SourceTM.getCodeModel(),
SourceTM.getOptLevel()));

fixupTM(*TM);
if (unopt) {
timers.unopt.startTimer();
raw_svector_ostream OS(out.unopt);
Expand Down Expand Up @@ -1032,6 +1031,7 @@ static AOTOutputs add_output_impl(Module &M, TargetMachine &SourceTM, ShardTimer
SourceTM.getRelocationModel(),
SourceTM.getCodeModel(),
SourceTM.getOptLevel()));
fixupTM(*PMTM);
NewPM optimizer{std::move(PMTM), getOptLevel(jl_options.opt_level), OptimizationOptions::defaults(true, true)};
optimizer.run(M);
assert(!verifyLLVMIR(M));
Expand Down Expand Up @@ -1527,6 +1527,7 @@ void jl_dump_native_impl(void *native_code,
CMModel,
CodeGenOpt::Aggressive // -O3 TODO: respect command -O0 flag?
));
fixupTM(*SourceTM);
auto DL = jl_create_datalayout(*SourceTM);
std::string StackProtectorGuard;
unsigned OverrideStackAlignment;
Expand Down
29 changes: 15 additions & 14 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static Value *runtime_sym_lookup(
dlsym_lookup);

assert(f->getParent() != NULL);
f->getBasicBlockList().push_back(dlsym_lookup);
dlsym_lookup->insertInto(f);
irbuilder.SetInsertPoint(dlsym_lookup);
Instruction *llvmf;
Value *nameval = stringConstPtr(emission_context, irbuilder, f_name);
Expand All @@ -180,7 +180,7 @@ static Value *runtime_sym_lookup(
store->setAtomic(AtomicOrdering::Release);
irbuilder.CreateBr(ccall_bb);

f->getBasicBlockList().push_back(ccall_bb);
ccall_bb->insertInto(f);
irbuilder.SetInsertPoint(ccall_bb);
PHINode *p = irbuilder.CreatePHI(T_pvoidfunc, 2);
p->addIncoming(llvmf_orig, enter_bb);
Expand Down Expand Up @@ -440,21 +440,21 @@ static Value *llvm_type_rewrite(
Value *from;
Value *to;
const DataLayout &DL = ctx.builder.GetInsertBlock()->getModule()->getDataLayout();
unsigned align = std::max(DL.getPrefTypeAlignment(target_type), DL.getPrefTypeAlignment(from_type));
Align align = std::max(DL.getPrefTypeAlign(target_type), DL.getPrefTypeAlign(from_type));
if (DL.getTypeAllocSize(target_type) >= DL.getTypeAllocSize(from_type)) {
to = emit_static_alloca(ctx, target_type);
setName(ctx.emission_context, to, "type_rewrite_buffer");
cast<AllocaInst>(to)->setAlignment(Align(align));
cast<AllocaInst>(to)->setAlignment(align);
from = emit_bitcast(ctx, to, from_type->getPointerTo());
}
else {
from = emit_static_alloca(ctx, from_type);
setName(ctx.emission_context, from, "type_rewrite_buffer");
cast<AllocaInst>(from)->setAlignment(Align(align));
cast<AllocaInst>(from)->setAlignment(align);
to = emit_bitcast(ctx, from, target_type->getPointerTo());
}
ctx.builder.CreateAlignedStore(v, from, Align(align));
auto pun = ctx.builder.CreateAlignedLoad(target_type, to, Align(align));
ctx.builder.CreateAlignedStore(v, from, align);
auto pun = ctx.builder.CreateAlignedLoad(target_type, to, align);
setName(ctx.emission_context, pun, "type_rewrite");
return pun;
}
Expand All @@ -473,7 +473,7 @@ static Value *runtime_apply_type_env(jl_codectx_t &ctx, jl_value_t *ty)
ctx.spvals_ptr,
ConstantInt::get(ctx.types().T_size, sizeof(jl_svec_t) / sizeof(jl_value_t*)))
};
auto call = ctx.builder.CreateCall(prepare_call(jlapplytype_func), makeArrayRef(args));
auto call = ctx.builder.CreateCall(prepare_call(jlapplytype_func), ArrayRef<Value*>(args));
addRetAttr(call, Attribute::getWithAlignment(ctx.builder.getContext(), Align(16)));
return call;
}
Expand All @@ -483,9 +483,10 @@ static const std::string make_errmsg(const char *fname, int n, const char *err)
std::string _msg;
raw_string_ostream msg(_msg);
msg << fname;
if (n > 0)
msg << " argument " << n;
else
if (n > 0) {
msg << " argument ";
msg << n;
} else
msg << " return";
msg << err;
return msg.str();
Expand Down Expand Up @@ -1055,7 +1056,7 @@ class function_sig_t {
FunctionType *functype(LLVMContext &ctxt) const {
assert(err_msg.empty());
if (nreqargs > 0)
return FunctionType::get(sret ? getVoidTy(ctxt) : prt, makeArrayRef(fargt_sig).slice(0, nreqargs), true);
return FunctionType::get(sret ? getVoidTy(ctxt) : prt, ArrayRef<Type*>(fargt_sig).slice(0, nreqargs), true);
else
return FunctionType::get(sret ? getVoidTy(ctxt) : prt, fargt_sig, false);
}
Expand Down Expand Up @@ -1674,7 +1675,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
true);
setName(ctx.emission_context, signal_page_load, "signal_page_load");
ctx.builder.CreateBr(contBB);
ctx.f->getBasicBlockList().push_back(contBB);
contBB->insertInto(ctx.f);
ctx.builder.SetInsertPoint(contBB);
return ghostValue(ctx, jl_nothing_type);
}
Expand Down Expand Up @@ -1857,7 +1858,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
decay_derived(ctx, data_pointer(ctx, val)),
T_pint8_derived)
};
Value *ret = ctx.builder.CreateCall(prepare_call(jl_object_id__func), makeArrayRef(args));
Value *ret = ctx.builder.CreateCall(prepare_call(jl_object_id__func), ArrayRef<Value*>(args));
setName(ctx.emission_context, ret, "object_id");
JL_GC_POP();
return mark_or_box_ccall_result(ctx, ret, retboxed, rt, unionall, static_rt);
Expand Down
38 changes: 19 additions & 19 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ static Type *_julia_struct_to_llvm(jl_codegen_params_t *ctx, LLVMContext &ctxt,
// unsigned remainder = fsz % al;
// while (remainder--)
// Elements.push_back(getInt8Ty(ctxt));
// lty = StructType::get(lty->getContext(), makeArrayRef(Elements));
// lty = StructType::get(lty->getContext(),ArrayRef<Type*>(Elements));
// }
if (isboxed) *isboxed = true;
return JuliaType::get_prjlvalue_ty(ctxt);
Expand Down Expand Up @@ -1354,7 +1354,7 @@ static void error_unless(jl_codectx_t &ctx, Value *cond, const Twine &msg)
ctx.builder.SetInsertPoint(failBB);
just_emit_error(ctx, prepare_call(jlerror_func), msg);
ctx.builder.CreateUnreachable();
ctx.f->getBasicBlockList().push_back(passBB);
passBB->insertInto(ctx.f);
ctx.builder.SetInsertPoint(passBB);
}

Expand All @@ -1368,7 +1368,7 @@ static void raise_exception(jl_codectx_t &ctx, Value *exc,
contBB = BasicBlock::Create(ctx.builder.getContext(), "after_throw", ctx.f);
}
else {
ctx.f->getBasicBlockList().push_back(contBB);
contBB->insertInto(ctx.f);
}
ctx.builder.SetInsertPoint(contBB);
}
Expand Down Expand Up @@ -1739,7 +1739,7 @@ static void emit_typecheck(jl_codectx_t &ctx, const jl_cgval_t &x, jl_value_t *t
just_emit_type_error(ctx, x, literal_pointer_val(ctx, type), msg);
ctx.builder.CreateUnreachable();

ctx.f->getBasicBlockList().push_back(passBB);
passBB->insertInto(ctx.f);
ctx.builder.SetInsertPoint(passBB);
}
}
Expand Down Expand Up @@ -1814,7 +1814,7 @@ static Value *emit_bounds_check(jl_codectx_t &ctx, const jl_cgval_t &ainfo, jl_v
i });
}
ctx.builder.CreateUnreachable();
ctx.f->getBasicBlockList().push_back(passBB);
passBB->insertInto(ctx.f);
ctx.builder.SetInsertPoint(passBB);
}
return im1;
Expand Down Expand Up @@ -2451,11 +2451,11 @@ static bool emit_getfield_unknownidx(jl_codectx_t &ctx,
assert((cast<ArrayType>(strct.V->getType())->getElementType() == ctx.types().T_prjlvalue) == isboxed);
Value *idx = idx0();
unsigned i = 0;
Value *fld = ctx.builder.CreateExtractValue(strct.V, makeArrayRef(i));
Value *fld = ctx.builder.CreateExtractValue(strct.V, ArrayRef<unsigned>(i));
for (i = 1; i < nfields; i++) {
fld = ctx.builder.CreateSelect(
ctx.builder.CreateICmpEQ(idx, ConstantInt::get(idx->getType(), i)),
ctx.builder.CreateExtractValue(strct.V, makeArrayRef(i)),
ctx.builder.CreateExtractValue(strct.V, ArrayRef<unsigned>(i)),
fld);
}
setName(ctx.emission_context, fld, "getfield");
Expand Down Expand Up @@ -2723,7 +2723,7 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
unsigned i = 0;
for (; i < fsz / align; i++) {
unsigned fld = st_idx + i;
Value *fldv = ctx.builder.CreateExtractValue(obj, makeArrayRef(fld));
Value *fldv = ctx.builder.CreateExtractValue(obj, ArrayRef<unsigned>(fld));
Value *fldp = ctx.builder.CreateConstInBoundsGEP1_32(ET, lv, i);
ctx.builder.CreateAlignedStore(fldv, fldp, Align(align));
}
Expand All @@ -2732,14 +2732,14 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
Value *staddr = ctx.builder.CreateConstInBoundsGEP1_32(ET, lv, i);
staddr = ctx.builder.CreateBitCast(staddr, getInt8PtrTy(ctx.builder.getContext()));
for (; i < ptindex - st_idx; i++) {
Value *fldv = ctx.builder.CreateExtractValue(obj, makeArrayRef(st_idx + i));
Value *fldv = ctx.builder.CreateExtractValue(obj, ArrayRef<unsigned>(st_idx + i));
Value *fldp = ctx.builder.CreateConstInBoundsGEP1_32(getInt8Ty(ctx.builder.getContext()), staddr, i);
ctx.builder.CreateAlignedStore(fldv, fldp, Align(1));
}
}
setNameWithField(ctx.emission_context, lv, get_objname, jt, idx, Twine());
}
Value *tindex0 = ctx.builder.CreateExtractValue(obj, makeArrayRef(ptindex));
Value *tindex0 = ctx.builder.CreateExtractValue(obj, ArrayRef<unsigned>(ptindex));
Value *tindex = ctx.builder.CreateNUWAdd(ConstantInt::get(getInt8Ty(ctx.builder.getContext()), 1), tindex0);
setNameWithField(ctx.emission_context, tindex, get_objname, jt, idx, Twine(".tindex"));
return mark_julia_slot(lv, jfty, tindex, ctx.tbaa().tbaa_stack);
Expand All @@ -2752,7 +2752,7 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
st_idx = convert_struct_offset(ctx, T, byte_offset);
else
llvm_unreachable("encountered incompatible type for a struct");
fldv = ctx.builder.CreateExtractValue(obj, makeArrayRef(st_idx));
fldv = ctx.builder.CreateExtractValue(obj, ArrayRef<unsigned>(st_idx));
setNameWithField(ctx.emission_context, fldv, get_objname, jt, idx, Twine());
}
if (maybe_null) {
Expand Down Expand Up @@ -3240,7 +3240,7 @@ static Function *mangleIntrinsic(IntrinsicInst *call) //mangling based on replac

auto newfType = FunctionType::get(
oldfType->getReturnType(),
makeArrayRef(argTys).slice(0, oldfType->getNumParams()),
ArrayRef<Type*>(argTys).slice(0, oldfType->getNumParams()),
oldfType->isVarArg());

// Accumulate an array of overloaded types for the given intrinsic
Expand Down Expand Up @@ -3460,7 +3460,7 @@ static void emit_cpointercheck(jl_codectx_t &ctx, const jl_cgval_t &x, const Twi
just_emit_type_error(ctx, x, literal_pointer_val(ctx, (jl_value_t*)jl_pointer_type), msg);
ctx.builder.CreateUnreachable();

ctx.f->getBasicBlockList().push_back(passBB);
passBB->insertInto(ctx.f);
ctx.builder.SetInsertPoint(passBB);
}

Expand Down Expand Up @@ -3496,7 +3496,7 @@ static Value *emit_new_bits(jl_codectx_t &ctx, Value *jt, Value *pval)
// if ptr is NULL this emits a write barrier _back_
static void emit_write_barrier(jl_codectx_t &ctx, Value *parent, Value *ptr)
{
emit_write_barrier(ctx, parent, makeArrayRef(ptr));
emit_write_barrier(ctx, parent, ArrayRef<Value*>(ptr));
}

static void emit_write_barrier(jl_codectx_t &ctx, Value *parent, ArrayRef<Value*> ptrs)
Expand Down Expand Up @@ -3798,7 +3798,7 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
Value *fldp = ctx.builder.CreateConstInBoundsGEP1_32(ET, lv, i);
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_stack);
Value *fldv = ai.decorateInst(ctx.builder.CreateAlignedLoad(ET, fldp, Align(al)));
strct = ctx.builder.CreateInsertValue(strct, fldv, makeArrayRef(llvm_idx + i));
strct = ctx.builder.CreateInsertValue(strct, fldv, ArrayRef<unsigned>(llvm_idx + i));
}
// emit remaining bytes up to tindex
if (i < ptindex - llvm_idx) {
Expand All @@ -3808,14 +3808,14 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
Value *fldp = ctx.builder.CreateConstInBoundsGEP1_32(getInt8Ty(ctx.builder.getContext()), staddr, i);
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_stack);
Value *fldv = ai.decorateInst(ctx.builder.CreateAlignedLoad(getInt8Ty(ctx.builder.getContext()), fldp, Align(1)));
strct = ctx.builder.CreateInsertValue(strct, fldv, makeArrayRef(llvm_idx + i));
strct = ctx.builder.CreateInsertValue(strct, fldv, ArrayRef<unsigned>(llvm_idx + i));
}
}
}
llvm_idx = ptindex;
fval = tindex;
if (jl_is_vecelement_type(ty))
fval = ctx.builder.CreateInsertValue(strct, fval, makeArrayRef(llvm_idx));
fval = ctx.builder.CreateInsertValue(strct, fval, ArrayRef<unsigned>(llvm_idx));
}
else {
Value *ptindex = emit_struct_gep(ctx, lt, strct, offs + fsz1);
Expand All @@ -3842,7 +3842,7 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
else if (lt->isVectorTy())
strct = ctx.builder.CreateInsertElement(strct, fval, ConstantInt::get(getInt32Ty(ctx.builder.getContext()), llvm_idx));
else if (lt->isAggregateType())
strct = ctx.builder.CreateInsertValue(strct, fval, makeArrayRef(llvm_idx));
strct = ctx.builder.CreateInsertValue(strct, fval, ArrayRef<unsigned>(llvm_idx));
else
assert(false);
}
Expand All @@ -3856,7 +3856,7 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
int fsz = jl_field_size(sty, i) - 1;
unsigned llvm_idx = convert_struct_offset(ctx, cast<StructType>(lt), offs + fsz);
if (init_as_value)
strct = ctx.builder.CreateInsertValue(strct, ConstantInt::get(getInt8Ty(ctx.builder.getContext()), 0), makeArrayRef(llvm_idx));
strct = ctx.builder.CreateInsertValue(strct, ConstantInt::get(getInt8Ty(ctx.builder.getContext()), 0), ArrayRef<unsigned>(llvm_idx));
else {
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_unionselbyte);
ai.decorateInst(ctx.builder.CreateAlignedStore(
Expand Down
Loading