add finalize everywhere, and fix some oversights

This commit is contained in:
Folkert 2020-11-18 20:08:43 +01:00
parent 6f4585e7d8
commit 5ce8a665f0
5 changed files with 213 additions and 22 deletions

View file

@ -66,6 +66,10 @@ pub fn gen_from_mono_module(
let context = Context::create();
let module = arena.alloc(module_from_builtins(&context, "app"));
// strip Zig debug stuff
// module.strip_debug_info();
let builder = context.create_builder();
let (dibuilder, compile_unit) = roc_gen::llvm::build::Env::new_debug_info(module);
let (mpm, fpm) = roc_gen::llvm::build::construct_optimization_passes(module, opt_level);
@ -115,6 +119,9 @@ pub fn gen_from_mono_module(
// println!("\n\nBuilding and then verifying function {:?}\n\n", proc);
build_proc(&env, &mut layout_ids, scope.clone(), proc, fn_val);
// call finalize() before any code generation/verification
env.dibuilder.finalize();
if fn_val.verify(true) {
fpm.run_on(&fn_val);
} else {
@ -127,6 +134,8 @@ pub fn gen_from_mono_module(
}
}
env.dibuilder.finalize();
// Uncomment this to see the module's optimized LLVM instruction output:
// env.module.print_to_stderr();