diff options
| author | bors <bors@rust-lang.org> | 2025-09-06 15:21:16 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-09-06 15:21:16 +0000 | 
| commit | bea625f3275e3c897dc965ed97a1d19ef7831f01 (patch) | |
| tree | f32cdc8fb33ca70d76fade0ba3a5af10a2c7d6bf /compiler/rustc_codegen_llvm | |
| parent | 6d5caf3a4a358c80f09ba51d71db0dbc41381992 (diff) | |
| parent | 2cf94b92ca852924ad90943a0c469f01742216a6 (diff) | |
| download | rust-bea625f3275e3c897dc965ed97a1d19ef7831f01.tar.gz rust-bea625f3275e3c897dc965ed97a1d19ef7831f01.zip | |
Auto merge of #146232 - bjorn3:lto_allocator_shim, r=lqd
Make the allocator shim participate in LTO again This is likely the cause of the perf regression in https://github.com/rust-lang/rust/pull/145955. It also caused some functional regressions. Fixes https://github.com/rust-lang/rust/issues/146235 Fixes https://github.com/rust-lang/rust/issues/146239
Diffstat (limited to 'compiler/rustc_codegen_llvm')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/lto.rs | 8 | 
1 files changed, 7 insertions, 1 deletions
| diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index 326b876e7e6..ad2e722cfef 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -11,7 +11,7 @@ use object::{Object, ObjectSection}; use rustc_codegen_ssa::back::lto::{SerializedModule, ThinModule, ThinShared}; use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput}; use rustc_codegen_ssa::traits::*; -use rustc_codegen_ssa::{ModuleCodegen, looks_like_rust_object_file}; +use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::memmap::Mmap; use rustc_errors::DiagCtxtHandle; @@ -225,9 +225,15 @@ fn fat_lto( // All the other modules will be serialized and reparsed into the new // context, so this hopefully avoids serializing and parsing the largest // codegen unit. + // + // Additionally use a regular module as the base here to ensure that various + // file copy operations in the backend work correctly. The only other kind + // of module here should be an allocator one, and if your crate is smaller + // than the allocator module then the size doesn't really matter anyway. let costliest_module = in_memory .iter() .enumerate() + .filter(|&(_, module)| module.kind == ModuleKind::Regular) .map(|(i, module)| { let cost = unsafe { llvm::LLVMRustModuleCost(module.module_llvm.llmod()) }; (cost, i) | 
