Page MenuHomePhabricator

[GCOV] Don't add a useless block in the entry

Authored by calixte on Sep 14 2018, 5:53 AM.



Currently, we split the entry block of a function to be sure to have at least one edge. In fact it's useless since we can add this edge in gcno/gcda without creating it.
There are several pros to do that:

  • slightly reduce gcno/gcda size (close to nothing...).
  • fix a crash when there are several CU attached to a module (the entry block was splitted several times)
  • when using -femit-coverage-data the entry was not splitted since it's currently done when emitting coverage notes, so no instrumentation added when there was only on block.

Diff Detail

Event Timeline

calixte created this revision.Sep 14 2018, 5:53 AM

I'm not really familiar with the gcov file format, but this change looks reasonable.



There are four possible terminators for a block with no successors: ret, unreachable, resume, and cleanupret. Writing good testcases for exception handling is probably hard, but it would be nice to at least ensure we generate something sane for a function that explicitly calls exit().


(Needs to be fixed.)

marco-c accepted this revision.Sep 20 2018, 2:42 AM

This looks good to me, modulo the changes requested by efriedma (and the additional tests to write).

It might be useful to stress test the patch on our CI to see if there are corner cases we haven't thought of.

This revision is now accepted and ready to land.Sep 20 2018, 2:42 AM
marco-c added inline comments.Sep 20 2018, 2:42 AM

Nit: I'd keep this the other way around, to have a smaller diff