Skip to content
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

coverage: Allow each coverage statement to have multiple code regions #115301

Merged
merged 7 commits into from Oct 3, 2023

Conversation

Zalathar
Copy link
Contributor

@Zalathar Zalathar commented Aug 28, 2023

The original implementation of coverage instrumentation was built around the assumption that a coverage counter/expression would be associated with up to one code region. When it was discovered that multiple regions would sometimes need to share a counter, a workaround was found: for the remaining regions, the instrumentor would create a fresh expression that adds zero to the existing counter/expression.

That got the job done, but resulted in some awkward code, and produces unnecessarily complicated coverage maps in the final binary.


This PR removes that tension by changing StatementKind::Coverage's code region field from Option<CodeRegion> to Vec<CodeRegion>.

The changes on the codegen side are fairly straightforward. As long as each CoverageKind::Counter only injects one llvm.instrprof.increment, the rest of coverage codegen is happy to handle multiple regions mapped to the same counter/expression, with only minor option-to-vec adjustments.

On the instrumentor/mir-transform side, we can get rid of the code that creates extra (x + 0) expressions. Instead we gather all of the code regions associated with a single BCB, and inject them all into one coverage statement.


There are several patches here but they can be divided in to three phases:

  • Preparatory work
  • Actually switching over to multiple regions per coverage statement
  • Cleaning up

So viewing the patches individually may be easier.

@rustbot
Copy link
Collaborator

rustbot commented Aug 28, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 28, 2023
@rustbot
Copy link
Collaborator

rustbot commented Aug 28, 2023

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @davidtwco, @celinval, @vakaras

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Aug 28, 2023
@Zalathar
Copy link
Contributor Author

(Cargo.toml changes are part of #114843 and won't remain in the final version of this PR.)

Comment on lines -126 to -129
debug!(
"adding counter to coverage_map: instance={:?}, id={:?}, region={:?}",
instance, id, code_region,
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These debug! invocations have been replaced with #[instrument(...)] tracing on the methods being called.

);
func_coverage.add_counter(id, code_region);
}
func_coverage.add_counter(id, code_regions);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now call add_counter unconditionally here, and leave the callee to decide how to handle counters with zero code regions.

@Zalathar Zalathar force-pushed the regions-vec branch 4 times, most recently from 823b02b to 39cfe01 Compare August 28, 2023 07:59
@davidtwco davidtwco added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 28, 2023
@davidtwco
Copy link
Member

davidtwco commented Aug 28, 2023

There's still lots of discussion and changes happening here, use @rustbot ready when you've got something you're looking to have merged. I mixed this up with one of the other coverage pull requests.

I'll review this once its dependencies land.

@Zalathar Zalathar force-pushed the regions-vec branch 3 times, most recently from 17b3653 to e08eb2e Compare August 29, 2023 03:03
@bors

This comment was marked as resolved.

@Zalathar Zalathar force-pushed the regions-vec branch 2 times, most recently from 594c85c to d280856 Compare August 30, 2023 10:35
@bors

This comment was marked as resolved.

@Zalathar Zalathar force-pushed the regions-vec branch 3 times, most recently from 08cff5b to 36c1667 Compare October 2, 2023 02:06
There is no need to include a dummy counter reference in the coverage mappings
for an unused function.
By encapsulating the coverage spans in a struct, we can change the internal
representation without disturbing existing call sites. This will be useful for
grouping coverage spans by BCB.

This patch includes some changes that were originally in rust-lang#115912, which avoid
the need for a particular test to deal with coverage spans at all.

(Comments/logs referring to `CoverageSpan` are updated in a subsequent patch.)
The concrete type `CoverageSpan` is no longer used outside of the `spans`
module.

