diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-12-11 15:41:02 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-12-11 21:35:45 +1100 |
| commit | 3f3a9bf7f50afbfde72cd0b9479323dddc84fe6d (patch) | |
| tree | 9aeeae3bc9516d499202142127bccb1d520bb95c /compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs | |
| parent | 512f3fdebe72532a435238435f0e16eff61fbf38 (diff) | |
| download | rust-3f3a9bf7f50afbfde72cd0b9479323dddc84fe6d.tar.gz rust-3f3a9bf7f50afbfde72cd0b9479323dddc84fe6d.zip | |
coverage: Store intermediate region tables in `CovfunRecord`
This defers the call to `llvm_cov::write_function_mappings_to_buffer` until just before its enclosing global variable is created.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs index f7c3193a449..a573a37beb3 100644 --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs @@ -194,7 +194,7 @@ rustc_index::newtype_index! { /// Holds a mapping from "local" (per-function) file IDs to "global" (per-CGU) /// file IDs. -#[derive(Default)] +#[derive(Debug, Default)] struct VirtualFileMapping { local_to_global: IndexVec<LocalFileId, GlobalFileId>, global_to_local: FxIndexMap<GlobalFileId, LocalFileId>, @@ -208,10 +208,10 @@ impl VirtualFileMapping { .or_insert_with(|| self.local_to_global.push(global_file_id)) } - fn into_vec(self) -> Vec<u32> { - // This conversion should be optimized away to ~zero overhead. - // In any case, it's probably not hot enough to worry about. - self.local_to_global.into_iter().map(|global| global.as_u32()).collect() + fn to_vec(&self) -> Vec<u32> { + // This clone could be avoided by transmuting `&[GlobalFileId]` to `&[u32]`, + // but it isn't hot or expensive enough to justify the extra unsafety. + self.local_to_global.iter().map(|&global| GlobalFileId::as_u32(global)).collect() } } |
