Skip to content
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

[CONTRACTS] DFCC loop assigns infererence with functions inlined #8490

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

qinheping
Copy link
Collaborator

@qinheping qinheping commented Oct 31, 2024

Current loop assigns inference of DFCC can only infer targets considering only instructions in the same function. However, variables may be written to in the call of another function from function call inside the loop. So in this PR, we infer loop assigns based on a copy of the function and inlining all calls in the copy.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • 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).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Copy link

codecov bot commented Oct 31, 2024

Codecov Report

Attention: Patch coverage is 84.69388% with 15 lines in your changes missing coverage. Please review.

Project coverage is 78.80%. Comparing base (018c61c) to head (0444fad).

Files with missing lines Patch % Lines
...ntracts/dynamic-frames/dfcc_infer_loop_assigns.cpp 84.70% 13 Missing ⚠️
...trument/contracts/dynamic-frames/dfcc_cfg_info.cpp 84.61% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8490      +/-   ##
===========================================
- Coverage    78.90%   78.80%   -0.11%     
===========================================
  Files         1727     1727              
  Lines       198425   198785     +360     
  Branches     18523    18529       +6     
===========================================
+ Hits        156561   156643      +82     
- Misses       41864    42142     +278     

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

@qinheping qinheping force-pushed the DFCC_loop_assigns_infer branch 6 times, most recently from cea198b to 0444fad Compare November 5, 2024 06:34
@qinheping
Copy link
Collaborator Author

We also switch to a more aggressive loop-assigns widening strategy that also widens all dereference to whole object. The reason to do so is that it fits better for Kani loop contracts, while we have a good loop assigns specification support for C loop contracts for which the inference is less needed.

@@ -10,7 +10,7 @@ void main()
data[4] = 0;

for(unsigned i = 0; i < SIZE; i++)
__CPROVER_loop_invariant(i <= SIZE)
__CPROVER_assigns(data[1], i) __CPROVER_loop_invariant(i <= SIZE)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this change now strictly necessary given the additional widening?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, new addition widening will infer object_whole(data), i which is not accurate for this test.

@qinheping qinheping merged commit f5f0672 into diffblue:develop Nov 5, 2024
38 checks passed
@qinheping qinheping deleted the DFCC_loop_assigns_infer branch November 5, 2024 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Contracts Function and loop contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants