[PATCH] D101780: [CoverageMapping] Handle gaps in counter IDs for source-based coverage

Rich Kadel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 11 16:25:46 PDT 2021


richkadel added a comment.

An "edge counter", as I'm calling it, is a counter (not an expression). It gets converted into a call to the `instrprof.increment` intrinsic (so there is executable code behind it), but there is no source code represented by that count.

I don't think this is unique to Rust, but I'm not sure how quickly I can come up with an example in code. From a CFG perspective:

    B
   / \
  C   D

We can use an expression to compute the count for one of the branches:

D = B - C

But that assumes C is only reached by B.

Consider a loop. The block inside the loop is reached via 2 or more edges: 1) from above the loop; 2) from the bottom of the loop (the backedge); and maybe from one or more `continue` statements.

So you can have something like this:

  A   B
   \ / \
    C   D

Now the previous expression won't work.

I could count D, and then compute:

C = A + (B - D)

But this isn't always possible or practical (from my experience).

But if I create a counter that counts the edge B->C, I can do this:

C = A + B->C
D = B - B->C

The B->C edge counter is an actual `instrprof.increment` counter in the LLVM IR, and it represents part of the control flow of the program, but there is no way to tie that to a code region, and it wouldn't be useful in a report. The counters/regions that USE the edge counter are what you want to know.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101780/new/

https://reviews.llvm.org/D101780



More information about the llvm-commits mailing list