This is a separate patch to avoid noise in the preceding patch that actually
encapsulates coverage spans.
This makes it possible for a `StatementKind::Coverage` to hold more than one
code region, but that capability is not yet used.
If a BCB has more than one code region, those extra regions can now all be
stored in the same coverage statement, instead of being stored in additional
statements.
Now that coverage statements can have multiple code regions attached to them,
this code is never used.
When these methods were originally written, I wasn't aware that
`newtype_index!` already supports addition with ordinary numbers, without
needing to unwrap and re-wrap.
Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay in getting to this, looks good to me.

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Oct 3, 2023

📌 Commit 053c4f9 has been approved by davidtwco

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 Oct 3, 2023
@bors
Copy link
Contributor

bors commented Oct 3, 2023

⌛ Testing commit 053c4f9 with merge 36aab8d...

@bors
Copy link
Contributor

bors commented Oct 3, 2023

☀️ Test successful - checks-actions
Approved by: davidtwco
Pushing 36aab8d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 3, 2023
@bors bors merged commit 36aab8d into rust-lang:master Oct 3, 2023
12 checks passed
@rustbot rustbot added this to the 1.75.0 milestone Oct 3, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (36aab8d): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.7% [-0.7%, -0.6%] 4
Improvements ✅
(secondary)
-0.4% [-0.6%, -0.2%] 15
All ❌✅ (primary) -0.7% [-0.7%, -0.6%] 4

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.1% [1.1%, 1.1%] 1
Improvements ✅
(primary)
-0.8% [-0.8%, -0.8%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.8% [-0.8%, -0.8%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 622.003s -> 621.563s (-0.07%)
Artifact size: 272.02 MiB -> 272.01 MiB (-0.00%)

@Zalathar Zalathar deleted the regions-vec branch October 4, 2023 01:33
bors-ferrocene bot added a commit to ferrocene/ferrocene that referenced this pull request Oct 5, 2023
23: Fix divergence from upstream `master` r=tshepang a=pvdrz

* rust-lang/rust#116381
* rust-lang/rust#116360
* rust-lang/rust#116353
* rust-lang/rust#116406
* rust-lang/rust#116408
  * rust-lang/rust#116395
  * rust-lang/rust#116393
  * rust-lang/rust#116388
  * rust-lang/rust#116365
  * rust-lang/rust#116363
  * rust-lang/rust#116146
  * rust-lang/rust#115961
* rust-lang/rust#116386
* rust-lang/rust#116367
* rust-lang/rust#105394
* rust-lang/rust#115301
* rust-lang/rust#116384
  * rust-lang/rust#116379
  * rust-lang/rust#116328
  * rust-lang/rust#116282
  * rust-lang/rust#116261
  * rust-lang/rust#114654
* rust-lang/rust#116376
  * rust-lang/rust#116374
  * rust-lang/rust#116371
  * rust-lang/rust#116358
  * rust-lang/rust#116210
  * rust-lang/rust#115863
* rust-lang/rust#115025
* rust-lang/rust#116372
  * rust-lang/rust#116361
  * rust-lang/rust#116355
  * rust-lang/rust#116351
  * rust-lang/rust#116158
  * rust-lang/rust#115726
  * rust-lang/rust#113053
* rust-lang/rust#116083
* rust-lang/rust#102099
* rust-lang/rust#116356
  * rust-lang/rust#116350
  * rust-lang/rust#116349
  * rust-lang/rust#116289
  * rust-lang/rust#114454
  * rust-lang/rust#114453
* rust-lang/rust#116331
* rust-lang/rust#116346
  * rust-lang/rust#116340
  * rust-lang/rust#116326
  * rust-lang/rust#116313
* rust-lang/rust#116276
* rust-lang/rust#115898
* rust-lang/rust#116325
* rust-lang/rust#116317
* rust-lang/rust#116207
* rust-lang/rust#116281
* rust-lang/rust#116304
* rust-lang/rust#116259
* rust-lang/rust#116228
* rust-lang/rust#116224
* rust-lang/rust#115554
* rust-lang/rust#116311
  * rust-lang/rust#116299
  * rust-lang/rust#116295
  * rust-lang/rust#116292
* rust-lang/rust#116307
* rust-lang/rust#115670
* rust-lang/rust#116225
* rust-lang/rust#116302
* rust-lang/rust#116108
* rust-lang/rust#116160
* rust-lang/rust#116157
* rust-lang/rust#116127
* rust-lang/rust#116286
* rust-lang/rust#116254
* rust-lang/rust#116195
* rust-lang/rust#116280
* rust-lang/rust#115933
* rust-lang/rust#115546
* rust-lang/rust#115368
* rust-lang/rust#116275
  * rust-lang/rust#116263
  * rust-lang/rust#116241
  * rust-lang/rust#116216
  * rust-lang/rust#116030
  * rust-lang/rust#116024
  * rust-lang/rust#112123
* rust-lang/rust#113301
* rust-lang/rust#113797
* rust-lang/rust#115759
* rust-lang/rust#116260
  * rust-lang/rust#116253
  * rust-lang/rust#116245
  * rust-lang/rust#116239
  * rust-lang/rust#116234
  * rust-lang/rust#116231
  * rust-lang/rust#116201
  * rust-lang/rust#116133
* rust-lang/rust#116176
* rust-lang/rust#116089
* rust-lang/rust#115986



Co-authored-by: ouz-a <ouz.agz@gmail.com>
Co-authored-by: Jakub Beránek <berykubik@gmail.com>
Co-authored-by: Federico Stra <stra.federico@gmail.com>
Co-authored-by: bohan <bohan-zhang@foxmail.com>
Co-authored-by: Jason Newcomb <jsnewcomb@pm.me>
Co-authored-by: Ralf Jung <post@ralfj.de>
Co-authored-by: bors <bors@rust-lang.org>
Co-authored-by: Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de>
bors-ferrocene bot added a commit to ferrocene/ferrocene that referenced this pull request Oct 6, 2023
23: Fix divergence from upstream `master` r=tshepang a=pvdrz

* rust-lang/rust#116483
  * rust-lang/rust#116475
  * rust-lang/rust#116329
  * rust-lang/rust#116198
  * rust-lang/rust#115588
  * rust-lang/rust#115522
  * rust-lang/rust#115454
* rust-lang/rust#111595
* rust-lang/rust#116018
* rust-lang/rust#116472
  * rust-lang/rust#116469
  * rust-lang/rust#116421
* rust-lang/rust#116463
* rust-lang/rust#101150
* rust-lang/rust#116269
* rust-lang/rust#116417
* rust-lang/rust#116455
  * rust-lang/rust#116452
  * rust-lang/rust#116428
  * rust-lang/rust#116415
  * rust-lang/rust#116288
  * rust-lang/rust#116220
* rust-lang/rust#103046
* rust-lang/rust#114042
* rust-lang/rust#104153
* rust-lang/rust#116427
* rust-lang/rust#116443
  * rust-lang/rust#116432
  * rust-lang/rust#116431
  * rust-lang/rust#116429
  * rust-lang/rust#116296
  * rust-lang/rust#116223
* rust-lang/rust#116273
* rust-lang/rust#116184
* rust-lang/rust#116370
* rust-lang/rust#114417
* rust-lang/rust#115200
* rust-lang/rust#116413
* rust-lang/rust#116381
* rust-lang/rust#116360
* rust-lang/rust#116353
* rust-lang/rust#116406
* rust-lang/rust#116408
  * rust-lang/rust#116395
  * rust-lang/rust#116393
  * rust-lang/rust#116388
  * rust-lang/rust#116365
  * rust-lang/rust#116363
  * rust-lang/rust#116146
  * rust-lang/rust#115961
* rust-lang/rust#116386
* rust-lang/rust#116367
* rust-lang/rust#105394
* rust-lang/rust#115301
* rust-lang/rust#116384
  * rust-lang/rust#116379
  * rust-lang/rust#116328
  * rust-lang/rust#116282
  * rust-lang/rust#116261
  * rust-lang/rust#114654
* rust-lang/rust#116376
  * rust-lang/rust#116374
  * rust-lang/rust#116371
  * rust-lang/rust#116358
  * rust-lang/rust#116210
  * rust-lang/rust#115863
* rust-lang/rust#115025
* rust-lang/rust#116372
  * rust-lang/rust#116361
  * rust-lang/rust#116355
  * rust-lang/rust#116351
  * rust-lang/rust#116158
  * rust-lang/rust#115726
  * rust-lang/rust#113053
* rust-lang/rust#116083
* rust-lang/rust#102099
* rust-lang/rust#116356
  * rust-lang/rust#116350
  * rust-lang/rust#116349
  * rust-lang/rust#116289
  * rust-lang/rust#114454
  * rust-lang/rust#114453
* rust-lang/rust#116331
* rust-lang/rust#116346
  * rust-lang/rust#116340
  * rust-lang/rust#116326
  * rust-lang/rust#116313
* rust-lang/rust#116276
* rust-lang/rust#115898
* rust-lang/rust#116325
* rust-lang/rust#116317
* rust-lang/rust#116207
* rust-lang/rust#116281
* rust-lang/rust#116304
* rust-lang/rust#116259
* rust-lang/rust#116228
* rust-lang/rust#116224
* rust-lang/rust#115554
* rust-lang/rust#116311
  * rust-lang/rust#116299
  * rust-lang/rust#116295
  * rust-lang/rust#116292
* rust-lang/rust#116307
* rust-lang/rust#115670
* rust-lang/rust#116225
* rust-lang/rust#116302
* rust-lang/rust#116108
* rust-lang/rust#116160
* rust-lang/rust#116157
* rust-lang/rust#116127
* rust-lang/rust#116286
* rust-lang/rust#116254
* rust-lang/rust#116195
* rust-lang/rust#116280
* rust-lang/rust#115933
* rust-lang/rust#115546
* rust-lang/rust#115368
* rust-lang/rust#116275
  * rust-lang/rust#116263
  * rust-lang/rust#116241
  * rust-lang/rust#116216
  * rust-lang/rust#116030
  * rust-lang/rust#116024
  * rust-lang/rust#112123
* rust-lang/rust#113301
* rust-lang/rust#113797
* rust-lang/rust#115759
* rust-lang/rust#116260
  * rust-lang/rust#116253
  * rust-lang/rust#116245
  * rust-lang/rust#116239
  * rust-lang/rust#116234
  * rust-lang/rust#116231
  * rust-lang/rust#116201
  * rust-lang/rust#116133
* rust-lang/rust#116176
* rust-lang/rust#116089
* rust-lang/rust#115986

Co-authored-by: ouz-a <ouz.agz@gmail.com>
Co-authored-by: bors <bors@rust-lang.org>
Co-authored-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Co-authored-by: linkmauve <linkmauve@linkmauve.fr>
Co-authored-by: onur-ozkan <work@onurozkan.dev>
Co-authored-by: asquared31415 <34665709+asquared31415@users.noreply.github.com>
Co-authored-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Co-authored-by: Ralf Jung <post@ralfj.de>
Co-authored-by: Nadrieril <nadrieril+git@gmail.com>
Co-authored-by: Raekye <Raekye@users.noreply.github.com>
Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
Co-authored-by: Zalathar <Zalathar@users.noreply.github.com>
bors-ferrocene bot added a commit to ferrocene/ferrocene that referenced this pull request Oct 9, 2023
23: Fix divergence from upstream `master` r=pietroalbini a=pvdrz

* rust-lang/rust#116483
  * rust-lang/rust#116475
  * rust-lang/rust#116329
  * rust-lang/rust#116198
  * rust-lang/rust#115588
  * rust-lang/rust#115522
  * rust-lang/rust#115454
* rust-lang/rust#111595
* rust-lang/rust#116018
* rust-lang/rust#116472
  * rust-lang/rust#116469
  * rust-lang/rust#116421
* rust-lang/rust#116463
* rust-lang/rust#101150
* rust-lang/rust#116269
* rust-lang/rust#116417
* rust-lang/rust#116455
  * rust-lang/rust#116452
  * rust-lang/rust#116428
  * rust-lang/rust#116415
  * rust-lang/rust#116288
  * rust-lang/rust#116220
* rust-lang/rust#103046
* rust-lang/rust#114042
* rust-lang/rust#104153
* rust-lang/rust#116427
* rust-lang/rust#116443
  * rust-lang/rust#116432
  * rust-lang/rust#116431
  * rust-lang/rust#116429
  * rust-lang/rust#116296
  * rust-lang/rust#116223
* rust-lang/rust#116273
* rust-lang/rust#116184
* rust-lang/rust#116370
* rust-lang/rust#114417
* rust-lang/rust#115200
* rust-lang/rust#116413
* rust-lang/rust#116381
* rust-lang/rust#116360
* rust-lang/rust#116353
* rust-lang/rust#116406
* rust-lang/rust#116408
  * rust-lang/rust#116395
  * rust-lang/rust#116393
  * rust-lang/rust#116388
  * rust-lang/rust#116365
  * rust-lang/rust#116363
  * rust-lang/rust#116146
  * rust-lang/rust#115961
* rust-lang/rust#116386
* rust-lang/rust#116367
* rust-lang/rust#105394
* rust-lang/rust#115301
* rust-lang/rust#116384
  * rust-lang/rust#116379
  * rust-lang/rust#116328
  * rust-lang/rust#116282
  * rust-lang/rust#116261
  * rust-lang/rust#114654
* rust-lang/rust#116376
  * rust-lang/rust#116374
  * rust-lang/rust#116371
  * rust-lang/rust#116358
  * rust-lang/rust#116210
  * rust-lang/rust#115863
* rust-lang/rust#115025
* rust-lang/rust#116372
  * rust-lang/rust#116361
  * rust-lang/rust#116355
  * rust-lang/rust#116351
  * rust-lang/rust#116158
  * rust-lang/rust#115726
  * rust-lang/rust#113053
* rust-lang/rust#116083
* rust-lang/rust#102099
* rust-lang/rust#116356
  * rust-lang/rust#116350
  * rust-lang/rust#116349
  * rust-lang/rust#116289
  * rust-lang/rust#114454
  * rust-lang/rust#114453
* rust-lang/rust#116331
* rust-lang/rust#116346
  * rust-lang/rust#116340
  * rust-lang/rust#116326
  * rust-lang/rust#116313
* rust-lang/rust#116276
* rust-lang/rust#115898
* rust-lang/rust#116325
* rust-lang/rust#116317
* rust-lang/rust#116207
* rust-lang/rust#116281
* rust-lang/rust#116304
* rust-lang/rust#116259
* rust-lang/rust#116228
* rust-lang/rust#116224
* rust-lang/rust#115554
* rust-lang/rust#116311
  * rust-lang/rust#116299
  * rust-lang/rust#116295
  * rust-lang/rust#116292
* rust-lang/rust#116307
* rust-lang/rust#115670
* rust-lang/rust#116225
* rust-lang/rust#116302
* rust-lang/rust#116108
* rust-lang/rust#116160
* rust-lang/rust#116157
* rust-lang/rust#116127
* rust-lang/rust#116286
* rust-lang/rust#116254
* rust-lang/rust#116195
* rust-lang/rust#116280
* rust-lang/rust#115933
* rust-lang/rust#115546
* rust-lang/rust#115368
* rust-lang/rust#116275
  * rust-lang/rust#116263
  * rust-lang/rust#116241
  * rust-lang/rust#116216
  * rust-lang/rust#116030
  * rust-lang/rust#116024
  * rust-lang/rust#112123
* rust-lang/rust#113301
* rust-lang/rust#113797
* rust-lang/rust#115759
* rust-lang/rust#116260
  * rust-lang/rust#116253
  * rust-lang/rust#116245
  * rust-lang/rust#116239
  * rust-lang/rust#116234
  * rust-lang/rust#116231
  * rust-lang/rust#116201
  * rust-lang/rust#116133
* rust-lang/rust#116176
* rust-lang/rust#116089
* rust-lang/rust#115986

Co-authored-by: bors <bors@rust-lang.org>
Co-authored-by: ouz-a <ouz.agz@gmail.com>
Co-authored-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Co-authored-by: linkmauve <linkmauve@linkmauve.fr>
Co-authored-by: onur-ozkan <work@onurozkan.dev>
Co-authored-by: asquared31415 <34665709+asquared31415@users.noreply.github.com>
Co-authored-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Co-authored-by: Ralf Jung <post@ralfj.de>
Co-authored-by: Nadrieril <nadrieril+git@gmail.com>
Co-authored-by: Raekye <Raekye@users.noreply.github.com>
Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
Co-authored-by: Zalathar <Zalathar@users.noreply.github.com>
bors-ferrocene bot added a commit to ferrocene/ferrocene that referenced this pull request Oct 9, 2023
23: Fix divergence from upstream `master` r=Dajamante a=pvdrz

* rust-lang/rust#116483
  * rust-lang/rust#116475
  * rust-lang/rust#116329
  * rust-lang/rust#116198
  * rust-lang/rust#115588
  * rust-lang/rust#115522
  * rust-lang/rust#115454
* rust-lang/rust#111595
* rust-lang/rust#116018
* rust-lang/rust#116472
  * rust-lang/rust#116469
  * rust-lang/rust#116421
* rust-lang/rust#116463
* rust-lang/rust#101150
* rust-lang/rust#116269
* rust-lang/rust#116417
* rust-lang/rust#116455
  * rust-lang/rust#116452
  * rust-lang/rust#116428
  * rust-lang/rust#116415
  * rust-lang/rust#116288
  * rust-lang/rust#116220
* rust-lang/rust#103046
* rust-lang/rust#114042
* rust-lang/rust#104153
* rust-lang/rust#116427
* rust-lang/rust#116443
  * rust-lang/rust#116432
  * rust-lang/rust#116431
  * rust-lang/rust#116429
  * rust-lang/rust#116296
  * rust-lang/rust#116223
* rust-lang/rust#116273
* rust-lang/rust#116184
* rust-lang/rust#116370
* rust-lang/rust#114417
* rust-lang/rust#115200
* rust-lang/rust#116413
* rust-lang/rust#116381
* rust-lang/rust#116360
* rust-lang/rust#116353
* rust-lang/rust#116406
* rust-lang/rust#116408
  * rust-lang/rust#116395
  * rust-lang/rust#116393
  * rust-lang/rust#116388
  * rust-lang/rust#116365
  * rust-lang/rust#116363
  * rust-lang/rust#116146
  * rust-lang/rust#115961
* rust-lang/rust#116386
* rust-lang/rust#116367
* rust-lang/rust#105394
* rust-lang/rust#115301
* rust-lang/rust#116384
  * rust-lang/rust#116379
  * rust-lang/rust#116328
  * rust-lang/rust#116282
  * rust-lang/rust#116261
  * rust-lang/rust#114654
* rust-lang/rust#116376
  * rust-lang/rust#116374
  * rust-lang/rust#116371
  * rust-lang/rust#116358
  * rust-lang/rust#116210
  * rust-lang/rust#115863
* rust-lang/rust#115025
* rust-lang/rust#116372
  * rust-lang/rust#116361
  * rust-lang/rust#116355
  * rust-lang/rust#116351
  * rust-lang/rust#116158
  * rust-lang/rust#115726
  * rust-lang/rust#113053
* rust-lang/rust#116083
* rust-lang/rust#102099
* rust-lang/rust#116356
  * rust-lang/rust#116350
  * rust-lang/rust#116349
  * rust-lang/rust#116289
  * rust-lang/rust#114454
  * rust-lang/rust#114453
* rust-lang/rust#116331
* rust-lang/rust#116346
  * rust-lang/rust#116340
  * rust-lang/rust#116326
  * rust-lang/rust#116313
* rust-lang/rust#116276
* rust-lang/rust#115898
* rust-lang/rust#116325
* rust-lang/rust#116317
* rust-lang/rust#116207
* rust-lang/rust#116281
* rust-lang/rust#116304
* rust-lang/rust#116259
* rust-lang/rust#116228
* rust-lang/rust#116224
* rust-lang/rust#115554
* rust-lang/rust#116311
  * rust-lang/rust#116299
  * rust-lang/rust#116295
  * rust-lang/rust#116292
* rust-lang/rust#116307
* rust-lang/rust#115670
* rust-lang/rust#116225
* rust-lang/rust#116302
* rust-lang/rust#116108
* rust-lang/rust#116160
* rust-lang/rust#116157
* rust-lang/rust#116127
* rust-lang/rust#116286
* rust-lang/rust#116254
* rust-lang/rust#116195
* rust-lang/rust#116280
* rust-lang/rust#115933
* rust-lang/rust#115546
* rust-lang/rust#115368
* rust-lang/rust#116275
  * rust-lang/rust#116263
  * rust-lang/rust#116241
  * rust-lang/rust#116216
  * rust-lang/rust#116030
  * rust-lang/rust#116024
  * rust-lang/rust#112123
* rust-lang/rust#113301
* rust-lang/rust#113797
* rust-lang/rust#115759
* rust-lang/rust#116260
  * rust-lang/rust#116253
  * rust-lang/rust#116245
  * rust-lang/rust#116239
  * rust-lang/rust#116234
  * rust-lang/rust#116231
  * rust-lang/rust#116201
  * rust-lang/rust#116133
* rust-lang/rust#116176
* rust-lang/rust#116089
* rust-lang/rust#115986

35: Automated pull from `rust-lang/libc` r=pietroalbini a=github-actions[bot]

This PR pulls the following changes from the [`rust-lang/libc`](https://github.com/rust-lang/libc) repository:

* rust-lang/libc#3335
* rust-lang/libc#3373
* rust-lang/libc#3360
* rust-lang/libc#3374
* rust-lang/libc#3375
* rust-lang/libc#3376
* rust-lang/libc#3377


Co-authored-by: ouz-a <ouz.agz@gmail.com>
Co-authored-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Co-authored-by: bors <bors@rust-lang.org>
Co-authored-by: linkmauve <linkmauve@linkmauve.fr>
Co-authored-by: onur-ozkan <work@onurozkan.dev>
Co-authored-by: asquared31415 <34665709+asquared31415@users.noreply.github.com>
Co-authored-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Co-authored-by: Ralf Jung <post@ralfj.de>
Co-authored-by: Nadrieril <nadrieril+git@gmail.com>
Co-authored-by: Raekye <Raekye@users.noreply.github.com>
Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
Co-authored-by: Zalathar <Zalathar@users.noreply.github.com>
Co-authored-by: Nikolay Arhipov <nikolajs.arhipovs@gmail.com>
Co-authored-by: Brian Cain <bcain@quicinc.com>
Co-authored-by: Steve Lau <stevelauc@outlook.com>
Co-authored-by: David CARLIER <devnexen@gmail.com>
Co-authored-by: Louis Dupré Bertoni <louisdb@lespetitspedestres.org>
Co-authored-by: Taiki Endo <te316e89@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 18, 2023
coverage: Move most per-function coverage info into `mir::Body`

Currently, all of the coverage information collected by the `InstrumentCoverage` pass is smuggled through MIR in the form of individual `StatementKind::Coverage` statements, which must then be reassembled by coverage codegen.

That's awkward for a number of reasons:
- While some of the coverage statements do care about their specific position in the MIR control-flow graph, many of them don't, and are just tacked onto the function's first BB as metadata carriers.
- MIR inlining can result in coverage statements being duplicated, so coverage codegen has to jump through hoops to avoid emitting duplicate mappings.
- MIR optimizations that would delete coverage statements need to carefully copy them into the function's first BB so as not to omit them from coverage reports.
- The order in which coverage codegen sees coverage statements is dependent on MIR optimizations/inlining, which can cause unnecessary churn in the emitted coverage mappings.
- We don't have a good way to annotate MIR-level functions with extra coverage info that doesn't belong in a statement.

---

This PR therefore takes most of the per-function coverage info and stores it in a field in `mir::Body` as `Option<Box<FunctionCoverageInfo>>`.

(This adds one pointer to the size of `mir::Body`, even when coverage is not enabled.)

Coverage statements still need to be injected into MIR in some cases, but only when they actually affect codegen (counters) or are needed to detect code that has been optimized away as unreachable (counters/expressions).

---

By the end of this PR, the information stored in `FunctionCoverageInfo` is:

- A hash of the function's source code (needed by LLVM's coverage map format)
- The number of coverage counters added by coverage instrumentation
- A table of coverage expressions, associating each expression ID with its operator (add or subtract) and its two operands
- The list of mappings, associating each covered code region with a counter/expression/zero value

---

~~This is built on top of rust-lang#115301, so I'll rebase and roll a reviewer once that lands.~~
r? `@ghost`
`@rustbot` label +A-code-coverage
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 18, 2023
coverage: Move most per-function coverage info into `mir::Body`

Currently, all of the coverage information collected by the `InstrumentCoverage` pass is smuggled through MIR in the form of individual `StatementKind::Coverage` statements, which must then be reassembled by coverage codegen.

That's awkward for a number of reasons:
- While some of the coverage statements do care about their specific position in the MIR control-flow graph, many of them don't, and are just tacked onto the function's first BB as metadata carriers.
- MIR inlining can result in coverage statements being duplicated, so coverage codegen has to jump through hoops to avoid emitting duplicate mappings.
- MIR optimizations that would delete coverage statements need to carefully copy them into the function's first BB so as not to omit them from coverage reports.
- The order in which coverage codegen sees coverage statements is dependent on MIR optimizations/inlining, which can cause unnecessary churn in the emitted coverage mappings.
- We don't have a good way to annotate MIR-level functions with extra coverage info that doesn't belong in a statement.

---

This PR therefore takes most of the per-function coverage info and stores it in a field in `mir::Body` as `Option<Box<FunctionCoverageInfo>>`.

(This adds one pointer to the size of `mir::Body`, even when coverage is not enabled.)

Coverage statements still need to be injected into MIR in some cases, but only when they actually affect codegen (counters) or are needed to detect code that has been optimized away as unreachable (counters/expressions).

---

By the end of this PR, the information stored in `FunctionCoverageInfo` is:

- A hash of the function's source code (needed by LLVM's coverage map format)
- The number of coverage counters added by coverage instrumentation
- A table of coverage expressions, associating each expression ID with its operator (add or subtract) and its two operands
- The list of mappings, associating each covered code region with a counter/expression/zero value

---

~~This is built on top of rust-lang#115301, so I'll rebase and roll a reviewer once that lands.~~
r? `@ghost`
`@rustbot` label +A-code-coverage
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) merged-by-bors This PR was explicitly merged by bors. 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.

None yet

7 participants