rustc: Actually write the optimized bitcode when --save-temps is on

This commit is contained in:
Patrick Walton 2011-04-26 18:48:02 -07:00
parent 8216b5fc10
commit 532a65485d

View File

@ -7110,18 +7110,6 @@ fn run_passes(ModuleRef llmod, bool opt, bool verify, bool save_temps,
llvm.LLVMAddStripDeadPrototypesPass(pm.llpm); llvm.LLVMAddStripDeadPrototypesPass(pm.llpm);
llvm.LLVMAddDeadTypeEliminationPass(pm.llpm); llvm.LLVMAddDeadTypeEliminationPass(pm.llpm);
llvm.LLVMAddConstantMergePass(pm.llpm); llvm.LLVMAddConstantMergePass(pm.llpm);
// Generate a post-optimization intermediate file if -save-temps was
// specified.
if (save_temps) {
alt (ot) {
case (output_type_bitcode) { /* nothing to do */ }
case (_) {
auto filename = mk_intermediate_name(output, "opt.bc");
llvm.LLVMWriteBitcodeToFile(llmod, _str.buf(filename));
}
}
}
} }
if (verify) { if (verify) {
@ -7140,6 +7128,19 @@ fn run_passes(ModuleRef llmod, bool opt, bool verify, bool save_temps,
FileType = LLVMAssemblyFile; FileType = LLVMAssemblyFile;
} }
// Write optimized bitcode if --save-temps was on.
if (save_temps) {
alt (ot) {
case (output_type_bitcode) { /* nothing to do */ }
case (_) {
auto filename = mk_intermediate_name(output, "opt.bc");
llvm.LLVMRunPassManager(pm.llpm, llmod);
llvm.LLVMWriteBitcodeToFile(llmod, _str.buf(filename));
pm = mk_pass_manager();
}
}
}
llvm.LLVMRustWriteOutputFile(pm.llpm, llmod, llvm.LLVMRustWriteOutputFile(pm.llpm, llmod,
_str.buf(x86.get_target_triple()), _str.buf(x86.get_target_triple()),
_str.buf(output), _str.buf(output),