Skip to content

Commit 0b9b253

Browse files
committed
Move finalize CodegenCx timer out of codegen mono items timer
1 parent 20ffea6 commit 0b9b253

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

src/driver/jit.rs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,32 +69,36 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
6969

7070
let mut cx = crate::CodegenCx::new(tcx, jit_module, false, false);
7171

72-
let (mut jit_module, global_asm, _debug, mut unwind_context) =
73-
super::time(tcx, "codegen mono items", || {
74-
super::predefine_mono_items(&mut cx, &mono_items);
75-
for (mono_item, (linkage, visibility)) in mono_items {
76-
let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility);
77-
match mono_item {
78-
MonoItem::Fn(inst) => {
79-
cx.tcx.sess.time("codegen fn", || {
80-
crate::base::codegen_fn(&mut cx, inst, linkage)
81-
});
82-
}
83-
MonoItem::Static(def_id) => {
84-
crate::constant::codegen_static(&mut cx.constants_cx, def_id)
85-
}
86-
MonoItem::GlobalAsm(hir_id) => {
87-
let item = cx.tcx.hir().expect_item(hir_id);
88-
tcx.sess
89-
.span_fatal(item.span, "Global asm is not supported in JIT mode");
90-
}
72+
super::time(tcx, "codegen mono items", || {
73+
super::predefine_mono_items(&mut cx, &mono_items);
74+
for (mono_item, (linkage, visibility)) in mono_items {
75+
let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility);
76+
match mono_item {
77+
MonoItem::Fn(inst) => {
78+
cx.tcx.sess.time("codegen fn", || {
79+
crate::base::codegen_fn(&mut cx, inst, linkage)
80+
});
81+
}
82+
MonoItem::Static(def_id) => {
83+
crate::constant::codegen_static(&mut cx.constants_cx, def_id)
84+
}
85+
MonoItem::GlobalAsm(hir_id) => {
86+
let item = cx.tcx.hir().expect_item(hir_id);
87+
tcx.sess
88+
.span_fatal(item.span, "Global asm is not supported in JIT mode");
9189
}
9290
}
93-
tcx.sess.time("finalize CodegenCx", || cx.finalize())
94-
});
91+
}
92+
});
93+
94+
let (mut jit_module, global_asm, _debug, mut unwind_context) =
95+
tcx.sess.time("finalize CodegenCx", || cx.finalize());
96+
jit_module.finalize_definitions();
97+
9598
if !global_asm.is_empty() {
9699
tcx.sess.fatal("Inline asm is not supported in JIT mode");
97100
}
101+
98102
crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module, &mut unwind_context, true);
99103
crate::allocator::codegen(tcx, &mut jit_module, &mut unwind_context);
100104

0 commit comments

Comments
 (0)