Skip to content

Tighten up global extern detection in phi_function #3752

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

Conversation

JohnDumbell
Copy link
Contributor

@JohnDumbell JohnDumbell commented Jan 10, 2019

The external check was a little too broad and some gen 0 dynamic objects were getting put into guards accidentally. The tests that would have helped show something had changed were also quite badly out of date which didn't help matters.

@tautschnig I made sure your additional test passes, but please just check that the new condition is good for whatever you needed too. (I was thinking the the is_not_nil could go if global externs should never be considered for removal)

  • 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
Contributor

@allredj allredj left a 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: aa8ca8a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/96936683

@tautschnig
Copy link
Collaborator

@JohnDumbell Could you please rebase? It seems Travis is acting up.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

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

Sweet!
I checked this on one of my test files. Here are the times:

  • Before Michael's commit: 17s
  • After Michael's commit: 43s
  • With this fix: 10s

👍
I haven't tried the whole benchmark, but I'm confident that the performance regression is now resolved. Thanks!

@kroening
Copy link
Member

There is the potentially problematic assumption here that a statically allocated variable is initialised if the symbol's .value member is non-nil.
Harnesses etc. may tweak that.

@JohnDumbell JohnDumbell force-pushed the jd/enhancement/phi_merge_explicit_exclude_extern branch from aa8ca8a to 0e1b02a Compare January 11, 2019 10:01
Copy link
Contributor

@allredj allredj left a 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: 0e1b02a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/97023637

^.*:\s+dynamic_object[0-9]+(@[0-9]+)?#0\)
^.*\?\s+dynamic_object[0-9]+(@[0-9]+)?#0\s+:
\([^\s]+guard[^\s]+ \? [^\s]+#0 : [^\s]+\)
\([^\s]+guard[^\s]+ \? [^\s]+#0 : [^\s]+\)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and below: these are duplicates, should be checking for the else position

@smowton
Copy link
Contributor

smowton commented Jan 11, 2019

@kroening fair point, how about just saying all globals are merged "naturally" (i.e. it's up to the frontend to construct a program where global initialisation trivially dominates the rest of the program, which is usually true because it happens in __CPROVER_initialize and we ensure that function is mostly a straight line (e.g. any function it calls must not throw))

Locals, dynamic objects we can both guarantee that gen 0 is not reachable, as we always assign them an explicit nondet value when they are malloc / DECL'd

@smowton
Copy link
Contributor

smowton commented Jan 11, 2019

@JohnDumbell if accepted that would correspond to generation == 0 && !symbol.is_static_lifetime

@JohnDumbell JohnDumbell force-pushed the jd/enhancement/phi_merge_explicit_exclude_extern branch from 0e1b02a to 2f819cf Compare January 11, 2019 12:41
Copy link
Contributor

@allredj allredj left a 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: 2f819cf).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/97038298

@smowton
Copy link
Contributor

smowton commented Jan 14, 2019

@JohnDumbell I spoke to @kroening -- he's happy with the plan proposed above

The is_not_nil check was a little broad and causing uninitialized values to get merged in some situations. Made the condition for being an external global stricter.
The tests that should have caught this were too specific when checking for the names of the variables and at some point in the past dynamic_object got given a prefix, which meant that the check to make sure no zero generation existed always passed (even with a #0 there) because the variable name wasn't exact.

Made the matching far more forgiving and it now looks for anything that vaguely looks like a guard statement with a 0 generation object.
@JohnDumbell JohnDumbell force-pushed the jd/enhancement/phi_merge_explicit_exclude_extern branch from 2f819cf to 466ac7a Compare January 14, 2019 16:27
Copy link
Contributor

@allredj allredj left a 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: 466ac7a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/97288170

@tautschnig tautschnig merged commit 00eff3f into diffblue:develop Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants