mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
report on LLVM codegen time
This commit is contained in:
parent
ac77177932
commit
4fdf8e5fab
2 changed files with 43 additions and 9 deletions
|
@ -7,8 +7,15 @@ use roc_gen::llvm::build::{build_proc, build_proc_header, module_from_builtins,
|
|||
use roc_load::file::MonomorphizedModule;
|
||||
use roc_mono::layout::LayoutIds;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{Duration, SystemTime};
|
||||
use target_lexicon::Triple;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct CodeGenTiming {
|
||||
pub code_gen: Duration,
|
||||
pub emit_o_file: Duration,
|
||||
}
|
||||
|
||||
// TODO how should imported modules factor into this? What if those use builtins too?
|
||||
// TODO this should probably use more helper functions
|
||||
// TODO make this polymorphic in the llvm functions so it can be reused for another backend.
|
||||
|
@ -21,11 +28,13 @@ pub fn gen_from_mono_module(
|
|||
app_o_file: &Path,
|
||||
opt_level: OptLevel,
|
||||
emit_debug_info: bool,
|
||||
) {
|
||||
) -> CodeGenTiming {
|
||||
use roc_reporting::report::{
|
||||
can_problem, mono_problem, type_problem, RocDocAllocator, DEFAULT_PALETTE,
|
||||
};
|
||||
|
||||
let code_gen_start = SystemTime::now();
|
||||
|
||||
for (home, (module_path, src)) in loaded.sources {
|
||||
let src_lines: Vec<&str> = src.split('\n').collect();
|
||||
let palette = DEFAULT_PALETTE;
|
||||
|
@ -160,6 +169,9 @@ pub fn gen_from_mono_module(
|
|||
// Uncomment this to see the module's optimized LLVM instruction output:
|
||||
// env.module.print_to_stderr();
|
||||
|
||||
let code_gen = code_gen_start.elapsed().unwrap();
|
||||
let emit_o_file_start = SystemTime::now();
|
||||
|
||||
// annotate the LLVM IR output with debug info
|
||||
// so errors are reported with the line number of the LLVM source
|
||||
if emit_debug_info {
|
||||
|
@ -232,6 +244,13 @@ pub fn gen_from_mono_module(
|
|||
.write_to_file(&env.module, FileType::Object, &app_o_file)
|
||||
.expect("Writing .o file failed");
|
||||
}
|
||||
|
||||
let emit_o_file = emit_o_file_start.elapsed().unwrap();
|
||||
|
||||
CodeGenTiming {
|
||||
emit_o_file,
|
||||
code_gen,
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FunctionIterator<'ctx> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue