-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Support LLVM 14 (upstream Git main
)
#43628
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,8 +223,7 @@ static GlobalVariable *emit_plt_thunk( | |
// NoReturn function can trigger LLVM verifier error when declared as | ||
// MustTail since other passes might replace the `ret` with | ||
// `unreachable` (LLVM should probably accept `unreachable`). | ||
if (attrs.hasAttribute(AttributeList::FunctionIndex, | ||
Attribute::NoReturn)) { | ||
if (hasFnAttr(attrs, Attribute::NoReturn)) { | ||
irbuilder.CreateUnreachable(); | ||
} | ||
else { | ||
|
@@ -272,7 +271,7 @@ static Value *emit_plt( | |
functype, attrs, cc, f_lib, f_name, libptrgv, llvmgv, runtime_lib); | ||
} | ||
GlobalVariable *got = prepare_global_in(jl_Module, sharedgot); | ||
LoadInst *got_val = ctx.builder.CreateAlignedLoad(got, Align(sizeof(void*))); | ||
LoadInst *got_val = ctx.builder.CreateAlignedLoad(got->getType()->getElementType(), got, Align(sizeof(void*))); | ||
// See comment in `runtime_sym_lookup` above. This in principle needs a | ||
// consume ordering too. This is even less likely to cause issues though | ||
// since the only thing we do to this loaded pointer is to call it | ||
|
@@ -404,7 +403,7 @@ static Value *llvm_type_rewrite( | |
to = emit_bitcast(ctx, from, target_type->getPointerTo()); | ||
} | ||
ctx.builder.CreateAlignedStore(v, from, Align(align)); | ||
return ctx.builder.CreateAlignedLoad(to, Align(align)); | ||
return ctx.builder.CreateAlignedLoad(target_type, to, Align(align)); | ||
} | ||
|
||
// --- argument passing and scratch space utilities --- | ||
|
@@ -422,8 +421,7 @@ static Value *runtime_apply_type_env(jl_codectx_t &ctx, jl_value_t *ty) | |
ConstantInt::get(T_size, sizeof(jl_svec_t) / sizeof(jl_value_t*))) | ||
}; | ||
auto call = ctx.builder.CreateCall(prepare_call(jlapplytype_func), makeArrayRef(args)); | ||
call->addAttribute(AttributeList::ReturnIndex, | ||
Attribute::getWithAlignment(jl_LLVMContext, Align(16))); | ||
addRetAttr(call, Attribute::getWithAlignment(jl_LLVMContext, Align(16))); | ||
return call; | ||
} | ||
|
||
|
@@ -1125,16 +1123,13 @@ std::string generate_func_sig(const char *fname) | |
const auto &as = paramattrs.at(i); | ||
if (!as.hasAttributes()) | ||
continue; | ||
attributes = attributes.addAttributes(jl_LLVMContext, i + 1, as); | ||
attributes = addAttributesAtIndex(attributes, jl_LLVMContext, i + 1, as); | ||
} | ||
// If return value is boxed it must be non-null. | ||
if (retboxed) | ||
attributes = attributes.addAttribute(jl_LLVMContext, AttributeList::ReturnIndex, | ||
Attribute::NonNull); | ||
attributes = addRetAttribute(attributes, jl_LLVMContext, Attribute::NonNull); | ||
if (rt == jl_bottom_type) { | ||
attributes = attributes.addAttribute(jl_LLVMContext, | ||
AttributeList::FunctionIndex, | ||
Attribute::NoReturn); | ||
attributes = addFnAttribute(attributes, jl_LLVMContext, Attribute::NoReturn); | ||
} | ||
return ""; | ||
} | ||
|
@@ -1487,8 +1482,8 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs) | |
JL_GC_POP(); | ||
Value *ptask_i16 = emit_bitcast(ctx, get_current_task(ctx), T_pint16); | ||
const int tid_offset = offsetof(jl_task_t, tid); | ||
Value *ptid = ctx.builder.CreateInBoundsGEP(ptask_i16, ConstantInt::get(T_size, tid_offset / sizeof(int16_t))); | ||
LoadInst *tid = ctx.builder.CreateAlignedLoad(ptid, Align(sizeof(int16_t))); | ||
Value *ptid = ctx.builder.CreateInBoundsGEP(T_int16, ptask_i16, ConstantInt::get(T_size, tid_offset / sizeof(int16_t))); | ||
LoadInst *tid = ctx.builder.CreateAlignedLoad(T_int16, ptid, Align(sizeof(int16_t))); | ||
tbaa_decorate(tbaa_gcframe, tid); | ||
return mark_or_box_ccall_result(ctx, tid, retboxed, rt, unionall, static_rt); | ||
} | ||
|
@@ -1500,8 +1495,8 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs) | |
JL_GC_POP(); | ||
Value *ptls_i32 = emit_bitcast(ctx, get_current_ptls(ctx), T_pint32); | ||
const int finh_offset = offsetof(jl_tls_states_t, finalizers_inhibited); | ||
Value *pfinh = ctx.builder.CreateInBoundsGEP(ptls_i32, ConstantInt::get(T_size, finh_offset / 4)); | ||
LoadInst *finh = ctx.builder.CreateAlignedLoad(pfinh, Align(sizeof(int32_t))); | ||
Value *pfinh = ctx.builder.CreateInBoundsGEP(T_int32, ptls_i32, ConstantInt::get(T_size, finh_offset / 4)); | ||
LoadInst *finh = ctx.builder.CreateAlignedLoad(T_int32, pfinh, Align(sizeof(int32_t))); | ||
Value *newval; | ||
if (is_libjulia_func(jl_gc_disable_finalizers_internal)) { | ||
newval = ctx.builder.CreateAdd(finh, ConstantInt::get(T_int32, 1)); | ||
|
@@ -1527,7 +1522,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs) | |
JL_GC_POP(); | ||
Value *ptls_pv = emit_bitcast(ctx, get_current_ptls(ctx), T_ppjlvalue); | ||
const int nt_offset = offsetof(jl_tls_states_t, next_task); | ||
Value *pnt = ctx.builder.CreateInBoundsGEP(ptls_pv, ConstantInt::get(T_size, nt_offset / sizeof(void*))); | ||
Value *pnt = ctx.builder.CreateInBoundsGEP(T_pjlvalue, ptls_pv, ConstantInt::get(T_size, nt_offset / sizeof(void*))); | ||
ctx.builder.CreateStore(emit_pointer_from_objref(ctx, boxed(ctx, argv[0])), pnt); | ||
return ghostValue(jl_nothing_type); | ||
} | ||
|
@@ -1537,7 +1532,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs) | |
JL_GC_POP(); | ||
ctx.builder.CreateCall(prepare_call(gcroot_flush_func)); | ||
Value *pdefer_sig = emit_defer_signal(ctx); | ||
Value *defer_sig = ctx.builder.CreateLoad(pdefer_sig); | ||
Value *defer_sig = ctx.builder.CreateLoad(T_sigatomic, pdefer_sig); | ||
defer_sig = ctx.builder.CreateAdd(defer_sig, ConstantInt::get(T_sigatomic, 1)); | ||
ctx.builder.CreateStore(defer_sig, pdefer_sig); | ||
emit_signal_fence(ctx); | ||
|
@@ -1549,7 +1544,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs) | |
JL_GC_POP(); | ||
ctx.builder.CreateCall(prepare_call(gcroot_flush_func)); | ||
Value *pdefer_sig = emit_defer_signal(ctx); | ||
Value *defer_sig = ctx.builder.CreateLoad(pdefer_sig); | ||
Value *defer_sig = ctx.builder.CreateLoad(T_sigatomic, pdefer_sig); | ||
emit_signal_fence(ctx); | ||
error_unless(ctx, | ||
ctx.builder.CreateICmpNE(defer_sig, ConstantInt::get(T_sigatomic, 0)), | ||
|
@@ -1566,6 +1561,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs) | |
checkBB, contBB); | ||
ctx.builder.SetInsertPoint(checkBB); | ||
ctx.builder.CreateLoad( | ||
T_size, | ||
ctx.builder.CreateConstInBoundsGEP1_32(T_size, get_current_signal_page(ctx), -1), | ||
true); | ||
ctx.builder.CreateBr(contBB); | ||
|
@@ -1725,8 +1721,8 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs) | |
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 *ph2 = ctx.builder.CreateInBoundsGEP(ph1, ConstantInt::get(T_size, hash_offset / sizeof(size_t))); | ||
LoadInst *hashval = ctx.builder.CreateAlignedLoad(ph2, Align(sizeof(size_t))); | ||
Value *ph2 = ctx.builder.CreateInBoundsGEP(T_size, ph1, ConstantInt::get(T_size, hash_offset / sizeof(size_t))); | ||
LoadInst *hashval = ctx.builder.CreateAlignedLoad(T_size, ph2, Align(sizeof(size_t))); | ||
tbaa_decorate(tbaa_const, hashval); | ||
return mark_or_box_ccall_result(ctx, hashval, retboxed, rt, unionall, static_rt); | ||
} | ||
|
@@ -1951,7 +1947,7 @@ jl_cgval_t function_sig_t::emit_a_ccall( | |
// something alloca'd above is SSA | ||
if (static_rt) | ||
return mark_julia_slot(result, rt, NULL, tbaa_stack); | ||
result = ctx.builder.CreateLoad(result); | ||
result = ctx.builder.CreateLoad(cast<PointerType>(result->getType())->getElementType(), result); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would require some restructuring of |
||
} | ||
} | ||
else { | ||
|
Uh oh!
There was an error while loading. Please reload this page.