Skip to content

coverage: Detect unused local file IDs to avoid an LLVM assertion #140847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 19, 2025

Conversation

Zalathar
Copy link
Contributor

@Zalathar Zalathar commented May 9, 2025

Each function's coverage metadata contains a local file table that maps local file IDs (used by the function's mapping regions) to global file IDs (shared by all functions in the same CGU).

LLVM requires all local file IDs to have at least one mapping region, and has an assertion that will fail if it detects a local file ID with no regions. To make sure that assertion doesn't fire, we need to detect and skip functions whose metadata would trigger it.

(This can't actually happen yet, because currently all of a function's spans must belong to the same file and expansion. But this will be an important edge case when adding expansion region support.)

@Zalathar Zalathar added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label May 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 9, 2025

r? @SparrowLii

rustbot has assigned @SparrowLii.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 9, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rust-log-analyzer

This comment has been minimized.

Zalathar added 3 commits May 10, 2025 00:24
This allows us to assume that coverage spans will only be discarded during
codegen in very unusual situations.
Having this helper function in the loop was confusing, because it doesn't rely
on anything that changes between loop iterations.
This case can't actually happen yet (other than via a testing flag), because
currently all of a function's spans must belong to the same file and expansion.
But this will be an important edge case when adding expansion region support.
@Zalathar Zalathar force-pushed the unused-local-file branch from 20bf8be to 078144f Compare May 9, 2025 14:27
@SparrowLii
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented May 19, 2025

📌 Commit 078144f has been approved by SparrowLii

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 19, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request May 19, 2025
…wLii

coverage: Detect unused local file IDs to avoid an LLVM assertion

Each function's coverage metadata contains a *local file table* that maps local file IDs (used by the function's mapping regions) to global file IDs (shared by all functions in the same CGU).

LLVM requires all local file IDs to have at least one mapping region, and has an assertion that will fail if it detects a local file ID with no regions. To make sure that assertion doesn't fire, we need to detect and skip functions whose metadata would trigger it.

(This can't actually happen yet, because currently all of a function's spans must belong to the same file and expansion. But this will be an important edge case when adding expansion region support.)
@bors
Copy link
Collaborator

bors commented May 19, 2025

⌛ Testing commit 078144f with merge 1e8d54d...

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-mingw-1 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [run-make] tests\run-make\rustdoc-dep-info stdout ----

error: rmake recipe failed to complete
status: exit code: 1
command: "D:\\a\\rust\\rust\\build\\x86_64-pc-windows-gnu\\test\\run-make\\rustdoc-dep-info\\rmake.exe"
stdout: none
--- stderr -------------------------------
command failed at line 10
Command { cmd: "D:\\a\\rust\\rust\\build\\x86_64-pc-windows-gnu\\stage2\\bin\\rustdoc.exe" "lib.rs" "-Zunstable-options" "--emit=dep-info", stdin_buf: None, stdin: None, stdout: None, stderr: None, drop_bomb: DropBomb { command: "D:\\a\\rust\\rust\\build\\x86_64-pc-windows-gnu\\stage2\\bin\\rustdoc.exe", defused: true, armed_location: Location { file: "D:\\a\\rust\\rust\\tests\\run-make\\rustdoc-dep-info\\rmake.rs", line: 10, col: 5 } }, already_executed: true }
output status: `exit code: 0xc00000fd`
=== STDOUT ===



=== STDERR ===

---
test result: FAILED. 284 passed; 1 failed; 110 ignored; 0 measured; 6 filtered out; finished in 205.58s

Some tests failed in compiletest suite=run-make mode=run-make host=x86_64-pc-windows-gnu target=x86_64-pc-windows-gnu
Build completed unsuccessfully in 2:25:45
make: *** [Makefile:124: ci-mingw-x] Error 1
  local time: Mon May 19 05:38:19 CUT 2025
  network time: Mon, 19 May 2025 05:38:19 GMT
##[error]Process completed with exit code 2.
Post job cleanup.
[command]"C:\Program Files\Git\bin\git.exe" version

@bors
Copy link
Collaborator

bors commented May 19, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 19, 2025
@Zalathar
Copy link
Contributor Author

@bors retry (mingw)

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 19, 2025
@Zalathar Zalathar added the CI-spurious-fail-mingw CI spurious failure: target env mingw label May 19, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request May 19, 2025
Rollup of 5 pull requests

Successful merges:

 - rust-lang#140847 (coverage: Detect unused local file IDs to avoid an LLVM assertion)
 - rust-lang#141117 (opt-dist: fix deprecated BOLT -icf=1 option)
 - rust-lang#141225 (more ice tests)
 - rust-lang#141239 (dladdr cannot leave dli_fname to be null)
 - rust-lang#141242 (in `tests/ui/asm/aarch64/parse-error.rs`, only test cases specific to that target)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3b22c21 into rust-lang:master May 19, 2025
6 of 7 checks passed
@rustbot rustbot added this to the 1.89.0 milestone May 19, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 19, 2025
Rollup merge of rust-lang#140847 - Zalathar:unused-local-file, r=SparrowLii

coverage: Detect unused local file IDs to avoid an LLVM assertion

Each function's coverage metadata contains a *local file table* that maps local file IDs (used by the function's mapping regions) to global file IDs (shared by all functions in the same CGU).

LLVM requires all local file IDs to have at least one mapping region, and has an assertion that will fail if it detects a local file ID with no regions. To make sure that assertion doesn't fire, we need to detect and skip functions whose metadata would trigger it.

(This can't actually happen yet, because currently all of a function's spans must belong to the same file and expansion. But this will be an important edge case when adding expansion region support.)
@Zalathar Zalathar deleted the unused-local-file branch May 19, 2025 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) CI-spurious-fail-mingw CI spurious failure: target env mingw S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants