Skip to content

Symex: shortcut the common case of whole-struct initialisation #4567

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

Conversation

smowton
Copy link
Contributor

@smowton smowton commented Apr 24, 2019

Rather than assign a temporary symbol and then expand it, directly extract the fields
and assign them. This cuts the time taken on one initialisation-heavy benchmark to symex and print VCCs from 3.6s to 3.2s.

lhs_field.id() == ID_symbol,
"member of symbol should be susceptible to field-sensitivity");

const exprt &rhs_field = rhs.operands()[i];
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you'd want a PRECONDITION(rhs.operands().size() == components.size());

const struct_typet &type = to_struct_type(ns.follow(lhs.type()));
const struct_union_typet::componentst &components = type.components();

for(std::size_t i = 0; i < components.size(); ++i)
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about using a ranged for and an iterator over rhs.operands()?

/// This abbreviates the process, directly producing
/// `x..field1 = 1; x..field2 = 2;`
/// \param state: goto-symex state
/// \param lhs: symbol to assign
Copy link
Contributor

Choose a reason for hiding this comment

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

You should mention that it should be L1-renamed already here

Rather than assign a temporary symbol and then expand it, directly extract the fields
and assign them. This cuts the time taken on one initialisation-heavy benchmark from 3.6s
to 3.2s.
@smowton smowton force-pushed the smowton/feature/shortcut-struct-init branch from 0b6ab81 to a1deabe Compare April 29, 2019 09:42
@smowton smowton merged commit 89d349b into diffblue:develop Apr 29, 2019
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