about summary refs log tree commit diff
path: root/tests/coverage
AgeCommit message (Collapse)AuthorLines
2025-02-19coverage: Add some more cases to `tests/coverage/holes.rs`Zalathar-17/+88
2025-02-13coverage: Eliminate more counters by giving them to unreachable nodesZalathar-218/+221
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-06coverage: Don't create counters for code that was removed by MIR optsZalathar-121/+84
2025-01-16coverage: Completely overhaul counter assignment, using node-flow graphsZalathar-1330/+1186
2025-01-09add comment to testlcnr-4/+6
2025-01-09Account for identity substituted items in symbol manglingMichael Goulet-0/+51
2024-12-24Add a test for coverage attr on trait functionEric Huss-0/+60
2024-12-23Revert "Auto merge of #130766 - clarfonthey:stable-coverage-attribute, ↵Zalathar-272/+335
r=wesleywiser" This reverts commit 1d35638dc38dbfbf1cc2a9823135dfcf3c650169, reversing changes made to f23a80a4c2fbca593b64e70f5970368824b4c5e9.
2024-12-19Rollup merge of #134497 - Zalathar:spans, r=jieyouxuMatthias Krüger-0/+37
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-19coverage: Add a synthetic test for when all spans are discardedZalathar-0/+37
2024-12-18Add reference annotations for the `coverage` attributeEric Huss-36/+48
2024-12-17Rollup merge of #134323 - Zalathar:dismantle-map-data, r=jieyouxuMatthias Krüger-4/+4
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-17coverage: Build the global file table on the flyZalathar-4/+4
2024-12-16Stabilize #[coverage] attributeltdk-341/+276
2024-12-13Stabilize async closuresMichael Goulet-14/+12
2024-12-07coverage: Prefer to visit nodes whose predecessors have been visitedZalathar-1076/+783
2024-12-05Stabilize noop_wakerEric Holk-89/+79
Co-authored-by: zachs18 <8355914+zachs18@users.noreply.github.com>
2024-12-04coverage: Add an extra "transcribe" step after counter creationZalathar-1428/+1433
2024-12-04coverage: Extract `subtracted_sum` in counter creationZalathar-4/+6
2024-12-02Gate async fn trait bound modifier on async_trait_boundsMichael Goulet-6/+6
2024-11-30coverage: Use a query to identify which counter/expression IDs are usedZalathar-8/+8
2024-11-27Auto merge of #133474 - RalfJung:gvn-miscompile, r=compiler-errorsbors-103/+120
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-25comment out the old tests instead of adjusting themRalf Jung-103/+120
2024-11-24Coverage test for allowing coverage in a `#![no_core]` crateZalathar-0/+34
2024-11-08coverage: Restrict empty-span expansion to only cover `{` and `}`Zalathar-154/+152
2024-11-02coverage: Regression test for inlining into an uninstrumented crateZalathar-0/+32
2024-10-18Dont ICE when computing coverage of synthetic async closure bodyMichael Goulet-0/+95
2024-10-11coverage: Include the highest counter ID seen in `.cov-map` dumpsZalathar-0/+296
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-11compiletest: Remove the magic hacks for finding output with `lto=thin`Zalathar-15/+0
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-08Simplify the directives for ignoring coverage-test modesZalathar-5/+5
2024-10-08coverage. Adapt to mcdc mapping formats introduced by llvm 19zhuyunxing-213/+107
2024-10-08coverage. Disable supporting mcdc on llvm-18zhuyunxing-10/+10
2024-10-05fix GVN trying to transmute pointers to integersRalf Jung-8/+8
2024-09-18Update the minimum external LLVM to 18Josh Stone-52/+42
2024-09-10coverage: Extract `executor::block_on` from several async coverage testsZalathar-277/+142
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-06coverage: Treat await similar to a macroJonathan Conder-37/+30
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-06coverage: Add test to codify existing behaviorJonathan Conder-0/+101
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-08-01Finish blessing `coverage/mcdc` tests after LLVM 19 upgradeZalathar-0/+5
2024-07-30Bless coverage/mcdc for line number changesJosh Stone-42/+42
2024-07-30Disable MC/DC tests on LLVM 19Krasimir Georgiev-0/+5
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-13Bless coverage.Camille GILLOT-7/+9
2024-07-13Create mapped places upon seeing them in the body.Camille GILLOT-85/+114
2024-07-09coverage. Fix panic when generating mcdc code for inlined functionszhuyunxing-0/+79
2024-07-09coverage. MCDC tests also report branches coveragezhuyunxing-6/+78
2024-07-09coverage. Group mcdc tests in one directoryzhuyunxing-18/+18
2024-07-08coverage: Extract hole spans from HIR instead of MIRZalathar-136/+109
This makes it possible to treat more kinds of nested item/code as holes, instead of being restricted to closures.
2024-07-08coverage: Test for handling of nested item spansZalathar-0/+179
2024-06-28Rollup merge of #126956 - joboet:fmt_no_extern_ty, r=RalfJungMatthias Krüger-10/+10
core: avoid `extern type`s in formatting infrastructure ```@RalfJung``` [said](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Use.20of.20.60extern.20type.60.20in.20formatting.20machinery/near/446552837): >How attached are y'all to using `extern type` in the formatting machinery? Seems like this was introduced a [long time ago](https://github.com/rust-lang/rust/commit/34ef8f5441d5335c4177abd622383ed34a6e9315). However, it's also [not really compatible with Stacked Borrows](https://github.com/rust-lang/unsafe-code-guidelines/issues/256), and only works currently because we effectively treat references-to-extern-type almost like raw pointers in Stacked Borrows -- which of course is unsound, it's not how LLVM works. I was planning to make Miri emit a warning when this happens to avoid cases like [this](https://github.com/rust-lang/rust/issues/126814#issuecomment-2183816373) where people use extern type specifically to silence Miri without realizing what happens. but with the formatting machinery using extern type, this warning would just show up everywhere... > > The "proper" way to do this in Stacked Borrows is to use raw pointers (or `NonNull`). This PR does just that. r? ```@RalfJung```
2024-06-27Rollup merge of #126721 - Zalathar:nested-cov-attr, r=oli-obkJacob Pratt-152/+255
coverage: Make `#[coverage(..)]` apply recursively to nested functions This PR makes the (currently-unstable) `#[coverage(off)]` and `#[coverage(on)]` attributes apply recursively to all nested functions/closures, instead of just the function they are directly attached to. Those attributes can now also be applied to modules and to impl/impl-trait blocks, where they have no direct effect, but will be inherited by all enclosed functions/closures/methods that don't override the inherited value. --- Fixes #126625.
2024-06-26coverage: Allow `#[coverage(..)]` on `impl` and `mod`Zalathar-0/+206
These attributes apply to all enclosed functions/methods/closures, unless explicitly overridden by another coverage attribute.