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

Move Coverage Regions / Expressions to a side table #115170

Closed
wants to merge 11 commits into from

Commits on Aug 23, 2023

  1. Configuration menu
    Copy the full SHA
    cc832c5 View commit details
    Browse the repository at this point in the history
  2. 🍒 Add test suite coverage-map to test coverage mappings emitted by …

    …LLVM
    
    We compile each test file to LLVM IR assembly, and then pass that IR to a
    dedicated program that can decode LLVM coverage maps and print them in a more
    human-readable format. We can then check that output against known-good
    snapshots.
    
    This test suite has some advantages over the existing `run-coverage` tests:
    
    - We can test coverage instrumentation without needing to run target binaries.
    
    - We can observe subtle improvements/regressions in the underlying coverage
    mappings that don't make a visible difference to coverage reports.
    Zalathar committed Aug 23, 2023
    Configuration menu
    Copy the full SHA
    d348d9f View commit details
    Browse the repository at this point in the history
  3. 🍒 Copy a selection of run-coverage test files into coverage-map

    The output of these tests is too complicated to comfortably verify by hand, but
    we can still use them to observe changes to the underlying mappings produced by
    codegen/LLVM.
    Zalathar committed Aug 23, 2023
    Configuration menu
    Copy the full SHA
    05b398e View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f268c0a View commit details
    Browse the repository at this point in the history
  5. coverage: Explicitly simplify coverage expressions in codegen

    After coverage instrumentation and MIR transformations, we can sometimes end up
    with coverage expressions that always have a value of zero. Any expression
    operand that refers to an always-zero expression can be replaced with a literal
    `Operand::Zero`, making the emitted coverage mapping data smaller and simpler.
    
    This simplification step is mostly redundant with the simplifications performed
    inline in `expressions_with_regions`, except that it does a slightly more
    thorough job in some cases (because it checks for always-zero expressions
    *after* other simplifications).
    
    However, adding this simplification step will then let us greatly simplify that
    code, without affecting the quality of the emitted coverage maps.
    Zalathar committed Aug 23, 2023
    Configuration menu
    Copy the full SHA
    f39b246 View commit details
    Browse the repository at this point in the history
  6. coverage: Don't bother renumbering expressions on the Rust side

    The LLVM API that we use to encode coverage mappings already has its own code
    for removing unused coverage expressions and renumbering the rest.
    
    This lets us get rid of our own complex renumbering code, making it easier to
    refactor our coverage code in other ways.
    Zalathar committed Aug 23, 2023
    Configuration menu
    Copy the full SHA
    5e63f64 View commit details
    Browse the repository at this point in the history
  7. Generalize Coverage Expression simplification

    This extends the current simplification code to not only replace operands by `Zero`, but also to remove trivial `Counter + Zero` expressions and replace those with just `Counter`.
    
    Currently this simplification is very simplistic, and does not handle more complex nested expressions such as `(A + B) - B` which could in theory be simplified as well.
    Swatinem committed Aug 23, 2023
    Configuration menu
    Copy the full SHA
    bae94ee View commit details
    Browse the repository at this point in the history

Commits on Aug 24, 2023

  1. Treat StatementKind::Coverage as completely opaque for SMIR purposes

    Coverage statements in MIR are heavily tied to internal details of the coverage
    implementation that are likely to change, and are unlikely to be useful to
    third-party tools for the foreseeable future.
    Zalathar authored and Swatinem committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    31dd815 View commit details
    Browse the repository at this point in the history
  2. Inline functions called from add_coverage

    This removes quite a bit of indirection and duplicated code related to getting the `FunctionCoverage`.
    Swatinem committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    43b773f View commit details
    Browse the repository at this point in the history
  3. Move Coverage Regions / Expressions to a side table

    Instead of encoding `CodeRegion`s and `CoverageExpression`s directly in a MIR `Coverage` statement, this moves this metadata to a side table. The `Coverage` statement is now only used to inject physical counters during codegen.
    Swatinem committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    74e5fef View commit details
    Browse the repository at this point in the history
  4. bless coverage map tests

    Swatinem committed Aug 24, 2023
    Configuration menu
    Copy the full SHA
    e0bade3 View commit details
    Browse the repository at this point in the history