Fix lifetime errors due to interner

In the llvm backend, there are the lifetimes `'a` (lifetime of the
global arena) and `'ctx` (lifetime of constructed LLVM values). `'a`
lives longer than `'ctx`, but the compiler didn't enforce this until
the layout interner was introduced, for some reason. We have to make
sure that containers of lifetime `'a` have no `'ctx` references.
This commit is contained in:
Ayaz Hafiz 2022-12-29 11:38:34 -06:00
parent 512a1721ae
commit 759f8d86af
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
6 changed files with 54 additions and 55 deletions

View file

@ -102,7 +102,7 @@ pub fn gen_from_mono_module<'a>(
// TODO make this polymorphic in the llvm functions so it can be reused for another backend.
fn gen_from_mono_module_llvm<'a>(
arena: &'a bumpalo::Bump,
loaded: MonomorphizedModule<'a>,
mut loaded: MonomorphizedModule<'a>,
roc_file_path: &Path,
target: &target_lexicon::Triple,
code_gen_options: CodeGenOptions,
@ -168,7 +168,6 @@ fn gen_from_mono_module_llvm<'a>(
// Compile and add all the Procs before adding main
let env = roc_gen_llvm::llvm::build::Env {
arena,
layout_interner: &loaded.layout_interner,
builder: &builder,
dibuilder: &dibuilder,
compile_unit: &compile_unit,
@ -204,6 +203,7 @@ fn gen_from_mono_module_llvm<'a>(
roc_gen_llvm::llvm::build::build_procedures(
&env,
&mut loaded.layout_interner,
opt_level,
loaded.procedures,
entry_point,