-
Notifications
You must be signed in to change notification settings - Fork 274
Use type equality, not base_type_eq in local safe pointers #4164
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
Use type equality, not base_type_eq in local safe pointers #4164
Conversation
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.
When tests pass, of course. Thanks for removing the pointless copying of local_safe_pointers
, I'd been meaning to fix that!
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.
Don't see anything blocking in this PR - though seems like quite a lot tangled up into one commit which made this a little difficult to review.
@@ -240,7 +240,7 @@ void goto_symext::symex_function_call_code( | |||
state.dirty.populate_dirty_for_function(identifier, goto_function); | |||
|
|||
auto emplace_safe_pointers_result = | |||
state.safe_pointers.emplace(identifier, local_safe_pointerst{ns}); | |||
path_storage.safe_pointers.emplace(identifier, local_safe_pointerst{}); |
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.
⛏️ AFAICT this variable renaming should be done in a seperate commit, ideally with an explanation of why this name is more accurate (I don't know this code well enough to comment on whether this is a good renaming or not). 🕊️
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.
Ah, no, this isn't variable renaming, it's an ownership change. safe_pointers
used to belong to goto_symex_statet
, but is now moved to path_storaget
.
src/goto-symex/symex_main.cpp
Outdated
@@ -178,7 +178,7 @@ void goto_symext::initialize_entry_point( | |||
state.top().hidden_function = entry_point_function.is_hidden(); | |||
|
|||
auto emplace_safe_pointers_result = | |||
state.safe_pointers.emplace(function_id, local_safe_pointerst{ns}); | |||
path_storage.safe_pointers.emplace(function_id, local_safe_pointerst{}); |
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.
⛏️ 🕊️
@@ -90,6 +92,8 @@ class path_storaget | |||
/// Counter for nondet objects, which require unique names | |||
symex_nondet_generatort build_symex_nondet; | |||
|
|||
std::unordered_map<irep_idt, local_safe_pointerst> safe_pointers; |
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.
⛏️ You might choose to doxygen this variable, safe_pointers
doesn't mean mich to me, but perhaps just a reference to a definition of a "safe pointer" would be a good addition here.
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.
Documentation added.
expr_is_not_null = | ||
state.safe_pointers.at(expr_function).is_safe_dereference( | ||
to_check, state.source.pc); | ||
expr_is_not_null = path_storage.safe_pointers.at(expr_function) |
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.
🕊️
src/analyses/local_safe_pointers.h
Outdated
/// their subexpressions, are identical except that one may use a symbol_typet | ||
/// while the other uses that type's expanded (namespacet::follow'd) form. | ||
class base_type_comparet | ||
class type_comparet |
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 this class even need to exist? Except the ordering is on the exprs, unless the types match - this is somewhat surprising. Out of scope of this PR, but I wonder if this is really what's needed here...
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.
It now still is a class, but with a near-trivial inline implementation of the comparison. What approach other than a class would you have thought of?
@@ -317,7 +315,6 @@ inline goto_statet::goto_statet(const class goto_symex_statet &s) | |||
source(s.source), | |||
propagation(s.propagation), | |||
atomic_section_id(s.atomic_section_id), | |||
safe_pointers(s.safe_pointers), |
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.
⛏️ Ideally this removal would have gone in a different commit with an explanation of why not required.
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.
This PR is now composed of three commits:
- Removing the
base_type_eq
comparison fromlocal_safe_pointerst
. - Small bits of cleanup in
local_safe_pointerst
. - Moving the storage from
goto_symex_statet
topath_storaget
.
…ming Reinstate limited symex renaming [blocks: #4164]
e9755ae
to
393da45
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: 393da45).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100642937
We no longer need to resort to tag/symbol type resolution.
1) Inline (now trivial) comparision function. 2) Use skip_typecast.
As local_safe_pointerst no longer needs a namespace we can do a partial revert of 959c7a5 (Bugfix: Maintain safe_pointers per-path). On SV-COMP's ReachSafety-ECA, copying safe_pointers accounted for 14% of the time spent in goto_symext::symex_goto (715 of 5119 seconds).
393da45
to
e1bfc15
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: e1bfc15).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/100810800
We no longer need to resort to tag/symbol type resolution. This enables partial
revert of 959c7a5 (Bugfix: Maintain safe_pointers per-path) as we no
longer need to maintain a namespacet in local_safe_pointerst. On SV-COMP's
ReachSafety-ECA, copying safe_pointers accounted for 14% of the time spent in
goto_symext::symex_goto (715 of 5119 seconds).
Requires #3966 to be merged for Java tests to pass.