-
Notifications
You must be signed in to change notification settings - Fork 269
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
Define coverage blocks so as to be terminated by assumptions #7810
Define coverage blocks so as to be terminated by assumptions #7810
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #7810 +/- ##
========================================
Coverage 79.09% 79.09%
========================================
Files 1701 1701
Lines 196625 196633 +8
========================================
+ Hits 155527 155535 +8
Misses 41098 41098 ☔ View full report in Codecov by Sentry. |
Hi @thomasspriggs ! If a goto-instrument pass adds assumptions in the middle of basic blocs, and the resulting model analysed with --cover locations, with the modification proposed in this PR would the basic blocks be split again in sub blocks before the cover analysis is executed ? After running instrumentation passes we usually call |
My understanding is that a hand-written assumption would be treated by the coverage checking in the same way as an assumption added by a proceeding pass. However the various check passes add assertions rather than assumptions. Therefore my source comment on multiple assumptions from instrumentation may not be accurate and I should re-visit the comment.
"basic blocks" as are defined for coverage instrumentation are held in a temporary data structure. This is generated at the start of the |
I have now run an example though this in order to confirm the behaviour. The assertions added by the instrumentation are converted to assumptions, which then become block boundaries. Source C fileint main()
{
int x;
int y;
y = x;
x = x / 0;
x = y;
assert(0);
return 0;
} Testing commands goto-cc ./instrumentation_example.c -o ./instrumentation_example.gb
goto-instrument --div-by-zero-check ./instrumentation_example.gb instrumentation_example_instrumented.gb
cbmc ./instrumentation_example_instrumented.gb --cover location The current output from a cbmc output
With the changes proposed in this PR, the output is - cbmc output
So the old output misleadingly suggests that all lines are reachable due to the single coverage block. With the update there are 3 blocks which are the result of splitting based on the instrumentation check and the user assertion. Do the changes in this PR resolve #7806 or is something different required? |
It seems this is the correct route forward, just needs tests. |
4693734
to
d6ee9e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not seem unreasonable
I doubt that the line number check meets the intent of #7806. I'd drop it. |
The alternative code which causes every assumption to be placed in a new block was ifdef'd out with a comment that it is "Disabled for being too messy". Indeed I tried this version and found that it introduced many new blocks due to check instrumentations adding multiple assertions which become assumptions before coverage checking. Many of these will be on the same source line of code. My reasoning is effectively that Are you suggesting that I remove the line number check from my implementation such that user assertions/assumptions from separate lines of code are combined together resulting in fewer blocks? Or are you asking for the version which is ifdef'd out which result in many more blocks? #7806 was raised by @remi-delmas-3000 who has confirmed that this PR as it currently stands works for the issue. |
More blocks. I'd keep in mind that the reader of the output is likely a tool. |
If a coverage block has an assumption in the middle then then an assertion at the end of the block could be reported as covered but actually be unreachable due to the preceding the assumption. Therefore coverage blocks should be terminated by assumptions in order to ensure than coverage reporting is accurate.
d6ee9e9
to
ac26185
Compare
Given that this PR is approved, I am going to merge it. If we want more blocks, then this alternative PR can be rebased on top of develop instead - #7944 |
If a coverage block has an assumption in the middle then then an assertion at the end of the block could be reported as covered but actually be unreachable due to the preceding the assumption. Therefore coverage blocks should be terminated by assumptions in order to ensure than coverage reporting is accurate.
Addresses #7806