Skip to content

change type of numerical architecture symbols to integer #7215

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 3 commits into from
Oct 11, 2022

Conversation

kroening
Copy link
Member

@kroening kroening commented Oct 6, 2022

Following a suggestion in ##5878, this changes the type of the numerical _CPROVER_architecture symbols from int (which is itself architecture-dependent) to integer (which does not depend on the architecture).

Closes #5878

  • 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
Copy link
Collaborator

Sure, we could do this, but it will require updating the goto binary version (and re-compiling binaries that are part of regression tests).

@tautschnig tautschnig assigned kroening and unassigned tautschnig Oct 7, 2022
@kroening
Copy link
Member Author

kroening commented Oct 8, 2022

Sure, we could do this, but it will require updating the goto binary version (and re-compiling binaries that are part of regression tests).

No need -- this is compatible both ways (old versions can read new binaries, and old binaries can be read by new versions).

@tautschnig
Copy link
Collaborator

Sure, we could do this, but it will require updating the goto binary version (and re-compiling binaries that are part of regression tests).

No need -- this is compatible both ways (old versions can read new binaries, and old binaries can be read by new versions).

Linking won't work for the architecture symbols now have conflicting types. We might gloss over that and would then just need to recompile the goto binaries in our regression tests.

Further fixes that seem to be necessary:

  1. Intervals don't know about integer_typet, which can be fixed as follows:
--- a/src/util/interval.cpp
+++ b/src/util/interval.cpp
@@ -1094,7 +1094,7 @@ bool constant_interval_exprt::is_numeric(

 bool constant_interval_exprt::is_int(const typet &type)
 {
-  return (is_signed(type) || is_unsigned(type));
+  return is_signed(type) || is_unsigned(type) || type.id() == ID_integer;
 }

 bool constant_interval_exprt::is_float(const typet &src)
  1. The C++ front-end rejects the type conversion in the assignment of the architecture string.

@nwetzler nwetzler self-requested a review October 10, 2022 07:10
@kroening kroening force-pushed the architecture_integer branch 2 times, most recently from d507f87 to 4ad807a Compare October 10, 2022 09:05
@@ -113,7 +113,8 @@ static std::string architecture_string(const std::string &value, const char *s)
template <typename T>
static std::string architecture_string(T value, const char *s)
{
return std::string("const int " CPROVER_PREFIX "architecture_") +
return std::string("const __CPROVER_integer " CPROVER_PREFIX
Copy link
Collaborator

@tautschnig tautschnig Oct 10, 2022

Choose a reason for hiding this comment

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

I think this should also use CPROVER_PREFIX in the first case of "__CPROVER_" (actually the failing cpplint job says the same :-) )

@kroening kroening force-pushed the architecture_integer branch from 4ad807a to be35902 Compare October 10, 2022 09:16
@kroening kroening marked this pull request as ready for review October 10, 2022 09:16
@kroening kroening force-pushed the architecture_integer branch 2 times, most recently from 1a42130 to c50d2e1 Compare October 10, 2022 20:25
This extends the C++ front-end to recognize __CPROVER_integer and
__CPROVER_rational, in the same way as done in the C frontend.
This enables using unbounded integers instead of bitvectors for
architecture-independent constants.
Following a suggestion in ##5878, this changes the type of the numerical
__CPROVER_architecture_ symbols from int (which is itself
architecture-dependent) to integer (which does not depend on the
architecture).

Closes #5878
@kroening kroening force-pushed the architecture_integer branch from c50d2e1 to a4ffe59 Compare October 11, 2022 08:23
@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Base: 77.92% // Head: 77.97% // Increases project coverage by +0.04% 🎉

Coverage data is based on head (a4ffe59) compared to base (dcf2b46).
Patch coverage: 75.53% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7215      +/-   ##
===========================================
+ Coverage    77.92%   77.97%   +0.04%     
===========================================
  Files         1616     1616              
  Lines       186777   186837      +60     
===========================================
+ Hits        145550   145683     +133     
+ Misses       41227    41154      -73     
Impacted Files Coverage Δ
src/analyses/interval_analysis.cpp 0.00% <0.00%> (ø)
src/ansi-c/ansi_c_internal_additions.cpp 90.12% <ø> (ø)
src/goto-instrument/contracts/utils.h 100.00% <ø> (ø)
src/goto-instrument/race_check.cpp 0.00% <0.00%> (ø)
.../goto-instrument/synthesizer/synthesizer_utils.cpp 92.85% <ø> (ø)
src/goto-instrument/thread_instrumentation.cpp 0.00% <0.00%> (ø)
src/goto-instrument/undefined_functions.cpp 0.00% <0.00%> (ø)
src/goto-programs/string_instrumentation.cpp 25.11% <0.00%> (ø)
src/linking/linking_class.h 100.00% <ø> (ø)
src/util/c_types.cpp 91.16% <ø> (ø)
... and 77 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kroening kroening merged commit d9fee7c into develop Oct 11, 2022
@kroening kroening deleted the architecture_integer branch October 11, 2022 10:46
@feliperodri feliperodri added the aws Bugs or features of importance to AWS CBMC users label Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws Bugs or features of importance to AWS CBMC users C Front End
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] CBMC architecture configuration uses architecture-specific int width
3 participants