Skip to content

Commit 1903a24

Browse files
committed
Remove output_filenames from CodegenCx
1 parent 8810ed6 commit 1903a24

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

src/base.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use rustc_middle::ty::TypeVisitableExt;
1212
use rustc_middle::ty::adjustment::PointerCoercion;
1313
use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv};
1414
use rustc_middle::ty::print::with_no_trimmed_paths;
15+
use rustc_session::config::OutputFilenames;
1516

1617
use crate::constant::ConstantCx;
1718
use crate::debuginfo::{FunctionDebugContext, TypeDebugContext};
@@ -138,6 +139,7 @@ pub(crate) fn codegen_fn<'tcx>(
138139
pub(crate) fn compile_fn(
139140
cx: &mut crate::CodegenCx,
140141
profiler: &SelfProfilerRef,
142+
output_filenames: &OutputFilenames,
141143
cached_context: &mut Context,
142144
module: &mut dyn Module,
143145
codegened_func: CodegenedFunction,
@@ -215,7 +217,7 @@ pub(crate) fn compile_fn(
215217
if cx.should_write_ir {
216218
// Write optimized function to file for debugging
217219
crate::pretty_clif::write_clif_file(
218-
&cx.output_filenames,
220+
output_filenames,
219221
&codegened_func.symbol_name,
220222
"opt",
221223
module.isa(),
@@ -225,7 +227,7 @@ pub(crate) fn compile_fn(
225227

226228
if let Some(disasm) = &context.compiled_code().unwrap().vcode {
227229
crate::pretty_clif::write_ir_file(
228-
&cx.output_filenames,
230+
output_filenames,
229231
&format!("{}.vcode", codegened_func.symbol_name),
230232
|file| file.write_all(disasm.as_bytes()),
231233
)

src/driver/aot.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ fn module_codegen(
594594

595595
let profiler = tcx.prof.clone();
596596
let invocation_temp = tcx.sess.invocation_temp.clone();
597+
let output_filenames = tcx.output_filenames(()).clone();
597598

598599
OngoingModuleCodegen::Async(std::thread::spawn(move || {
599600
profiler.clone().generic_activity_with_arg("compile functions", &*cgu_name).run(|| {
@@ -606,6 +607,7 @@ fn module_codegen(
606607
crate::base::compile_fn(
607608
&mut cx,
608609
&profiler,
610+
&output_filenames,
609611
&mut cached_context,
610612
&mut module,
611613
codegened_func,

src/driver/jit.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_codegen_ssa::CrateInfo;
99
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1010
use rustc_middle::mir::mono::MonoItem;
1111
use rustc_session::Session;
12+
use rustc_session::config::OutputFilenames;
1213
use rustc_span::sym;
1314

1415
use crate::CodegenCx;
@@ -41,6 +42,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, jit_args: Vec<String>) -> ! {
4142
tcx.dcx().fatal("can't jit non-executable crate");
4243
}
4344

45+
let output_filenames = tcx.output_filenames(());
4446
let (mut jit_module, mut cx) = create_jit_module(tcx);
4547
let mut cached_context = Context::new();
4648

@@ -60,6 +62,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, jit_args: Vec<String>) -> ! {
6062
MonoItem::Fn(inst) => {
6163
codegen_and_compile_fn(
6264
tcx,
65+
&output_filenames,
6366
&mut cx,
6467
&mut cached_context,
6568
&mut jit_module,
@@ -122,6 +125,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, jit_args: Vec<String>) -> ! {
122125

123126
fn codegen_and_compile_fn<'tcx>(
124127
tcx: TyCtxt<'tcx>,
128+
output_filenames: &OutputFilenames,
125129
cx: &mut crate::CodegenCx,
126130
cached_context: &mut Context,
127131
module: &mut dyn Module,
@@ -149,7 +153,14 @@ fn codegen_and_compile_fn<'tcx>(
149153
module,
150154
instance,
151155
);
152-
crate::base::compile_fn(cx, &tcx.prof, cached_context, module, codegened_func);
156+
crate::base::compile_fn(
157+
cx,
158+
&tcx.prof,
159+
output_filenames,
160+
cached_context,
161+
module,
162+
codegened_func,
163+
);
153164
});
154165
}
155166

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ impl<F: Fn() -> String> Drop for PrintOnPanic<F> {
125125
/// The codegen context holds any information shared between the codegen of individual functions
126126
/// inside a single codegen unit with the exception of the Cranelift [`Module`](cranelift_module::Module).
127127
struct CodegenCx {
128-
output_filenames: Arc<OutputFilenames>,
129128
should_write_ir: bool,
130129
global_asm: String,
131130
debug_context: Option<DebugContext>,
@@ -142,7 +141,6 @@ impl CodegenCx {
142141
None
143142
};
144143
CodegenCx {
145-
output_filenames: tcx.output_filenames(()).clone(),
146144
should_write_ir: crate::pretty_clif::should_write_ir(tcx),
147145
global_asm: String::new(),
148146
debug_context,

0 commit comments

Comments
 (0)