1
Fork 0

Remove serialized_bitcode from LtoModuleCodegen.

It's unused.
This commit is contained in:
Nicholas Nethercote 2024-09-05 17:17:26 +10:00
parent d6c8169c18
commit bbe28cf1d9
3 changed files with 7 additions and 17 deletions

View file

@ -272,7 +272,6 @@ fn fat_lto(
}*/ }*/
} }
}; };
let mut serialized_bitcode = Vec::new();
{ {
info!("using {:?} as a base module", module.name); info!("using {:?} as a base module", module.name);
@ -317,7 +316,6 @@ fn fat_lto(
unimplemented!("from uncompressed file") unimplemented!("from uncompressed file")
} }
} }
serialized_bitcode.push(bc_decoded);
} }
save_temp_bitcode(cgcx, &module, "lto.input"); save_temp_bitcode(cgcx, &module, "lto.input");
@ -337,7 +335,7 @@ fn fat_lto(
// of now. // of now.
module.module_llvm.temp_dir = Some(tmp_path); module.module_llvm.temp_dir = Some(tmp_path);
Ok(LtoModuleCodegen::Fat { module, _serialized_bitcode: serialized_bitcode }) Ok(LtoModuleCodegen::Fat(module))
} }
pub struct ModuleBuffer(PathBuf); pub struct ModuleBuffer(PathBuf);

View file

@ -314,7 +314,6 @@ fn fat_lto(
} }
} }
}; };
let mut serialized_bitcode = Vec::new();
{ {
let (llcx, llmod) = { let (llcx, llmod) = {
let llvm = &module.module_llvm; let llvm = &module.module_llvm;
@ -342,9 +341,7 @@ fn fat_lto(
serialized_modules.sort_by(|module1, module2| module1.1.cmp(&module2.1)); serialized_modules.sort_by(|module1, module2| module1.1.cmp(&module2.1));
// For all serialized bitcode files we parse them and link them in as we did // For all serialized bitcode files we parse them and link them in as we did
// above, this is all mostly handled in C++. Like above, though, we don't // above, this is all mostly handled in C++.
// know much about the memory management here so we err on the side of being
// save and persist everything with the original module.
let mut linker = Linker::new(llmod); let mut linker = Linker::new(llmod);
for (bc_decoded, name) in serialized_modules { for (bc_decoded, name) in serialized_modules {
let _timer = cgcx let _timer = cgcx
@ -355,7 +352,6 @@ fn fat_lto(
info!("linking {:?}", name); info!("linking {:?}", name);
let data = bc_decoded.data(); let data = bc_decoded.data();
linker.add(data).map_err(|()| write::llvm_err(dcx, LlvmError::LoadBitcode { name }))?; linker.add(data).map_err(|()| write::llvm_err(dcx, LlvmError::LoadBitcode { name }))?;
serialized_bitcode.push(bc_decoded);
} }
drop(linker); drop(linker);
save_temp_bitcode(cgcx, &module, "lto.input"); save_temp_bitcode(cgcx, &module, "lto.input");
@ -372,7 +368,7 @@ fn fat_lto(
} }
} }
Ok(LtoModuleCodegen::Fat { module, _serialized_bitcode: serialized_bitcode }) Ok(LtoModuleCodegen::Fat(module))
} }
pub(crate) struct Linker<'a>(&'a mut llvm::Linker<'a>); pub(crate) struct Linker<'a>(&'a mut llvm::Linker<'a>);

View file

@ -41,18 +41,14 @@ pub struct ThinShared<B: WriteBackendMethods> {
} }
pub enum LtoModuleCodegen<B: WriteBackendMethods> { pub enum LtoModuleCodegen<B: WriteBackendMethods> {
Fat { Fat(ModuleCodegen<B::Module>),
module: ModuleCodegen<B::Module>,
_serialized_bitcode: Vec<SerializedModule<B::ModuleBuffer>>,
},
Thin(ThinModule<B>), Thin(ThinModule<B>),
} }
impl<B: WriteBackendMethods> LtoModuleCodegen<B> { impl<B: WriteBackendMethods> LtoModuleCodegen<B> {
pub fn name(&self) -> &str { pub fn name(&self) -> &str {
match *self { match *self {
LtoModuleCodegen::Fat { .. } => "everything", LtoModuleCodegen::Fat(_) => "everything",
LtoModuleCodegen::Thin(ref m) => m.name(), LtoModuleCodegen::Thin(ref m) => m.name(),
} }
} }
@ -68,7 +64,7 @@ impl<B: WriteBackendMethods> LtoModuleCodegen<B> {
cgcx: &CodegenContext<B>, cgcx: &CodegenContext<B>,
) -> Result<ModuleCodegen<B::Module>, FatalError> { ) -> Result<ModuleCodegen<B::Module>, FatalError> {
match self { match self {
LtoModuleCodegen::Fat { mut module, .. } => { LtoModuleCodegen::Fat(mut module) => {
B::optimize_fat(cgcx, &mut module)?; B::optimize_fat(cgcx, &mut module)?;
Ok(module) Ok(module)
} }
@ -81,7 +77,7 @@ impl<B: WriteBackendMethods> LtoModuleCodegen<B> {
pub fn cost(&self) -> u64 { pub fn cost(&self) -> u64 {
match *self { match *self {
// Only one module with fat LTO, so the cost doesn't matter. // Only one module with fat LTO, so the cost doesn't matter.
LtoModuleCodegen::Fat { .. } => 0, LtoModuleCodegen::Fat(_) => 0,
LtoModuleCodegen::Thin(ref m) => m.cost(), LtoModuleCodegen::Thin(ref m) => m.cost(),
} }
} }