Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d534080
Adapt to "CodeGen: Avoid using MachineFunction::getMMI in MachineModu…
Zentrik Feb 10, 2025
d2c8ae3
Adapt to "[DataLayout] Remove clear and reset methods (NFC) (#102993)"
Zentrik Feb 10, 2025
8de4aae
Adapt to "[DebugInfo] Enable deprecation of iterator-insertion method…
Zentrik Feb 10, 2025
82edf1c
Adapt to "[NFC] Move intrinsic related functions to Intrinsic namespa…
Zentrik Feb 10, 2025
8fd7701
Adapt to "[NFC] Rename Intrinsic::getDeclaration to getOrInsertDeclar…
Zentrik Feb 10, 2025
599fdd6
Adapt to "[PassBuilder] Add ThinOrFullLTOPhase to early simplication …
Zentrik Feb 10, 2025
4a7d193
Adapt to "[PassBuilder] Add ThinOrFullLTOPhase to optimizer pipeline …
Zentrik Feb 10, 2025
e46fa35
Adapt to "[llvm] Deprecate Type::getPointerTo() (#113331)"
Zentrik Feb 10, 2025
b7c9384
Adapt to "[ORC] Move absoluteSymbols from Core.h to new AbsoluteSymbo…
Zentrik Feb 10, 2025
d70f5be
Rename `LLVMTargetMachine` to `CodeGenCommonTMImpl`
Zentrik Feb 10, 2025
532e1cd
Adapt to "[PowerPC] Update data layout aligment of i128 to 16 (#118004)"
Zentrik Feb 10, 2025
8b56b2e
fixup! Adapt to "[ORC] Move absoluteSymbols from Core.h to new Absolu…
Zentrik Feb 11, 2025
12b40d3
fixup! Adapt to "[DebugInfo] Enable deprecation of iterator-insertion…
Zentrik Feb 11, 2025
bc17490
fixup! Adapt to "CodeGen: Avoid using MachineFunction::getMMI in Mach…
Zentrik Feb 11, 2025
a655889
fixup! Adapt to "[DebugInfo] Enable deprecation of iterator-insertion…
Zentrik Feb 11, 2025
b73126e
fixup! fixup! Adapt to "[DebugInfo] Enable deprecation of iterator-in…
Zentrik Feb 11, 2025
01a29cc
Merge branch 'master' into llvm-20-initial
Zentrik Feb 23, 2025
01d2eea
Merge branch 'master' into llvm-20-initial
giordano Feb 26, 2025
d70d523
Merge branch 'master' into llvm-20-initial
Zentrik Feb 27, 2025
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
10 changes: 5 additions & 5 deletions src/aotcompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@ static void construct_vars(Module &M, Partition &partition, StringRef suffix) {

// Now commit the fvars, gvars, and idxs
auto T_size = M.getDataLayout().getIntPtrType(M.getContext());
emit_table(M, fvars, "jl_fvars", T_size->getPointerTo());
emit_table(M, fvars, "jl_fvars", PointerType::getUnqual(T_size->getContext()));
emit_offset_table(M, T_size, gvars, "jl_gvar", suffix);
auto fidxs = ConstantDataArray::get(M.getContext(), fvar_idxs);
auto fidxs_var = new GlobalVariable(M, fidxs->getType(), true,
Expand Down Expand Up @@ -2065,7 +2065,7 @@ void jl_dump_native_impl(void *native_code,
dataM.setPICLevel(PICLevel::BigPIC);
auto &Context = dataM.getContext();

Type *T_psize = dataM.getDataLayout().getIntPtrType(Context)->getPointerTo();
Type *T_psize = PointerType::getUnqual(Context);

// This should really be in jl_create_native, but we haven't
// yet set the target triple binary format correctly at that
Expand Down Expand Up @@ -2171,10 +2171,10 @@ void jl_dump_native_impl(void *native_code,
GlobalValue *jlRTLD_DEFAULT_var = jl_emit_RTLD_DEFAULT_var(&metadataM);

Type *T_size = DL.getIntPtrType(Context);
Type *T_psize = T_size->getPointerTo();
Type *T_psize = PointerType::getUnqual(T_size->getContext());
Type *T_ptr = PointerType::get(Context, 0);

auto FT = FunctionType::get(Type::getInt8Ty(Context)->getPointerTo()->getPointerTo(), {}, false);
auto FT = FunctionType::get(PointerType::getUnqual(Context), {}, false);
auto F = Function::Create(FT, Function::ExternalLinkage, "get_jl_RTLD_DEFAULT_handle_addr", metadataM);
llvm::IRBuilder<> builder(BasicBlock::Create(Context, "top", F));
builder.CreateRet(jlRTLD_DEFAULT_var);
Expand All @@ -2186,7 +2186,7 @@ void jl_dump_native_impl(void *native_code,
// Windows expect that the function `_DllMainStartup` is present in an dll.
// Normal compilers use something like Zig's crtdll.c instead we provide a
// a stub implementation.
auto T_pvoid = Type::getInt8Ty(Context)->getPointerTo();
auto T_pvoid = PointerType::getUnqual(Context);
auto T_int32 = Type::getInt32Ty(Context);
auto FT = FunctionType::get(T_int32, {T_pvoid, T_int32, T_pvoid}, false);
auto F = Function::Create(FT, Function::ExternalLinkage, "_DllMainCRTStartup", metadataM);
Expand Down
18 changes: 13 additions & 5 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static bool runtime_sym_gvs(jl_codectx_t &ctx, const char *f_lib, const char *f_
name += f_name;
name += "_";
name += std::to_string(jl_atomic_fetch_add_relaxed(&globalUniqueGeneratedNames, 1));
auto T_pvoidfunc = JuliaType::get_pvoidfunc_ty(M->getContext());
auto T_pvoidfunc = getPointerTy(M->getContext());
llvmgv = new GlobalVariable(*M, T_pvoidfunc, false,
GlobalVariable::ExternalLinkage,
Constant::getNullValue(T_pvoidfunc), name);
Expand Down Expand Up @@ -133,7 +133,7 @@ static Value *runtime_sym_lookup(
// *llvmgv = jl_load_and_lookup(f_lib, f_name, libptrgv);
// }
// return (*llvmgv)
auto T_pvoidfunc = JuliaType::get_pvoidfunc_ty(irbuilder.getContext());
auto T_pvoidfunc = getPointerTy(irbuilder.getContext());
BasicBlock *enter_bb = irbuilder.GetInsertBlock();
BasicBlock *dlsym_lookup = BasicBlock::Create(irbuilder.getContext(), "dlsym");
BasicBlock *ccall_bb = BasicBlock::Create(irbuilder.getContext(), "ccall");
Expand Down Expand Up @@ -197,7 +197,7 @@ static Value *runtime_sym_lookup(
PointerType *funcptype, const char *f_lib, jl_value_t *lib_expr,
const char *f_name, Function *f)
{
auto T_pvoidfunc = JuliaType::get_pvoidfunc_ty(ctx.builder.getContext());
auto T_pvoidfunc = getPointerTy(ctx.builder.getContext());
GlobalVariable *libptrgv;
GlobalVariable *llvmgv;
bool runtime_lib;
Expand Down Expand Up @@ -244,7 +244,7 @@ static GlobalVariable *emit_plt_thunk(
plt->setAttributes(attrs);
if (cc != CallingConv::C)
plt->setCallingConv(cc);
auto T_pvoidfunc = JuliaType::get_pvoidfunc_ty(M->getContext());
auto T_pvoidfunc = getPointerTy(M->getContext());
GlobalVariable *got = new GlobalVariable(*M, T_pvoidfunc, false,
GlobalVariable::ExternalLinkage,
plt,
Expand Down Expand Up @@ -2099,7 +2099,11 @@ jl_cgval_t function_sig_t::emit_a_ccall(
}
else if (f_name.starts_with("llvm.")) {
// compute and verify auto-mangling for intrinsic name
#if JL_LLVM_VERSION >= 200000
auto ID = Intrinsic::lookupIntrinsicID(f_name);
#else
auto ID = Function::lookupIntrinsicID(f_name);
#endif
if (ID != Intrinsic::not_intrinsic) {
// Accumulate an array of overloaded types for the given intrinsic
// and compute the new name mangling schema
Expand All @@ -2111,7 +2115,11 @@ jl_cgval_t function_sig_t::emit_a_ccall(
if (res == Intrinsic::MatchIntrinsicTypes_Match) {
bool matchvararg = !Intrinsic::matchIntrinsicVarArg(functype->isVarArg(), TableRef);
if (matchvararg) {
#if JL_LLVM_VERSION >= 200000
Function *intrinsic = Intrinsic::getOrInsertDeclaration(jl_Module, ID, overloadTys);
#else
Function *intrinsic = Intrinsic::getDeclaration(jl_Module, ID, overloadTys);
#endif
assert(intrinsic->getFunctionType() == functype);
if (intrinsic->getName() == f_name || Intrinsic::getBaseName(ID) == f_name)
llvmf = intrinsic;
Expand All @@ -2132,7 +2140,7 @@ jl_cgval_t function_sig_t::emit_a_ccall(
}
else if (symarg.fptr != NULL) {
++LiteralCCalls;
Type *funcptype = functype->getPointerTo(0);
Type *funcptype = PointerType::getUnqual(functype->getContext());
llvmf = literal_static_pointer_val((void*)(uintptr_t)symarg.fptr, funcptype);
setName(ctx.emission_context, llvmf, "ccall_fptr");
}
Expand Down
32 changes: 30 additions & 2 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static Value *stringConstPtr(
// Doesn't need to be aligned, we shouldn't operate on these like julia objects
GlobalVariable *gv = get_pointer_to_constant(emission_context, Data, Align(1), "_j_str_" + StringRef(ctxt.data(), ctxt.size()), *M);
// AddrSpaceCast in case globals are in non-0 AS
return irbuilder.CreateAddrSpaceCast(gv, gv->getValueType()->getPointerTo(0));
return irbuilder.CreateAddrSpaceCast(gv, PointerType::getUnqual(gv->getContext()));
}


Expand Down Expand Up @@ -1336,7 +1336,7 @@ static Value *emit_typeof(jl_codectx_t &ctx, const jl_cgval_t &p, bool maybenull
Value *tindex = ctx.builder.CreateAnd(p.TIndex, ConstantInt::get(getInt8Ty(ctx.builder.getContext()), 0x7f));
bool allunboxed = is_uniontype_allunboxed(p.typ);
Type *expr_type = justtag ? ctx.types().T_size : ctx.types().T_pjlvalue;
Value *datatype_or_p = Constant::getNullValue(expr_type->getPointerTo());
Value *datatype_or_p = Constant::getNullValue(PointerType::getUnqual(expr_type->getContext()));
unsigned counter = 0;
for_each_uniontype_small(
[&](unsigned idx, jl_datatype_t *jt) {
Expand Down Expand Up @@ -3666,7 +3666,11 @@ static Value *box_union(jl_codectx_t &ctx, const jl_cgval_t &vinfo, const SmallB
ctx.builder.CreateBr(postBB);
}
else if (!vinfo.Vboxed) {
#if JL_LLVM_VERSION >= 200000
Function *trap_func = Intrinsic::getOrInsertDeclaration(
#else
Function *trap_func = Intrinsic::getDeclaration(
#endif
ctx.f->getParent(),
Intrinsic::trap);
ctx.builder.CreateCall(trap_func);
Expand Down Expand Up @@ -3710,7 +3714,11 @@ static Function *mangleIntrinsic(IntrinsicInst *call) //mangling based on replac
assert(matchvararg);
(void)matchvararg;
}
#if JL_LLVM_VERSION >= 200000
auto newF = Intrinsic::getOrInsertDeclaration(call->getModule(), ID, overloadTys);
#else
auto newF = Intrinsic::getDeclaration(call->getModule(), ID, overloadTys);
#endif
assert(newF->getFunctionType() == newfType);
newF->setCallingConv(call->getCallingConv());
return newF;
Expand Down Expand Up @@ -3846,7 +3854,11 @@ static void emit_unionmove(jl_codectx_t &ctx, Value *dest, MDNode *tbaa_dst, con
if (nb > 0) {
if (!src_ptr) {
Function *trap_func =
#if JL_LLVM_VERSION >= 200000
Intrinsic::getOrInsertDeclaration(ctx.f->getParent(), Intrinsic::trap);
#else
Intrinsic::getDeclaration(ctx.f->getParent(), Intrinsic::trap);
#endif
ctx.builder.CreateCall(trap_func);
ctx.builder.CreateUnreachable();
return;
Expand All @@ -3861,7 +3873,11 @@ static void emit_unionmove(jl_codectx_t &ctx, Value *dest, MDNode *tbaa_dst, con
counter);
ctx.builder.SetInsertPoint(defaultBB);
if (!skip && allunboxed && (src.V == NULL || isa<AllocaInst>(src.V))) {
#if JL_LLVM_VERSION >= 200000
Function *trap_func = Intrinsic::getOrInsertDeclaration(
#else
Function *trap_func = Intrinsic::getDeclaration(
#endif
ctx.f->getParent(),
Intrinsic::trap);
ctx.builder.CreateCall(trap_func);
Expand Down Expand Up @@ -4547,14 +4563,22 @@ static jl_cgval_t emit_memorynew(jl_codectx_t &ctx, jl_datatype_t *typ, jl_cgval
auto cg_typ = literal_pointer_val(ctx, (jl_value_t*) typ);
auto cg_elsz = ConstantInt::get(T_size, elsz);

#if JL_LLVM_VERSION >= 200000
FunctionCallee intr = Intrinsic::getOrInsertDeclaration(jl_Module, Intrinsic::smul_with_overflow, ArrayRef<Type*>(T_size));
#else
FunctionCallee intr = Intrinsic::getDeclaration(jl_Module, Intrinsic::smul_with_overflow, ArrayRef<Type*>(T_size));
#endif
// compute nbytes with possible overflow
Value *prod_with_overflow = ctx.builder.CreateCall(intr, {nel_unboxed, cg_elsz});
Value *nbytes = ctx.builder.CreateExtractValue(prod_with_overflow, 0);
Value *overflow = ctx.builder.CreateExtractValue(prod_with_overflow, 1);
if (isunion) {
// if isunion, we need to allocate the union selector bytes as well
#if JL_LLVM_VERSION >= 200000
intr = Intrinsic::getOrInsertDeclaration(jl_Module, Intrinsic::sadd_with_overflow, ArrayRef<Type*>(T_size));
#else
intr = Intrinsic::getDeclaration(jl_Module, Intrinsic::sadd_with_overflow, ArrayRef<Type*>(T_size));
#endif
Value *add_with_overflow = ctx.builder.CreateCall(intr, {nel_unboxed, nbytes});
nbytes = ctx.builder.CreateExtractValue(add_with_overflow, 0);
Value *overflow1 = ctx.builder.CreateExtractValue(add_with_overflow, 1);
Expand Down Expand Up @@ -4682,7 +4706,11 @@ static jl_cgval_t emit_memoryref(jl_codectx_t &ctx, const jl_cgval_t &ref, jl_cg
Value *boffset;
#if 0
if (bc) {
#if JL_LLVM_VERSION >= 200000
auto *MulF = Intrinsic::getOrInsertDeclaration(jl_Module, Intrinsic::smul_with_overflow, offset->getType());
#else
auto *MulF = Intrinsic::getDeclaration(jl_Module, Intrinsic::smul_with_overflow, offset->getType());
#endif
CallInst *Mul = ctx.builder.CreateCall(MulF, {offset, elsz});
boffset = ctx.builder.CreateExtractValue(Mul, 0);
ovflw = ctx.builder.CreateExtractValue(Mul, 1);
Expand Down
Loading