-
Notifications
You must be signed in to change notification settings - Fork 263
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 conversion: create temporaries with minimal scope #8363
GOTO conversion: create temporaries with minimal scope #8363
Conversation
20908b2
to
c2a3496
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8363 +/- ##
===========================================
- Coverage 78.32% 78.11% -0.22%
===========================================
Files 1726 1726
Lines 188506 189207 +701
Branches 18249 18258 +9
===========================================
+ Hits 147646 147790 +144
- Misses 40860 41417 +557 ☔ View full report in Codecov by Sentry. |
src/goto-instrument/contracts/dynamic-frames/dfcc_contract_clauses_codegen.cpp
Show resolved
Hide resolved
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.
Just asking for documentation on the clean_expr_resultt
so that users of clean_expr
know what to do with it.
f0bb6dc
to
756540c
Compare
756540c
to
25fff76
Compare
GOTO conversion introduces temporaries when cleaning expression, e.g., removing side effects. We previously considered them to have block scope as they only were marked dead when the block containing them was left. This, however, can be a much larger range of instructions than for what instructions they actually need to be live for. As a consequence, GOTO conversion frequently deemed it necessary to introduce declaration hops for we had goto instructions that would jump over the declaration of the temporary, but still within the block that contained that temporary (and well after the last actual use of that temporary). This PR now largely (with the exception of compound literals, which yield temporaries that must have block scope) removes the side effect that creating temporaries had on scope tracking. Instead, methods explicitly return the list of temporaries in need of cleanup. This avoids performance penalties seen when trying to upgrade Kani to CBMC version 6. Kani makes extensive use of statement expressions, which are one case of instructions that yield a temporary that needs to be cleaned up as soon as possible.
Removes one side-effect of invoking clean_expr and instead expands on the return-value type.
25fff76
to
cb2e20c
Compare
Probably low priority, but I am wondering whether it makes sense to return a compound that includes both the objects that need to be destroyed and the generated goto program. |
Could you please be more specific on how this should be different from what's being done now? Arguably, right now it's just the names plus goto program, would you want |
GOTO conversion introduces temporaries when cleaning expression, e.g., removing side effects. We previously considered them to have block scope as they only were marked dead when the block containing them was left. This, however, can be a much larger range of instructions than for what instructions they actually need to be live for. As a consequence, GOTO conversion frequently deemed it necessary to introduce declaration hops for we had goto instructions that would jump over the declaration of the temporary, but still within the block that contained that temporary (and well after the last actual use of that temporary).
This PR now largely (with the exception of compound literals, which yield temporaries that must have block scope) removes the side effect that creating temporaries had on scope tracking. Instead, methods explicitly return the list of temporaries in need of cleanup.
This avoids performance penalties seen when trying to upgrade Kani to CBMC version 6. Kani makes extensive use of statement expressions, which are one case of instructions that yield a temporary that needs to be cleaned up as soon as possible.
The second commit is code cleanup that touches almost the same lines as the first commit, so this PR is best reviewed all-commits-at-once.