Skip to content

Maintain loop invariant annotation when converting do .. while #8417

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

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

tautschnig
Copy link
Collaborator

@tautschnig tautschnig commented Aug 19, 2024

With the changes in bbd9de4 we newly made do .. while converted instructions subject to optimize_guarded_gotos, which previously rewrote conditions without retaining annotations related to loop invariants.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@tautschnig tautschnig self-assigned this Aug 19, 2024
@tautschnig tautschnig force-pushed the fix-do-while-loop-invariant branch from bfd5e66 to 612191a Compare August 20, 2024 07:20
@tautschnig tautschnig force-pushed the fix-do-while-loop-invariant branch 2 times, most recently from 60d7d4a to 88d2091 Compare August 20, 2024 08:16
@tautschnig tautschnig removed their assignment Aug 20, 2024
Copy link

codecov bot commented Aug 20, 2024

Codecov Report

Attention: Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.

Project coverage is 77.88%. Comparing base (89a0470) to head (6009066).
Report is 3 commits behind head on develop.

Files Patch % Lines
src/ansi-c/goto-conversion/goto_convert.cpp 87.50% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8417      +/-   ##
===========================================
- Coverage    77.93%   77.88%   -0.05%     
===========================================
  Files         1726     1726              
  Lines       189657   189804     +147     
  Branches     18255    18234      -21     
===========================================
+ Hits        147805   147826      +21     
- Misses       41852    41978     +126     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@remi-delmas-3000 remi-delmas-3000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The do-while loop test can be made to work with x < 10. in the invariant

@@ -7,3 +7,4 @@ main.c
--
--
This test checks that loop contracts work correctly on do/while loops.
Fails because contracts are not yet supported on do while loops.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contracts are supported on do-while thanks to latch normalization, here you need to fix the loop invariant to 0 <= x && x < 10

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed for the dfcc variant.

With the changes in bbd9de4 we newly made do .. while converted
instructions subject to `optimize_guarded_gotos`, which previously
rewrote conditions without retaining annotations related to loop
invariants.

The included tests now show that the annotations are preserved, but
still fail for an unrelated bug in how do .. while loops are
instrumented.
The incoming edge from a `goto` instruction may also be the
non-branching case, which must not result in redirecting this goto.
@tautschnig tautschnig force-pushed the fix-do-while-loop-invariant branch from 88d2091 to 6009066 Compare August 21, 2024 07:15
@tautschnig tautschnig merged commit 2bef701 into diffblue:develop Aug 21, 2024
39 of 40 checks passed
@tautschnig tautschnig deleted the fix-do-while-loop-invariant branch August 21, 2024 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants