Skip to content

Commit 14701f8

Browse files
committed
Slightly simplify write_bitcode_to_file handling
This also causes bitcode to be saved for the allocator shim with -Csave-temps.
1 parent 8387095 commit 14701f8

2 files changed

Lines changed: 5 additions & 12 deletions

File tree

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,13 @@ pub(crate) fn save_temp_bitcode(
336336
&module.name,
337337
cgcx.invocation_temp.as_deref(),
338338
);
339-
write_bitcode_to_file(module, &path)
339+
write_bitcode_to_file(&module.module_llvm, &path)
340340
}
341341

342-
fn write_bitcode_to_file(module: &ModuleCodegen<ModuleLlvm>, path: &Path) {
342+
fn write_bitcode_to_file(module: &ModuleLlvm, path: &Path) {
343343
unsafe {
344344
let path = path_to_c_string(&path);
345-
let llmod = module.module_llvm.llmod();
345+
let llmod = module.llmod();
346346
llvm::LLVMWriteBitcodeToFile(llmod, path.as_ptr());
347347
}
348348
}
@@ -906,13 +906,8 @@ pub(crate) fn optimize(
906906
let _handlers =
907907
DiagnosticHandlers::new(cgcx, shared_emitter, llcx, module, CodegenDiagnosticsStage::Opt);
908908

909-
if config.emit_no_opt_bc {
910-
let out = cgcx.output_filenames.temp_path_ext_for_cgu(
911-
"no-opt.bc",
912-
&module.name,
913-
cgcx.invocation_temp.as_deref(),
914-
);
915-
write_bitcode_to_file(module, &out)
909+
if module.kind == ModuleKind::Regular {
910+
save_temp_bitcode(cgcx, module, "no-opt");
916911
}
917912

918913
// FIXME(ZuseZ4): support SanitizeHWAddress and prevent illegal/unsupported opts

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ pub struct ModuleConfig {
9696

9797
// Flags indicating which outputs to produce.
9898
pub emit_pre_lto_bc: bool,
99-
pub emit_no_opt_bc: bool,
10099
pub emit_bc: bool,
101100
pub emit_ir: bool,
102101
pub emit_asm: bool,
@@ -198,7 +197,6 @@ impl ModuleConfig {
198197
save_temps || need_pre_lto_bitcode_for_incr_comp(sess),
199198
false
200199
),
201-
emit_no_opt_bc: if_regular!(save_temps, false),
202200
emit_bc: if_regular!(
203201
save_temps || sess.opts.output_types.contains_key(&OutputType::Bitcode),
204202
save_temps

0 commit comments

Comments
 (0)