Skip to content

Commit

Permalink
Move some things from codegen_mono_item to trans_fn
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Nov 12, 2020
1 parent db8fa0e commit 4e547b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/base.rs
Expand Up @@ -12,6 +12,10 @@ pub(crate) fn codegen_fn<'tcx>(
) {
let tcx = cx.tcx;

let _inst_guard =
crate::PrintOnPanic(|| format!("{:?} {}", instance, tcx.symbol_name(instance).name));
debug_assert!(!instance.substs.needs_infer());

let mir = tcx.instance_mir(instance.def);

// Declare function
Expand Down
13 changes: 4 additions & 9 deletions src/driver/mod.rs
Expand Up @@ -68,20 +68,15 @@ fn codegen_mono_item<'tcx, M: Module>(
mono_item: MonoItem<'tcx>,
linkage: Linkage,
) {
let tcx = cx.tcx;
match mono_item {
MonoItem::Fn(inst) => {
let _inst_guard =
crate::PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).name));
debug_assert!(!inst.substs.needs_infer());
tcx.sess
cx.tcx
.sess
.time("codegen fn", || crate::base::codegen_fn(cx, inst, linkage));
}
MonoItem::Static(def_id) => {
crate::constant::codegen_static(&mut cx.constants_cx, def_id);
}
MonoItem::Static(def_id) => crate::constant::codegen_static(&mut cx.constants_cx, def_id),
MonoItem::GlobalAsm(hir_id) => {
let item = tcx.hir().expect_item(hir_id);
let item = cx.tcx.hir().expect_item(hir_id);
if let rustc_hir::ItemKind::GlobalAsm(rustc_hir::GlobalAsm { asm }) = item.kind {
cx.global_asm.push_str(&*asm.as_str());
cx.global_asm.push_str("\n\n");
Expand Down

0 comments on commit 4e547b9

Please sign in to comment.