diff --git a/compiler/gen/src/llvm/build.rs b/compiler/gen/src/llvm/build.rs index 8d308d9177..2d835c40fc 100644 --- a/compiler/gen/src/llvm/build.rs +++ b/compiler/gen/src/llvm/build.rs @@ -94,6 +94,10 @@ impl<'a, 'ctx, 'env> Env<'a, 'ctx, 'env> { pub fn ptr_int(&self) -> IntType<'ctx> { ptr_int(self.context, self.ptr_bytes) } + + pub fn small_str_bytes(&self) -> u32 { + self.ptr_bytes * 2 + } } pub fn module_from_builtins<'ctx>(ctx: &'ctx Context, module_name: &str) -> Module<'ctx> { diff --git a/compiler/gen/src/llvm/build_str.rs b/compiler/gen/src/llvm/build_str.rs index e40f70253d..354298ef96 100644 --- a/compiler/gen/src/llvm/build_str.rs +++ b/compiler/gen/src/llvm/build_str.rs @@ -401,7 +401,7 @@ where byte_array_ptr, &[ctx .i8_type() - .const_int(((env.ptr_bytes * 2) - 1) as u64, false)], + .const_int(env.small_str_bytes() as u64 - 1, false)], "final_byte_ptr", ) };