Skip to content

Commit 4e547b9

Browse files
committed
Move some things from codegen_mono_item to trans_fn
1 parent db8fa0e commit 4e547b9

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/base.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ pub(crate) fn codegen_fn<'tcx>(
1212
) {
1313
let tcx = cx.tcx;
1414

15+
let _inst_guard =
16+
crate::PrintOnPanic(|| format!("{:?} {}", instance, tcx.symbol_name(instance).name));
17+
debug_assert!(!instance.substs.needs_infer());
18+
1519
let mir = tcx.instance_mir(instance.def);
1620

1721
// Declare function

src/driver/mod.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,15 @@ fn codegen_mono_item<'tcx, M: Module>(
6868
mono_item: MonoItem<'tcx>,
6969
linkage: Linkage,
7070
) {
71-
let tcx = cx.tcx;
7271
match mono_item {
7372
MonoItem::Fn(inst) => {
74-
let _inst_guard =
75-
crate::PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).name));
76-
debug_assert!(!inst.substs.needs_infer());
77-
tcx.sess
73+
cx.tcx
74+
.sess
7875
.time("codegen fn", || crate::base::codegen_fn(cx, inst, linkage));
7976
}
80-
MonoItem::Static(def_id) => {
81-
crate::constant::codegen_static(&mut cx.constants_cx, def_id);
82-
}
77+
MonoItem::Static(def_id) => crate::constant::codegen_static(&mut cx.constants_cx, def_id),
8378
MonoItem::GlobalAsm(hir_id) => {
84-
let item = tcx.hir().expect_item(hir_id);
79+
let item = cx.tcx.hir().expect_item(hir_id);
8580
if let rustc_hir::ItemKind::GlobalAsm(rustc_hir::GlobalAsm { asm }) = item.kind {
8681
cx.global_asm.push_str(&*asm.as_str());
8782
cx.global_asm.push_str("\n\n");

0 commit comments

Comments
 (0)