From 31fc62b7f01a0c4fbcab0b8431cc38d3384b2c89 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 6 Feb 2021 21:46:22 +0100 Subject: [PATCH] cleanup --- cli/src/repl/gen.rs | 4 +--- compiler/build/src/program.rs | 5 ++--- compiler/gen/src/llvm/build.rs | 13 +++---------- compiler/gen/src/llvm/build_hash.rs | 3 +-- compiler/gen/tests/gen_hash.rs | 2 +- compiler/gen/tests/helpers/eval.rs | 2 +- 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/cli/src/repl/gen.rs b/cli/src/repl/gen.rs index 0f97551742..c97450eb17 100644 --- a/cli/src/repl/gen.rs +++ b/cli/src/repl/gen.rs @@ -117,9 +117,7 @@ pub fn gen_and_eval(src: &[u8], target: Triple, opt_level: OptLevel) -> Result Env<'a, 'ctx, 'env> { } } -pub fn module_from_builtins<'ctx>( - ctx: &'ctx Context, - module_name: &str, - ptr_size: u32, -) -> Module<'ctx> { +pub fn module_from_builtins<'ctx>(ctx: &'ctx Context, module_name: &str) -> Module<'ctx> { let bitcode_bytes = bitcode::get_bytes(); let memory_buffer = MemoryBuffer::create_from_memory_range(&bitcode_bytes, module_name); @@ -260,12 +256,12 @@ pub fn module_from_builtins<'ctx>( .unwrap_or_else(|err| panic!("Unable to import builtins bitcode. LLVM error: {:?}", err)); // Add LLVM intrinsics. - add_intrinsics(ctx, &module, ptr_size); + add_intrinsics(ctx, &module); module } -fn add_intrinsics<'ctx>(ctx: &'ctx Context, module: &Module<'ctx>, ptr_size: u32) { +fn add_intrinsics<'ctx>(ctx: &'ctx Context, module: &Module<'ctx>) { // List of all supported LLVM intrinsics: // // https://releases.llvm.org/10.0.0/docs/LangRef.html#standard-c-library-intrinsics @@ -277,9 +273,6 @@ fn add_intrinsics<'ctx>(ctx: &'ctx Context, module: &Module<'ctx>, ptr_size: u32 let i8_type = ctx.i8_type(); let i8_ptr_type = i8_type.ptr_type(AddressSpace::Generic); - let byte_slice_type = - ctx.struct_type(&[i8_ptr_type.into(), ptr_int(ctx, ptr_size).into()], false); - add_intrinsic( module, LLVM_MEMSET_I64, diff --git a/compiler/gen/src/llvm/build_hash.rs b/compiler/gen/src/llvm/build_hash.rs index ef1daa6b7b..321326a191 100644 --- a/compiler/gen/src/llvm/build_hash.rs +++ b/compiler/gen/src/llvm/build_hash.rs @@ -1,6 +1,5 @@ use crate::llvm::build::call_bitcode_fn; use crate::llvm::build::Env; -use crate::llvm::build_list::{load_list, store_list}; use crate::llvm::build_str; use crate::llvm::convert::basic_type_from_layout; use inkwell::values::BasicValueEnum; @@ -54,7 +53,7 @@ pub fn hash<'a, 'ctx, 'env>( call_bitcode_fn( env, - &[seed.into(), hash_bytes.into(), num_bytes.into()], + &[seed.into(), hash_bytes, num_bytes.into()], &bitcode::DICT_HASH, ) } diff --git a/compiler/gen/tests/gen_hash.rs b/compiler/gen/tests/gen_hash.rs index d7d8315ce3..6cf9fd4cea 100644 --- a/compiler/gen/tests/gen_hash.rs +++ b/compiler/gen/tests/gen_hash.rs @@ -22,7 +22,7 @@ mod gen_hash { Dict.hashTestOnly 0 0 "# ), - 1, + 9718519427346233646, u64 ); } diff --git a/compiler/gen/tests/helpers/eval.rs b/compiler/gen/tests/helpers/eval.rs index 7c4650d9c4..944bcc7a91 100644 --- a/compiler/gen/tests/helpers/eval.rs +++ b/compiler/gen/tests/helpers/eval.rs @@ -174,7 +174,7 @@ pub fn helper<'a>( ), }; - let module = roc_gen::llvm::build::module_from_builtins(context, "app", ptr_bytes); + let module = roc_gen::llvm::build::module_from_builtins(context, "app"); // strip Zig debug stuff module.strip_debug_info();