diff options
| author | Seo Sanghyeon <sanxiyn@gmail.com> | 2015-09-22 00:33:17 +0900 |
|---|---|---|
| committer | Seo Sanghyeon <sanxiyn@gmail.com> | 2015-09-22 00:33:17 +0900 |
| commit | 9ba5db6690929eb0595582908dadbb4e773fbf98 (patch) | |
| tree | 2a890978b67fed85e3fd8bfe8ccde5d34898f440 /src | |
| parent | a33e48771e75c82411da2c668366bec59cee718d (diff) | |
| download | rust-9ba5db6690929eb0595582908dadbb4e773fbf98.tar.gz rust-9ba5db6690929eb0595582908dadbb4e773fbf98.zip | |
Save bitcode before LTO when -C save-temps is given
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_trans/back/lto.rs | 13 | ||||
| -rw-r--r-- | src/librustc_trans/back/write.rs | 3 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/librustc_trans/back/lto.rs b/src/librustc_trans/back/lto.rs index 00439c1fd58..ba6ec895a8e 100644 --- a/src/librustc_trans/back/lto.rs +++ b/src/librustc_trans/back/lto.rs @@ -15,6 +15,7 @@ use llvm; 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; @@ -24,7 +25,9 @@ use std::ffi::CString; 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"); @@ -124,6 +127,14 @@ pub fn run(sess: &session::Session, llmod: ModuleRef, } } + 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. // diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index d75f2fcf126..94e2891f40f 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -496,7 +496,8 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext, 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); |
