[PATCH] D23160: [Coverage] Prevent creating a redundant counter if a nested body ends with a macro.

Igor Kudrin via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 4 22:43:46 PDT 2016


ikudrin added a comment.

In https://reviews.llvm.org/D23160#506061, @vsk wrote:

> I guess it never makes sense to have two regions with the exact same start/end loc, and different counters. Do you think we should add assertions in llvm (either in llvm-cov, or in the coverage reader) which guard against this?


Right now we can have several ranges with the same start and end locations in case of macro fully expanded into another macro. We consider this situation possible and handle it in class `SegmentBuilder` in llvm/lib/ProfileData/Coverage/CoverageMapping.cpp. Maybe something has to be fixed here too.

By the way, thinking about your words, I found another example which results in spawning not only redundant but also wrong counters. I'm postponing landing this patch until I finish the investigation.

      4|    1|void dummy() {}
       |    2|
      4|    3|#define M_INT dummy()
       |    4|
     11|    5|#define MACRO M_INT
       |    6|
       |    7|int main()
      1|    8|{
      1|    9|  int i = 0;
     11|   10|  while (i++ < 10)
     10|   11|    if (i < 5)
     10|   12|      MACRO;
  ------------------
  |  |     11|    5|#define MACRO M_INT
  |  |  ------------------
  |  |  |  |      4|    3|#define M_INT dummy()
  |  |  ------------------
  ------------------
      1|   13|  return 0;
      1|   14|}


https://reviews.llvm.org/D23160





More information about the cfe-commits mailing list