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

llvm-cov assertion failure when handling MC/DC that involves macros #80098

Closed

Commits on Jan 31, 2024

  1. [Coverage][llvm-cov] Fix failures to handle MC/DC decisions involving…

    … macros (1/2)
    
    This patch lets MC/DC code regions for the same composite logical
    expression get sorted next to each other, so that `llvm-cov show` won't
    hit assertion failures.
    
    The problematic cases are mostly when macros are involved:
    
      (FOO(x) && BAR(y))
    
       <-R2->    <-R3->
      <-------R1------->
    
    Let's call the full expression Region 1, `FOO(x)` Region 2 and `BAR(y)`
    Region 3. If these macros are defined far away from their invocations,
    the eventual order of all regions would look like: Region 1, (many other
    irrelevant regions), Region 2, Region 3. This will break an assertion in
    CoverageMapping::loadFunctionRecord() which assumes branch regions of an
    MC/DC decision would immediately follow the decision region itself.
    
    This patch adds a new field `GroupID` to `MCDCParameters` struct, sort
    all regions based on this information, and place related MC/DC regions
    together. The `GroupID` assignment is included in the other patch to
    Clang CodeGen. This patch also disables 3 assertions that's based on the
    old sorting criteria.
    whentojump committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    daf74be View commit details
    Browse the repository at this point in the history
  2. [Coverage][clang] Fix failures to handle MC/DC decisions involving ma…

    …cros (2/2)
    
    This patch lets MC/DC code regions for the same composite logical
    expression get sorted next to each other, so that `llvm-cov show` won't
    hit assertion failures.
    
    The problematic cases are mostly when macros are involved:
    
      (FOO(x) && BAR(y))
    
       <-R2->    <-R3->
      <-------R1------->
    
    Let's call the full expression Region 1, `FOO(x)` Region 2 and `BAR(y)`
    Region 3. If these macros are defined far away from their invocations,
    the eventual order of all regions would look like: Region 1, (many other
    irrelevant regions), Region 2, Region 3. This will break an assertion in
    CoverageMapping::loadFunctionRecord() which assumes branch regions of an
    MC/DC decision would immediately follow the decision region itself.
    
    An earlier patch adds a new field `GroupID` to `MCDCParameters` struct,
    sort all regions based on this information, and place related MC/DC
    regions together. This patch let Clang assign the same `GroupID` to
    decision- and branch-regions that are related to each other.
    whentojump committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    cd5a338 View commit details
    Browse the repository at this point in the history