Skip to content

Cleanup processing and use __builtin_X_overflow #6612

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 4 commits into from
Jan 28, 2022

Conversation

tautschnig
Copy link
Collaborator

With thanks to @danielsn for reminding me of this: on the back of #6607 we realised that our C front-end should also make use of those GCC built-ins to avoid doing duplicate work. For the C library this may improve performance when verification tasks use calloc or strtol.

Please review commit-by-commit.

  • 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.
  • 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).
  • 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 force-pushed the cleanup/c-library-overflow branch 4 times, most recently from efd093d to 582644e Compare January 26, 2022 18:20
@codecov
Copy link

codecov bot commented Jan 26, 2022

Codecov Report

Merging #6612 (291c72a) into develop (788cb49) will increase coverage by 0.00%.
The diff coverage is 98.46%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #6612   +/-   ##
========================================
  Coverage    76.64%   76.65%           
========================================
  Files         1578     1578           
  Lines       181199   181219   +20     
========================================
+ Hits        138875   138907   +32     
+ Misses       42324    42312   -12     
Impacted Files Coverage Δ
src/ansi-c/c_typecheck_base.h 100.00% <ø> (ø)
src/ansi-c/c_typecheck_expr.cpp 76.56% <98.46%> (+0.90%) ⬆️
src/solvers/flattening/boolbv_overflow.cpp 48.78% <0.00%> (-6.10%) ⬇️
src/goto-programs/goto_convert_side_effect.cpp 95.62% <0.00%> (+0.51%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 048b824...291c72a. Read the comment docs.

@tautschnig tautschnig self-assigned this Jan 26, 2022
@tautschnig tautschnig force-pushed the cleanup/c-library-overflow branch from 582644e to a932759 Compare January 27, 2022 17:56
Copy link
Contributor

@chrisr-diffblue chrisr-diffblue left a comment

Choose a reason for hiding this comment

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

Tiny nit-pick around naming, but feel free to ignore my personal preference there, as the code is still a massive step forward in readability.

@tautschnig tautschnig force-pushed the cleanup/c-library-overflow branch from a932759 to 1e8d3ab Compare January 27, 2022 19:52
Move the implementation to a method of its own. This avoids repeatedly
testing the name to derive the underlying arithmetic operation. This
change is to support upcoming extensions to handle further built-ins via
this code path. No changes in behaviour intended with just this commit,
and additional testing should ensure that this is also true for error
handling.

The function refactored from remains too large, and cpplint rightly
complains about that, but this issue cannot be fixed in a single commit.
Hence, adding an override.
…cker

The models in the C library incurred unnecessary overhead in that they
would do the arithmetic operation twice: once for the actual (possibly
overflowing) result, and once for determining the overflow bit.
@tautschnig tautschnig force-pushed the cleanup/c-library-overflow branch from 1e8d3ab to 9d91abc Compare January 27, 2022 19:57
We just need to provide the declarations in case the underlying compiler
isn't GCC.
The use of GCC built-ins allows us to avoid the duplicate multiplication
(and addition) that __CPROVER_overflow_OP plus the actual result
computation would entail.
@tautschnig tautschnig force-pushed the cleanup/c-library-overflow branch from 9d91abc to 291c72a Compare January 27, 2022 21:19
@tautschnig tautschnig merged commit 23306ee into diffblue:develop Jan 28, 2022
@tautschnig tautschnig deleted the cleanup/c-library-overflow branch January 28, 2022 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants