Skip to content

Commit 532a654

Browse files
committed
rustc: Actually write the optimized bitcode when --save-temps is on
1 parent 8216b5f commit 532a654

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/comp/middle/trans.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7110,18 +7110,6 @@ fn run_passes(ModuleRef llmod, bool opt, bool verify, bool save_temps,
71107110
llvm.LLVMAddStripDeadPrototypesPass(pm.llpm);
71117111
llvm.LLVMAddDeadTypeEliminationPass(pm.llpm);
71127112
llvm.LLVMAddConstantMergePass(pm.llpm);
7113-
7114-
// Generate a post-optimization intermediate file if -save-temps was
7115-
// specified.
7116-
if (save_temps) {
7117-
alt (ot) {
7118-
case (output_type_bitcode) { /* nothing to do */ }
7119-
case (_) {
7120-
auto filename = mk_intermediate_name(output, "opt.bc");
7121-
llvm.LLVMWriteBitcodeToFile(llmod, _str.buf(filename));
7122-
}
7123-
}
7124-
}
71257113
}
71267114

71277115
if (verify) {
@@ -7140,6 +7128,19 @@ fn run_passes(ModuleRef llmod, bool opt, bool verify, bool save_temps,
71407128
FileType = LLVMAssemblyFile;
71417129
}
71427130

7131+
// Write optimized bitcode if --save-temps was on.
7132+
if (save_temps) {
7133+
alt (ot) {
7134+
case (output_type_bitcode) { /* nothing to do */ }
7135+
case (_) {
7136+
auto filename = mk_intermediate_name(output, "opt.bc");
7137+
llvm.LLVMRunPassManager(pm.llpm, llmod);
7138+
llvm.LLVMWriteBitcodeToFile(llmod, _str.buf(filename));
7139+
pm = mk_pass_manager();
7140+
}
7141+
}
7142+
}
7143+
71437144
llvm.LLVMRustWriteOutputFile(pm.llpm, llmod,
71447145
_str.buf(x86.get_target_triple()),
71457146
_str.buf(output),

0 commit comments

Comments
 (0)