FunctionCx: WIP: Replace .constants with codegen_cx.constants
MODIFY
src/base.rs
src/base.rs
@@ -49,7 +49,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>(
cold_blocks: EntitySet::new(),
clif_comments,
- constants_cx: &mut cx.constants_cx,
+ constants_cx: &mut cxcodegen_cx.constants_cx,
vtables: &mut cx.vtables,
source_info_set: indexmap::IndexSet::new(),
next_ssa_var: 0,

MODIFY
src/constant.rs
src/constant.rs
@@ -167,7 +167,7 @@ pub(crate) fn trans_const_value<'tcx>(
let alloc_kind = fxcodegen_cx.tcx.get_global_alloc(ptr.alloc_id);
let base_addr = match alloc_kind {
Some(GlobalAlloc::Memory(alloc)) => {
- fx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id));
+ fxcodegen_cx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id));
let data_id = data_id_for_alloc_id(fxcodegen_cx.module, ptr.alloc_id, alloc.align, alloc.mutability);
let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
#[cfg(debug_assertions)]
@@ -216,7 +216,7 @@ fn pointer_for_allocation<'tcx>(
alloc: &'tcx Allocation,
) -> crate::pointer::Pointer {
let alloc_id = fxcodegen_cx.tcx.create_memory_alloc(alloc);
- fx.constants_cx.todo.push(TodoItem::Alloc(alloc_id));
+ fxcodegen_cx.constants_cx.todo.push(TodoItem::Alloc(alloc_id));
let data_id = data_id_for_alloc_id(fxcodegen_cx.module, alloc_id, alloc.align, alloc.mutability);
let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func);

MODIFY
src/driver/mod.rs
src/driver/mod.rs
@@ -88,7 +88,7 @@ fn trans_mono_item<'tcx, B: Backend + 'static>(
cxcodegen_cx.tcx.sess.time("codegen fn", || crate::base::trans_fn(cx, inst, linkage));
}
MonoItem::Static(def_id) => {
- crate::constant::codegen_static(&mut cx.constants_cx, def_id);
+ crate::constant::codegen_static(&mut cxcodegen_cx.constants_cx, def_id);
}
MonoItem::GlobalAsm(hir_id) => {
let item = tcx.hir().expect_item(hir_id);

MODIFY
src/lib.rs
src/lib.rs
@@ -160,7 +160,7 @@ fn new(
}
fn finalize(mut self) -> (Module<B>, String, Option<DebugContext<'tcx>>, UnwindContext<'tcx>) {
- self.constants_cx.finalize(selfcodegen_cx.tcx, &mut selfcodegen_cx.module);
+ selfcodegen_cx.constants_cx.finalize(selfcodegen_cx.tcx, &mut selfcodegen_cx.module);
(selfcodegen_cx.module, self.global_asm, self.debug_context, self.unwind_context)
}
}

FunctionCx: WIP: Replace .constants with codegen_cx.constants