mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
fix warnings from deprecated llvm ptr type
This commit is contained in:
parent
8090e99e75
commit
1519e5f833
11 changed files with 109 additions and 218 deletions
|
@ -33,8 +33,8 @@ use inkwell::values::{
|
|||
FunctionValue, InstructionOpcode, InstructionValue, IntMathValue, IntValue, PhiValue,
|
||||
PointerMathValue, PointerValue, StructValue,
|
||||
};
|
||||
use inkwell::FloatPredicate;
|
||||
use inkwell::{AddressSpace, IntPredicate};
|
||||
use inkwell::{FloatPredicate, OptimizationLevel};
|
||||
use morphic_lib::{
|
||||
CalleeSpecVar, FuncName, FuncSpec, FuncSpecSolutions, ModSolutions, UpdateMode, UpdateModeVar,
|
||||
};
|
||||
|
@ -1173,8 +1173,8 @@ fn promote_to_wasm_test_wrapper<'a, 'ctx>(
|
|||
let roc_main_fn = function_value_by_func_spec(env, FuncBorrowSpec::Some(*func_spec), symbol);
|
||||
|
||||
let output_type = match roc_main_fn.get_type().get_return_type() {
|
||||
Some(return_type) => {
|
||||
let output_type = return_type.ptr_type(AddressSpace::default());
|
||||
Some(..) => {
|
||||
let output_type = env.context.ptr_type(AddressSpace::default());
|
||||
output_type.into()
|
||||
}
|
||||
None => {
|
||||
|
@ -1367,7 +1367,7 @@ fn small_str_ptr_width_8<'ctx>(env: &Env<'_, 'ctx, '_>, str_literal: &str) -> Po
|
|||
let cap = env.ptr_int().const_int(word3, false);
|
||||
|
||||
let address_space = AddressSpace::default();
|
||||
let ptr_type = env.context.i8_type().ptr_type(address_space);
|
||||
let ptr_type = env.context.ptr_type(address_space);
|
||||
let ptr = env.builder.new_build_int_to_ptr(ptr, ptr_type, "to_u8_ptr");
|
||||
|
||||
const_str_alloca_ptr(env, ptr, len, cap)
|
||||
|
@ -1391,7 +1391,7 @@ fn small_str_ptr_width_4<'ctx>(env: &Env<'_, 'ctx, '_>, str_literal: &str) -> St
|
|||
let cap = env.ptr_int().const_int(word3 as u64, false);
|
||||
|
||||
let address_space = AddressSpace::default();
|
||||
let ptr_type = env.context.i8_type().ptr_type(address_space);
|
||||
let ptr_type = env.context.ptr_type(address_space);
|
||||
let ptr = env.builder.new_build_int_to_ptr(ptr, ptr_type, "to_u8_ptr");
|
||||
|
||||
struct_from_fields(
|
||||
|
@ -1530,7 +1530,7 @@ fn struct_pointer_from_fields<'a, 'ctx, 'env, I>(
|
|||
.builder
|
||||
.new_build_bitcast(
|
||||
input_pointer,
|
||||
struct_type.ptr_type(AddressSpace::default()),
|
||||
env.context.ptr_type(AddressSpace::default()),
|
||||
"struct_ptr",
|
||||
)
|
||||
.into_pointer_value();
|
||||
|
@ -1868,7 +1868,7 @@ pub(crate) fn build_exp_expr<'a, 'ctx>(
|
|||
|
||||
let data_ptr = env.builder.new_build_pointer_cast(
|
||||
opaque_data_ptr,
|
||||
struct_type.ptr_type(AddressSpace::default()),
|
||||
env.context.ptr_type(AddressSpace::default()),
|
||||
"to_data_pointer",
|
||||
);
|
||||
|
||||
|
@ -2222,7 +2222,7 @@ fn build_tag_field_value<'a, 'ctx>(
|
|||
env.builder
|
||||
.new_build_pointer_cast(
|
||||
value.into_pointer_value(),
|
||||
env.context.i64_type().ptr_type(AddressSpace::default()),
|
||||
env.context.ptr_type(AddressSpace::default()),
|
||||
"cast_recursive_pointer",
|
||||
)
|
||||
.into()
|
||||
|
@ -2395,7 +2395,7 @@ fn build_tag<'a, 'ctx>(
|
|||
RocUnion::untagged_from_slices(layout_interner, env.context, &[other_fields]);
|
||||
|
||||
if tag_id == *nullable_id as u16 {
|
||||
let output_type = roc_union.struct_type().ptr_type(AddressSpace::default());
|
||||
let output_type = env.context.ptr_type(AddressSpace::default());
|
||||
|
||||
return output_type.const_null().into();
|
||||
}
|
||||
|
@ -2445,7 +2445,7 @@ fn tag_pointer_set_tag_id<'ctx>(
|
|||
|
||||
let cast_pointer = env.builder.new_build_pointer_cast(
|
||||
pointer,
|
||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
||||
env.context.ptr_type(AddressSpace::default()),
|
||||
"cast_to_i8_ptr",
|
||||
);
|
||||
|
||||
|
@ -2504,7 +2504,7 @@ pub fn tag_pointer_clear_tag_id<'ctx>(
|
|||
|
||||
let cast_pointer = env.builder.new_build_pointer_cast(
|
||||
pointer,
|
||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
||||
env.context.ptr_type(AddressSpace::default()),
|
||||
"cast_to_i8_ptr",
|
||||
);
|
||||
|
||||
|
@ -2718,7 +2718,7 @@ fn union_field_ptr_at_index_help<'a, 'ctx>(
|
|||
|
||||
let data_ptr = env.builder.new_build_pointer_cast(
|
||||
value,
|
||||
struct_type.ptr_type(AddressSpace::default()),
|
||||
env.context.ptr_type(AddressSpace::default()),
|
||||
"cast_lookup_at_index_ptr",
|
||||
);
|
||||
|
||||
|
@ -2769,17 +2769,11 @@ fn reserve_with_refcount_union_as_block_of_memory<'a, 'ctx>(
|
|||
RocUnion::untagged_from_slices(layout_interner, env.context, fields)
|
||||
};
|
||||
|
||||
reserve_union_with_refcount_help(
|
||||
env,
|
||||
roc_union.struct_type(),
|
||||
roc_union.tag_width(),
|
||||
roc_union.tag_alignment(),
|
||||
)
|
||||
reserve_union_with_refcount_help(env, roc_union.tag_width(), roc_union.tag_alignment())
|
||||
}
|
||||
|
||||
fn reserve_union_with_refcount_help<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
basic_type: impl BasicType<'ctx>,
|
||||
fn reserve_union_with_refcount_help<'ctx>(
|
||||
env: &Env<'_, 'ctx, '_>,
|
||||
stack_size: u32,
|
||||
alignment_bytes: u32,
|
||||
) -> PointerValue<'ctx> {
|
||||
|
@ -2789,18 +2783,11 @@ fn reserve_union_with_refcount_help<'a, 'ctx, 'env>(
|
|||
|
||||
// elem_refcounted does not apply to unions, only lists.
|
||||
let elem_refcounted = env.context.bool_type().const_zero().into();
|
||||
allocate_with_refcount_help(
|
||||
env,
|
||||
basic_type,
|
||||
alignment_bytes,
|
||||
value_bytes_intvalue,
|
||||
elem_refcounted,
|
||||
)
|
||||
allocate_with_refcount_help(env, alignment_bytes, value_bytes_intvalue, elem_refcounted)
|
||||
}
|
||||
|
||||
pub fn allocate_with_refcount_help<'a, 'ctx, 'env>(
|
||||
env: &Env<'a, 'ctx, 'env>,
|
||||
value_type: impl BasicType<'ctx>,
|
||||
pub fn allocate_with_refcount_help<'ctx>(
|
||||
env: &Env<'_, 'ctx, '_>,
|
||||
alignment_bytes: u32,
|
||||
number_of_data_bytes: IntValue<'ctx>,
|
||||
elem_refcounted: BasicValueEnum<'ctx>,
|
||||
|
@ -2816,7 +2803,7 @@ pub fn allocate_with_refcount_help<'a, 'ctx, 'env>(
|
|||
)
|
||||
.into_pointer_value();
|
||||
|
||||
let ptr_type = value_type.ptr_type(AddressSpace::default());
|
||||
let ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||
|
||||
env.builder
|
||||
.new_build_pointer_cast(ptr, ptr_type, "alloc_cast_to_desired")
|
||||
|
@ -3043,9 +3030,7 @@ pub fn store_roc_value_opaque<'a, 'ctx>(
|
|||
opaque_destination: PointerValue<'ctx>,
|
||||
value: BasicValueEnum<'ctx>,
|
||||
) {
|
||||
let target_type =
|
||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(layout))
|
||||
.ptr_type(AddressSpace::default());
|
||||
let target_type = env.context.ptr_type(AddressSpace::default());
|
||||
let destination = env.builder.new_build_pointer_cast(
|
||||
opaque_destination,
|
||||
target_type,
|
||||
|
@ -3929,7 +3914,7 @@ fn complex_bitcast_from_bigger_than_to<'ctx>(
|
|||
// then read it back as a different type
|
||||
let to_type_pointer = builder.new_build_pointer_cast(
|
||||
argument_pointer,
|
||||
to_type.ptr_type(inkwell::AddressSpace::default()),
|
||||
env.context.ptr_type(inkwell::AddressSpace::default()),
|
||||
name,
|
||||
);
|
||||
|
||||
|
@ -3951,9 +3936,7 @@ fn complex_bitcast_to_bigger_than_from<'ctx>(
|
|||
// then cast the pointer to our desired type
|
||||
let from_type_pointer = builder.new_build_pointer_cast(
|
||||
storage,
|
||||
from_value
|
||||
.get_type()
|
||||
.ptr_type(inkwell::AddressSpace::default()),
|
||||
env.context.ptr_type(inkwell::AddressSpace::default()),
|
||||
name,
|
||||
);
|
||||
|
||||
|
@ -4320,8 +4303,8 @@ fn expose_function_to_host_help_c_abi_generic<'a, 'ctx>(
|
|||
let output_type = roc_function.get_type().get_param_types().pop().unwrap();
|
||||
argument_types.insert(0, output_type);
|
||||
}
|
||||
Some(return_type) => {
|
||||
let output_type = return_type.ptr_type(AddressSpace::default());
|
||||
Some(..) => {
|
||||
let output_type = env.context.ptr_type(AddressSpace::default());
|
||||
argument_types.insert(0, output_type.into());
|
||||
}
|
||||
}
|
||||
|
@ -4373,7 +4356,7 @@ fn expose_function_to_host_help_c_abi_generic<'a, 'ctx>(
|
|||
// bitcast the ptr
|
||||
let fastcc_ptr = env.builder.new_build_pointer_cast(
|
||||
arg.into_pointer_value(),
|
||||
fastcc_type.ptr_type(AddressSpace::default()),
|
||||
env.context.ptr_type(AddressSpace::default()),
|
||||
"bitcast_arg",
|
||||
);
|
||||
|
||||
|
@ -4514,7 +4497,7 @@ fn expose_function_to_host_help_c_abi_gen_test<'a, 'ctx>(
|
|||
let return_type = wrapper_return_type;
|
||||
|
||||
let c_function_spec = {
|
||||
let output_type = return_type.ptr_type(AddressSpace::default());
|
||||
let output_type = env.context.ptr_type(AddressSpace::default());
|
||||
argument_types.push(output_type.into());
|
||||
FunctionSpec::cconv(env, CCReturn::Void, None, &argument_types)
|
||||
};
|
||||
|
@ -4690,10 +4673,7 @@ fn expose_function_to_host_help_c_abi_v2<'a, 'ctx>(
|
|||
|
||||
let c_abi_roc_str_type = env.context.struct_type(
|
||||
&[
|
||||
env.context
|
||||
.i8_type()
|
||||
.ptr_type(AddressSpace::default())
|
||||
.into(),
|
||||
env.context.ptr_type(AddressSpace::default()).into(),
|
||||
env.ptr_int().into(),
|
||||
env.ptr_int().into(),
|
||||
],
|
||||
|
@ -4834,7 +4814,7 @@ fn expose_function_to_host_help_c_abi_v2<'a, 'ctx>(
|
|||
// bitcast the ptr
|
||||
let fastcc_ptr = env.builder.new_build_pointer_cast(
|
||||
arg.into_pointer_value(),
|
||||
fastcc_type.ptr_type(AddressSpace::default()),
|
||||
env.context.ptr_type(AddressSpace::default()),
|
||||
"bitcast_arg",
|
||||
);
|
||||
|
||||
|
@ -5024,7 +5004,7 @@ pub fn get_sjlj_buffer<'ctx>(env: &Env<'_, 'ctx, '_>) -> PointerValue<'ctx> {
|
|||
|
||||
env.builder.new_build_pointer_cast(
|
||||
global.as_pointer_value(),
|
||||
env.context.i32_type().ptr_type(AddressSpace::default()),
|
||||
env.context.ptr_type(AddressSpace::default()),
|
||||
"cast_sjlj_buffer",
|
||||
)
|
||||
}
|
||||
|
@ -5041,15 +5021,11 @@ pub fn build_setjmp_call<'ctx>(env: &Env<'_, 'ctx, '_>) -> BasicValueEnum<'ctx>
|
|||
// Anywhere else, use the LLVM intrinsic.
|
||||
// https://llvm.org/docs/ExceptionHandling.html#llvm-eh-sjlj-setjmp
|
||||
|
||||
let buf_type = env
|
||||
.context
|
||||
.i8_type()
|
||||
.ptr_type(AddressSpace::default())
|
||||
.array_type(5);
|
||||
let buf_type = env.context.ptr_type(AddressSpace::default()).array_type(5);
|
||||
|
||||
let jmp_buf_i8p_arr = env.builder.new_build_pointer_cast(
|
||||
jmp_buf,
|
||||
buf_type.ptr_type(AddressSpace::default()),
|
||||
env.context.ptr_type(AddressSpace::default()),
|
||||
"jmp_buf [5 x i8*]",
|
||||
);
|
||||
|
||||
|
@ -5090,7 +5066,7 @@ pub fn build_setjmp_call<'ctx>(env: &Env<'_, 'ctx, '_>) -> BasicValueEnum<'ctx>
|
|||
.builder
|
||||
.new_build_pointer_cast(
|
||||
jmp_buf,
|
||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
||||
env.context.ptr_type(AddressSpace::default()),
|
||||
"jmp_buf i8*",
|
||||
)
|
||||
.into();
|
||||
|
@ -5262,7 +5238,7 @@ fn roc_call_result_type<'ctx>(
|
|||
env.context.struct_type(
|
||||
&[
|
||||
env.context.i64_type().into(),
|
||||
zig_str_type(env).ptr_type(AddressSpace::default()).into(),
|
||||
env.context.ptr_type(AddressSpace::default()).into(),
|
||||
return_type,
|
||||
],
|
||||
false,
|
||||
|
@ -5990,23 +5966,11 @@ fn build_closure_caller<'a, 'ctx>(
|
|||
) {
|
||||
let mut argument_types = Vec::with_capacity_in(arguments.len() + 3, env.arena);
|
||||
|
||||
for layout in arguments {
|
||||
let arg_type =
|
||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(*layout));
|
||||
let arg_ptr_type = arg_type.ptr_type(AddressSpace::default());
|
||||
|
||||
argument_types.push(arg_ptr_type.into());
|
||||
for _ in arguments {
|
||||
argument_types.push(env.context.ptr_type(AddressSpace::default()).into());
|
||||
}
|
||||
|
||||
let closure_argument_type = {
|
||||
let basic_type = basic_type_from_layout(
|
||||
env,
|
||||
layout_interner,
|
||||
layout_interner.get_repr(lambda_set.runtime_representation()),
|
||||
);
|
||||
|
||||
basic_type.ptr_type(AddressSpace::default())
|
||||
};
|
||||
let closure_argument_type = env.context.ptr_type(AddressSpace::default());
|
||||
argument_types.push(closure_argument_type.into());
|
||||
|
||||
let context = &env.context;
|
||||
|
@ -6015,7 +5979,7 @@ fn build_closure_caller<'a, 'ctx>(
|
|||
let result_type =
|
||||
basic_type_from_layout(env, layout_interner, layout_interner.get_repr(result));
|
||||
|
||||
let output_type = { result_type.ptr_type(AddressSpace::default()) };
|
||||
let output_type = { env.context.ptr_type(AddressSpace::default()) };
|
||||
argument_types.push(output_type.into());
|
||||
|
||||
// STEP 1: build function header
|
||||
|
@ -6264,7 +6228,7 @@ fn roc_call_erased_with_args<'a, 'ctx>(
|
|||
) -> BasicValueEnum<'ctx> {
|
||||
let function_type =
|
||||
fn_ptr::function_type(env, layout_interner, argument_layouts, result_layout);
|
||||
let function_ptr_type = function_type.ptr_type(AddressSpace::default());
|
||||
let function_ptr_type = env.context.ptr_type(AddressSpace::default());
|
||||
|
||||
let function_pointer = fn_ptr::cast_to_function_ptr_type(env, pointer, function_ptr_type);
|
||||
|
||||
|
@ -6486,7 +6450,7 @@ fn to_cc_type<'a, 'ctx>(
|
|||
let stack_type = basic_type_from_layout(env, layout_interner, layout_repr);
|
||||
|
||||
if layout_repr.is_passed_by_reference(layout_interner) {
|
||||
stack_type.ptr_type(AddressSpace::default()).into()
|
||||
env.context.ptr_type(AddressSpace::default()).into()
|
||||
} else {
|
||||
stack_type
|
||||
}
|
||||
|
@ -6506,18 +6470,7 @@ fn to_cc_type_builtin<'a, 'ctx>(
|
|||
Builtin::Int(_) | Builtin::Float(_) | Builtin::Bool | Builtin::Decimal => {
|
||||
basic_type_from_builtin(env, builtin)
|
||||
}
|
||||
Builtin::Str | Builtin::List(_) => {
|
||||
let address_space = AddressSpace::default();
|
||||
let field_types: [BasicTypeEnum; 3] = [
|
||||
env.context.i8_type().ptr_type(address_space).into(),
|
||||
env.ptr_int().into(),
|
||||
env.ptr_int().into(),
|
||||
];
|
||||
|
||||
let struct_type = env.context.struct_type(&field_types, false);
|
||||
|
||||
struct_type.ptr_type(address_space).into()
|
||||
}
|
||||
Builtin::Str | Builtin::List(_) => env.context.ptr_type(AddressSpace::default()).into(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6597,7 +6550,7 @@ impl<'ctx> FunctionSpec<'ctx> {
|
|||
let (typ, opt_sret_parameter) = match cc_return {
|
||||
CCReturn::ByPointer => {
|
||||
// turn the output type into a pointer type. Make it the first argument to the function
|
||||
let output_type = return_type.unwrap().ptr_type(AddressSpace::default());
|
||||
let output_type = env.context.ptr_type(AddressSpace::default());
|
||||
|
||||
let mut arguments: Vec<'_, BasicTypeEnum> =
|
||||
bumpalo::vec![in env.arena; output_type.into()];
|
||||
|
@ -6641,7 +6594,7 @@ impl<'ctx> FunctionSpec<'ctx> {
|
|||
return_type.fn_type(&function_arguments(env, &argument_types), false)
|
||||
}
|
||||
RocReturn::ByPointer => {
|
||||
argument_types.push(return_type.ptr_type(AddressSpace::default()).into());
|
||||
argument_types.push(env.context.ptr_type(AddressSpace::default()).into());
|
||||
env.context
|
||||
.void_type()
|
||||
.fn_type(&function_arguments(env, &argument_types), false)
|
||||
|
@ -6901,7 +6854,7 @@ fn define_global_str_literal_ptr<'ctx>(
|
|||
|
||||
let ptr = env.builder.new_build_pointer_cast(
|
||||
global.as_pointer_value(),
|
||||
env.context.i8_type().ptr_type(AddressSpace::default()),
|
||||
env.context.ptr_type(AddressSpace::default()),
|
||||
"to_opaque",
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue