Commit Graph

150 Commits

Author SHA1 Message Date
Josh Stone
12167d7064 Update the minimum external LLVM to 19 2025-04-05 11:44:38 -07:00
dianqk
1787789fe5
Bless tests 2025-04-02 19:59:26 +08:00
dianqk
7e0463fe93
Revert "comment out the old tests instead of adjusting them"
This reverts commit 906f66fb4c.
2025-04-02 19:59:26 +08:00
Zalathar
26cea8a286 coverage: Don't split bang-macro spans, just truncate them 2025-04-01 13:13:21 +11:00
Zalathar
62a533ce78 coverage: Instead of splitting, just discard any span that overlaps a hole 2025-04-01 13:13:20 +11:00
Zalathar
577272eede coverage: Shrink call spans to just the function name
This is a way to shrink call spans that doesn't involve mixing different spans,
and avoids overlap with argument spans.

This patch also removes some low-value comments that were causing rustfmt to
ignore the match arms.
2025-04-01 13:07:33 +11:00
Zalathar
e80a3e2232 coverage: Tweak tests/coverage/assert-ne.rs
This test is intended to demonstrate that a particular macro-argument span
doesn't get lost during span-refinement, but it turns out that span-extraction
currently doesn't yield any MIR spans for this position.

This patch therefore tweaks the test to add a function call in that position,
so that it still remains relevant to span refinement.
2025-04-01 13:07:33 +11:00
Michael Goulet
897acc3e5d Encode synthetic by-move coroutine body with a different DefPathData 2025-03-30 22:53:21 +00:00
Zalathar
d9b91de00c coverage: Add some more cases to tests/coverage/holes.rs 2025-02-19 13:56:20 +11:00
Zalathar
ab786d3b98 coverage: Eliminate more counters by giving them to unreachable nodes
When preparing a function's coverage counters and metadata during codegen, any
part of the original coverage graph that was removed by MIR optimizations can
be treated as having an execution count of zero.

Somewhat counter-intuitively, if we give those unreachable nodes a _higher_
priority for receiving physical counters (instead of counter expressions), that
ends up reducing the total number of physical counters needed.

This works because if a node is unreachable, we don't actually create a
physical counter for it. Instead that node gets a fixed zero counter, and any
other node that would have relied on that physical counter in its counter
expression can just ignore that term completely.
2025-02-13 13:45:53 +11:00
Zalathar
bf1f254b13 coverage: Don't create counters for code that was removed by MIR opts 2025-02-06 21:44:31 +11:00
Zalathar
f1300c860e coverage: Completely overhaul counter assignment, using node-flow graphs 2025-01-16 22:07:18 +11:00
lcnr
b85b2c60f9 add comment to test 2025-01-09 13:55:50 +01:00
Michael Goulet
39daadc76e Account for identity substituted items in symbol mangling 2025-01-09 13:55:40 +01:00
Eric Huss
0efa90f246 Add a test for coverage attr on trait function 2024-12-24 00:09:38 +11:00
Zalathar
87c2f9a5be Revert "Auto merge of #130766 - clarfonthey:stable-coverage-attribute, r=wesleywiser"
This reverts commit 1d35638dc3, reversing
changes made to f23a80a4c2.
2024-12-23 12:30:37 +11:00
Matthias Krüger
57cbd078f2
Rollup merge of #134497 - Zalathar:spans, r=jieyouxu
coverage: Store coverage source regions as `Span` until codegen (take 2)

This is an attempt to re-land #133418:

> Historically, coverage spans were converted into line/column coordinates during the MIR instrumentation pass.

> This PR moves that conversion step into codegen, so that coverage spans spend most of their time stored as Span instead.

> In addition to being conceptually nicer, this also reduces the size of coverage mappings in MIR, because Span is smaller than 4x u32.

That PR was reverted by #133608, because in some circumstances not covered by our test suite we were emitting coverage metadata that was causing `llvm-cov` to exit with an error (#133606).

---

