From d662083a6c78928c70cc74b600205c246dab3bf6 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 14 Aug 2018 17:55:22 +0200 Subject: Use CGU name as LLVM module name and add some caching to CGU name generation. --- src/librustc_codegen_llvm/back/link.rs | 7 ------- src/librustc_codegen_llvm/back/lto.rs | 11 +++++------ src/librustc_codegen_llvm/back/write.rs | 3 +-- 3 files changed, 6 insertions(+), 15 deletions(-) (limited to 'src/librustc_codegen_llvm/back') diff --git a/src/librustc_codegen_llvm/back/link.rs b/src/librustc_codegen_llvm/back/link.rs index bbe1ccf3696..37c99932f56 100644 --- a/src/librustc_codegen_llvm/back/link.rs +++ b/src/librustc_codegen_llvm/back/link.rs @@ -46,13 +46,6 @@ use std::process::{Output, Stdio}; use std::str; use syntax::attr; -/// The LLVM module name containing crate-metadata. This includes a `.` on -/// purpose, so it cannot clash with the name of a user-defined module. -pub const METADATA_MODULE_NAME: &'static str = "crate.metadata"; - -// same as for metadata above, but for allocator shim -pub const ALLOCATOR_MODULE_NAME: &'static str = "crate.allocator"; - pub use rustc_codegen_utils::link::{find_crate_name, filename_for_input, default_output_for_target, invalid_output_for_target, build_link_meta, out_filename, check_file_is_writeable}; diff --git a/src/librustc_codegen_llvm/back/lto.rs b/src/librustc_codegen_llvm/back/lto.rs index d7741230327..56858a31efd 100644 --- a/src/librustc_codegen_llvm/back/lto.rs +++ b/src/librustc_codegen_llvm/back/lto.rs @@ -242,7 +242,7 @@ fn fat_lto(cgcx: &CodegenContext, let llvm = module.llvm().expect("can't lto pre-codegened modules"); (&llvm.llcx, llvm.llmod()) }; - info!("using {:?} as a base module", module.llmod_id); + info!("using {:?} as a base module", module.name); // The linking steps below may produce errors and diagnostics within LLVM // which we'd like to handle and print, so set up our diagnostic handlers @@ -257,7 +257,7 @@ fn fat_lto(cgcx: &CodegenContext, for module in modules { let llvm = module.llvm().expect("can't lto pre-codegened modules"); let buffer = ModuleBuffer::new(llvm.llmod()); - let llmod_id = CString::new(&module.llmod_id[..]).unwrap(); + let llmod_id = CString::new(&module.name[..]).unwrap(); serialized_modules.push((SerializedModule::Local(buffer), llmod_id)); } @@ -384,9 +384,9 @@ fn thin_lto(diag_handler: &Handler, // the most expensive portion of this small bit of global // analysis! for (i, module) in modules.iter().enumerate() { - info!("local module: {} - {}", i, module.llmod_id); + info!("local module: {} - {}", i, module.name); let llvm = module.llvm().expect("can't lto precodegened module"); - let name = CString::new(module.llmod_id.clone()).unwrap(); + let name = CString::new(module.name.clone()).unwrap(); let buffer = ThinBuffer::new(llvm.llmod()); thin_modules.push(llvm::ThinLTOModule { identifier: name.as_ptr(), @@ -395,7 +395,7 @@ fn thin_lto(diag_handler: &Handler, }); thin_buffers.push(buffer); module_names.push(name); - timeline.record(&module.llmod_id); + timeline.record(&module.name); } // FIXME: All upstream crates are deserialized internally in the @@ -668,7 +668,6 @@ impl ThinModule { llcx, tm, }), - llmod_id: self.name().to_string(), name: self.name().to_string(), kind: ModuleKind::Regular, }; diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs index d60983d7697..b62836ec255 100644 --- a/src/librustc_codegen_llvm/back/write.rs +++ b/src/librustc_codegen_llvm/back/write.rs @@ -728,7 +728,7 @@ unsafe fn codegen(cgcx: &CodegenContext, if config.emit_bc_compressed { let dst = bc_out.with_extension(RLIB_BYTECODE_EXTENSION); - let data = bytecode::encode(&module.llmod_id, data); + let data = bytecode::encode(&module.name, data); if let Err(e) = fs::write(&dst, data) { diag_handler.err(&format!("failed to write bytecode: {}", e)); } @@ -1338,7 +1338,6 @@ fn execute_work_item(cgcx: &CodegenContext, assert_eq!(bytecode_compressed.is_some(), config.emit_bc_compressed); Ok(WorkItemResult::Compiled(CompiledModule { - llmod_id: module.llmod_id.clone(), name: module_name, kind: ModuleKind::Regular, pre_existing: true, -- cgit 1.4.1-3-g733a5