This is an archive of the discontinued LLVM Phabricator instance.

[Coverage] The coverage region for a switch should cover the code after the switch
ClosedPublic

Authored by arphaman on Sep 27 2016, 12:57 PM.

Details

Summary

This patch fixes a regression introduced in r262697 that changed the way the coverage regions for switch are constructed. The PGO instrumentation counter for switch statements refers to a counter at the exit of the switch, and thus the coverage region for the switch statement should cover the code that comes after the switch, and not the switch statement itself.

This patch should fix the issue exposed by the new coverage bot where the switches with all cases returning get zero coverage: http://lab.llvm.org:8080/coverage/coverage-reports/clang/coverage/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp.html#L520.

Diff Detail

Repository
rL LLVM

Event Timeline

arphaman updated this revision to Diff 72692.Sep 27 2016, 12:57 PM
arphaman retitled this revision from to [Coverage] The coverage region for a switch should cover the code after the switch.
arphaman updated this object.
arphaman added a reviewer: vsk.
arphaman set the repository for this revision to rL LLVM.
arphaman added a subscriber: cfe-commits.
vsk accepted this revision.Sep 27 2016, 1:27 PM
vsk edited edge metadata.

LGTM, thank you!

It makes sense to inherit the current region's counter when we see a new switch. That should fix the 0 execution count we see on the condition.

This revision is now accepted and ready to land.Sep 27 2016, 1:27 PM
This revision was automatically updated to reflect the committed changes.