use llvm::archive_ro::ArchiveRO;
use llvm::{ModuleRef, TargetMachineRef, True, False};
use rustc::util::common::time;
+use rustc::util::common::path2cstr;
use back::write::{ModuleConfig, with_llvm_pmb};
use libc;
pub fn run(sess: &session::Session, llmod: ModuleRef,
tm: TargetMachineRef, reachable: &[String],
- config: &ModuleConfig) {
+ config: &ModuleConfig,
+ name_extra: &str,
+ output_names: &config::OutputFilenames) {
if sess.opts.cg.prefer_dynamic {
sess.err("cannot prefer dynamic linking when performing LTO");
sess.note("only 'staticlib' and 'bin' outputs are supported with LTO");
}
}
+ if sess.opts.cg.save_temps {
+ let path = output_names.with_extension(&format!("{}.no-opt.lto.bc", name_extra));
+ let cstr = path2cstr(&path);
+ unsafe {
+ llvm::LLVMWriteBitcodeToFile(llmod, cstr.as_ptr());
+ }
+ }
+
// Now we have one massive module inside of llmod. Time to run the
// LTO-specific optimization passes that LLVM provides.
//
match cgcx.lto_ctxt {
Some((sess, reachable)) if sess.lto() => {
time(sess.time_passes(), "all lto passes", ||
- lto::run(sess, llmod, tm, reachable, &config));
+ lto::run(sess, llmod, tm, reachable, &config,
+ &name_extra, &output_names));
if config.emit_lto_bc {
let name = format!("{}.lto.bc", name_extra);