-
Notifications
You must be signed in to change notification settings - Fork 89
Zero alloc: don't loose witnesses #2353
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
This allows us to get rid of a lot of machinery for tracking and resolving unresolved depedencies. Conservative on functions that have mutually recursive calls or forward calls.
1) Keep unresolved functions around until the end of the compilation unit 2) Naively compute fixed point at the end of the unit
t.approx should only be used for self rec that has no other unresolved dependencies.
Pass [keep_witnesses ] as an argument to [Analysis.create] instead of using default initial value and mutating it later.
otherwise we loose witnesses sometimes
76f46cb
to
6cfbe64
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.
Do we have an idea of the size of the
witness sets in practice? With the
comparision over the domain now
possibly involving an inclusion test,
the cost could increase significantly.
I am collecting some statistics on this RP and it's baseline #2290. |
I messed up the repo/branch in this PR, sorry. I am closing this in favor of #2354 to reduce the confusion. We can continue the discussion there. |
There is a mismatch in handling witnesses:
V.lessequal
ignores them andV.join
does not. As a result, witnesses discovered in the last iteration of a fixed point computation might be lost, if there are already other witnesses for the same component.The analysis uses
V.lessequal new_value value
to detect fixed points and will not join thenew_value
to the preiously computed value if the only difference is in witnesses.This is not a soundness problem in the sense that the check will not miss allocations, but it might not return all allocations as witnesses. We do not guarantee that all witnesses will be reported, but it is a nice property to have. We rely on the witnesses produced by the analysis to visualize allocations and not only to check annotations. Having consistent output also makes testing easier.
This PR fixes it "properly" by taking witnesses into account in
V.lessequal
and refactoring some other witness related checks to make it clear that we are allowed to ignore witnesses of "expected" values that come from annotations, and not the computed values. The downside of this approach is that the fixpoint can take longer: the height of the abstract domain now depends on the size of the input file in the worst case, instead of being constant height of3
. I think that the bad case cannot happen in practice because of the order or propagation of witnesses along all the control flow paths within a loop before checking for a fixed point.An alternative is to call
join
even whenlessequal
is true. It works too but feels like a hack.For example, the output of existing test
fail19.ml
changes depending on the order in which functions are emitted in the file:-function-layout topological
includesprobe
witness and with thesource
layout it doesn't. This happens because the fixpoint for "forward defined" functions discovered a new witness but the value was alreadyTop
, so the new witness is not recorded. I haven't found a way to reproduce this on main yet.On top of #2290.