Skip to content
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

Goto crossing scopes: fix scope tree entry of conditions #8187

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

tautschnig
Copy link
Collaborator

We must convert the condition of an if/then/else first to make sure any declarations produced by converting the condition have a suitable scope-tree node. Previously, gotos in either branch of the if-then-else were led to believe that declarations resulting from condition were not yet in scope. The feature from #8091 would, thus, result in a spurious loop back to the declaration to put it in scope before following the goto edge.

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

Copy link

codecov bot commented Feb 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.33%. Comparing base (4eadc8a) to head (727982e).
Report is 1 commits behind head on develop.

Current head 727982e differs from pull request most recent head 1f5950c

Please upload reports for the commit 1f5950c to get more accurate results.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8187      +/-   ##
===========================================
- Coverage    78.34%   78.33%   -0.02%     
===========================================
  Files         1722     1722              
  Lines       188394   188393       -1     
  Branches     18493    18430      -63     
===========================================
- Hits        147600   147569      -31     
- Misses       40794    40824      +30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tautschnig tautschnig force-pushed the bugfixes/no-spurious-loops branch from ecc35f2 to 5108c55 Compare February 6, 2024 16:18
@kroening
Copy link
Member

kroening commented Feb 8, 2024

I find it odd that the order of conversion matters?

@tautschnig
Copy link
Collaborator Author

I find it odd that the order of conversion matters?

I'm with you in that I don't like that the order matters, but I can't claim to have a better solution to offer: the order (nowadays) matters, because we keep track of variable declarations in the scope stack (which now is a scope tree). That is, conversion has that side effect of updating the scope tree.

In absence of ideas on how to avoid this side effect I'd maintain that this PR here is the correct fix.

@kroening
Copy link
Member

kroening commented Feb 9, 2024

In absence of ideas on how to avoid this side effect I'd maintain that this PR here is the correct fix.

I'd really like to get rid of that side effect. If need be, I'd prefer to pass around that scope stack.

@tautschnig tautschnig self-assigned this Feb 9, 2024
@tautschnig
Copy link
Collaborator Author

In absence of ideas on how to avoid this side effect I'd maintain that this PR here is the correct fix.

I'd really like to get rid of that side effect. If need be, I'd prefer to pass around that scope stack.

With apologies for taking this long to get back to this: I am still trying to figure out whether this can be done without making all of targetst target that object being passed around. Perhaps that's the right thing to do, but it will amount to touching approximately 160 places in goto_convert's code.

@kroening
Copy link
Member

With apologies for taking this long to get back to this: I am still trying to figure out whether this can be done without making all of targetst target that object being passed around. Perhaps that's the right thing to do, but it will amount to touching approximately 160 places in goto_convert's code.

Do we want to do this in the C front-end instead? That's where scoping belongs.

@tautschnig
Copy link
Collaborator Author

With apologies for taking this long to get back to this: I am still trying to figure out whether this can be done without making all of targetst target that object being passed around. Perhaps that's the right thing to do, but it will amount to touching approximately 160 places in goto_convert's code.

Do we want to do this in the C front-end instead? That's where scoping belongs.

I equally thought that was the right choice. The challenge, however, is with goto instructions, where we’d need a frontend (codet) level control-flow graph. But maybe we should bite that bullet, it would also help with always_inline?

@tautschnig tautschnig force-pushed the bugfixes/no-spurious-loops branch from 5108c55 to 2fc75f9 Compare March 27, 2024 10:26
@tautschnig tautschnig force-pushed the bugfixes/no-spurious-loops branch from 2fc75f9 to 4d75a8d Compare April 15, 2024 10:34
@tautschnig tautschnig force-pushed the bugfixes/no-spurious-loops branch 2 times, most recently from 6ffa1c5 to 4827dd4 Compare April 30, 2024 14:49
@tautschnig tautschnig force-pushed the bugfixes/no-spurious-loops branch from 4827dd4 to 727982e Compare June 13, 2024 10:05
@tautschnig tautschnig added the Version 6 Pull requests and issues requiring a major version bump label Jun 13, 2024
@kroening
Copy link
Member

Approving with the understanding that this will be fixed post release of version 6.

@kroening kroening enabled auto-merge June 14, 2024 20:00
@tautschnig tautschnig disabled auto-merge June 17, 2024 09:15
We must convert the condition of an if/then/else first to make sure any
declarations produced by converting the condition have a suitable
scope-tree node. Previously, gotos in either branch of the if-then-else
were led to believe that declarations resulting from condition were not
yet in scope. The feature from diffblue#8091 would, thus, result in a spurious
loop back to the declaration to put it in scope before following the
goto edge.
@tautschnig tautschnig force-pushed the bugfixes/no-spurious-loops branch from 727982e to 1f5950c Compare June 17, 2024 10:02
@tautschnig tautschnig merged commit 804c708 into diffblue:develop Jun 17, 2024
37 of 38 checks passed
@tautschnig tautschnig deleted the bugfixes/no-spurious-loops branch June 17, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws-high Version 6 Pull requests and issues requiring a major version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants