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

(DRAFT) Combined draft branch for coverage work #115428

Closed
wants to merge 13 commits into from

Commits on Oct 21, 2023

  1. Configuration menu
    Copy the full SHA
    7a4ec81 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6b2e80c View commit details
    Browse the repository at this point in the history
  3. coverage: Change query codegened_and_inlined_items to a plain function

    This query has a name that sounds general-purpose, but in fact it has
    coverage-specific semantics, and (fortunately) is only used by coverage code.
    
    Because it is only ever called once, it doesn't need to be a query, and we can
    change it to a regular function instead.
    Zalathar committed Oct 21, 2023
    Configuration menu
    Copy the full SHA
    15ffe3d View commit details
    Browse the repository at this point in the history
  4. coverage: Force -Copt-level=2 in the unreachable-code test

    This test is mainly for detecting problems triggered by MIR optimizations, but
    the run-coverage tests don't enable optimization by default.
    
    (The coverage-map tests do enable optimization by default, but I'm updating the
    test anyway so that the two `unreachable.rs` files don't drift out of sync.)
    Zalathar committed Oct 21, 2023
    Configuration menu
    Copy the full SHA
    11aeb69 View commit details
    Browse the repository at this point in the history
  5. coverage: Repair instrumented functions that have lost all their coun…

    …ters
    
    If a function has been instrumented for coverage, but MIR optimizations
    subsequently remove all of its counter-increment statements, then we won't emit
    LLVM counter-increment intrinsics. LLVM will think the function is not
    instrumented, and it will disappear from coverage mappings and coverage
    reports.
    
    This new MIR pass detects when that has happened, and re-inserts a dummy
    counter-increment statement so that LLVM knows to treat the function as
    instrumented.
    Zalathar committed Oct 21, 2023
    Configuration menu
    Copy the full SHA
    9886ac6 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    ea929a5 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    81b4ab7 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    c4f5e60 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    b8fc5a0 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    63ecc25 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    340b7d1 View commit details
    Browse the repository at this point in the history
  12. coverage: Emit the filenames section before encoding per-function map…

    …pings
    
    Most coverage metadata is encoded into two sections in the final executable.
    The `__llvm_covmap` section mostly just contains a list of filenames, while the
    `__llvm_covfun` section contains encoded coverage maps for each instrumented
    function.
    
    The catch is that each per-function record also needs to contain a hash of the
    filenames list that it refers to. Historically this was handled by assembling
    most of the per-function data into a temporary list, then assembling the
    filenames buffer, then using the filenames hash to emit the per-function data,
    and then finally emitting the filenames table itself.
    
    However, now that we build the filenames table up-front (via a separate
    traversal of the per-function data), we can hash and emit that part first, and
    then emit each of the per-function records immediately after building. This
    removes the awkwardness of having to temporarily store nearly-complete
    per-function records.
    Zalathar committed Oct 21, 2023
    Configuration menu
    Copy the full SHA
    639d00c View commit details
    Browse the repository at this point in the history
  13. coverage: Consolidate creation of __llvm_covmap records

    The code for creating these records was spread across multiple functions and
    multiple files, so this change moves as much of it as possible into one place.
    Zalathar committed Oct 21, 2023
    Configuration menu
    Copy the full SHA
    db35232 View commit details
    Browse the repository at this point in the history