The implementation here is *mostly* the same, but adapted for subsequent changes in the relevant code (e.g. #134163).

I believe that the changes in #134163 should be sufficient to prevent the problem that required the original PR to be reverted. But I haven't been able to reproduce the original breakage in a regression test, and the `llvm-cov` error message is extremely unhelpful, so I can't completely rule out the possibility of this breaking again.

r? jieyouxu (reviewer of the original PR)
2024-12-19 15:26:16 +01:00
Zalathar
aced4dcf10 coverage: Add a synthetic test for when all spans are discarded 2024-12-19 22:03:43 +11:00
Eric Huss
dbf5ae3a86 Add reference annotations for the coverage attribute 2024-12-18 15:03:44 -08:00
Matthias Krüger
e696f5c180
Rollup merge of #134323 - Zalathar:dismantle-map-data, r=jieyouxu
coverage: Dismantle `map_data.rs` by moving its responsibilities elsewhere

This is a series of incremental changes that combine to let us get rid of `coverageinfo/map_data.rs`, by moving all of its responsibilities into more appropriate places.

Some of the notable consequences are:

- We once again build the per-CGU file table on the fly while preparing individual covfun records, instead of building the whole table up-front. The up-front approach was introduced by #117042 to work around various other problems in generating the covmap/covfun records, but subsequent cleanups have made that approach no longer necessary.
- Expression conversion and mapping-region conversion are now performed directly in `mapgen::covfun`, which should make future changes easier.
- We no longer insert unused function instances into the same map that is also used to track used function instances. This helps to decouple the handling of used vs unused functions.

---

There should be no meaningful change to compiler output. The file table is no longer sorted, because reordering it would invalidate the file indices stored in individual covfun records, but the table order should still be deterministic (albeit arbitrary).

There are some subsequent cleanups that I intend to investigate, but this is enough change for one PR.
2024-12-17 22:34:42 +01:00
Zalathar
154fae1e8d coverage: Build the global file table on the fly 2024-12-17 13:55:19 +11:00
ltdk
cb487cc2fa Stabilize #[coverage] attribute 2024-12-16 21:07:06 -05:00
Michael Goulet
c605c84be8 Stabilize async closures 2024-12-13 00:04:56 +00:00
Zalathar
ac815ff6b0 coverage: Prefer to visit nodes whose predecessors have been visited 2024-12-07 12:13:12 +11:00
Eric Holk
72ce1ab42f
Stabilize noop_waker
Co-authored-by: zachs18 <8355914+zachs18@users.noreply.github.com>
2024-12-05 14:14:17 -08:00
Zalathar
44e4e4515c coverage: Add an extra "transcribe" step after counter creation 2024-12-04 17:50:52 +11:00
Zalathar
2a3b4a0afd coverage: Extract subtracted_sum in counter creation 2024-12-04 17:00:25 +11:00
Michael Goulet
59e3e8934e Gate async fn trait bound modifier on async_trait_bounds 2024-12-02 16:50:44 +00:00
Zalathar
6fc0fe76e8 coverage: Use a query to identify which counter/expression IDs are used 2024-11-30 00:58:48 +11:00
bors
6b6a867ae9 Auto merge of #133474 - RalfJung:gvn-miscompile, r=compiler-errors
Do not unify dereferences of shared borrows in GVN

Repost of https://github.com/rust-lang/rust/pull/132461, the last commit applies my suggestions.

Fixes https://github.com/rust-lang/rust/issues/130853
2024-11-27 15:43:56 +00:00
Ralf Jung
906f66fb4c comment out the old tests instead of adjusting them 2024-11-25 20:39:45 +01:00
Zalathar
6798ecaf10 Coverage test for allowing coverage in a #![no_core] crate 2024-11-24 21:12:40 +11:00
Zalathar
3c30fe3423 coverage: Restrict empty-span expansion to only cover { and } 2024-11-08 20:43:08 +11:00
Zalathar
afe190204b coverage: Regression test for inlining into an uninstrumented crate 2024-11-02 23:20:14 +11:00
Michael Goulet
cdbf28af76 Dont ICE when computing coverage of synthetic async closure body 2024-10-18 20:14:02 +11:00
Zalathar
599f95ecc2 coverage: Include the highest counter ID seen in .cov-map dumps
When making changes that have a large impact on coverage counter creation, this
makes it easier to see whether the number of physical counters has changed.

(The highest counter ID seen in coverage maps is not necessarily the same as
the number of physical counters actually used by the instrumented code, but
it's the best approximation we can get from looking only at the coverage maps,
and it should be reasonably accurate in most cases.)
2024-10-11 21:04:37 +11:00
Zalathar
96224d80ce compiletest: Remove the magic hacks for finding output with lto=thin
This hack was intended to handle the case where `-Clto=thin` causes the
compiler to emit multiple output files (when producing LLVM-IR or assembly).

The hack only affects 4 tests, of which 3 are just meta-tests for the hack
itself. The one remaining test that motivated the hack currently doesn't even
need it!

(`tests/codegen/issues/issue-81408-dllimport-thinlto-windows.rs`)
2024-10-11 11:28:42 +11:00
Zalathar
27583378d3 Simplify the directives for ignoring coverage-test modes 2024-10-08 22:51:53 +11:00
zhuyunxing
6e3e19f714 coverage. Adapt to mcdc mapping formats introduced by llvm 19 2024-10-08 11:15:24 +08:00
zhuyunxing
911ac56e95 coverage. Disable supporting mcdc on llvm-18 2024-10-08 10:50:18 +08:00
Ralf Jung
7d63efdb8c fix GVN trying to transmute pointers to integers 2024-10-05 17:55:23 +02:00
Josh Stone
6fd8a50680 Update the minimum external LLVM to 18 2024-09-18 13:53:31 -07:00
Zalathar
e96b4e479a coverage: Extract executor::block_on from several async coverage tests
By moving `block_on` to an auxiliary crate, we avoid having to keep a separate
copy of it in every async test.

(This also incorporates some small tweaks to the headers in `await_ready.rs`.)
2024-09-10 16:08:36 +10:00
Jonathan Conder
25d183057e coverage: Treat await similar to a macro
Currently `await` is only counted towards coverage if the containing
function is suspended and resumed at least once. This is because it
expands to code which contains a branch on the discriminant of `Poll`.

By treating it like a branching macro (e.g. `assert!`), these
implementation details will be hidden from the coverage results.
2024-09-06 17:01:59 +12:00
Jonathan Conder
3446ca535e coverage: Add test to codify existing behavior
Currently `await` is only counted towards coverage if the containing
function is suspended and resumed at least once. A future commit will
fix this and update the test to reflect the new behavior.
2024-09-06 16:50:23 +12:00
Zalathar
68df46c4c2 Finish blessing coverage/mcdc tests after LLVM 19 upgrade 2024-08-01 13:36:50 +10:00
Josh Stone
33a36ea438 Bless coverage/mcdc for line number changes 2024-07-30 18:25:05 -07:00
Krasimir Georgiev
00bfd702dc Disable MC/DC tests on LLVM 19
Disable the tests and generate an error if MC/DC is used on LLVM 19.
The support will be ported separately, as it is substantially
different on LLVM 19, and there are no plans to support both
versions.
2024-07-30 10:22:48 +02:00
Camille GILLOT
6e3cff7094 Bless coverage. 2024-07-13 12:02:12 +00:00
Camille GILLOT
76f5bc6a9f Create mapped places upon seeing them in the body. 2024-07-13 11:54:25 +00:00