-
Notifications
You must be signed in to change notification settings - Fork 5
Merging fails incorrectly while converting bc benchmark #427
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
Comments
@kyleheadley, you've been working on the declaration merging code, so maybe you can figure out what's going wrong. I see the same error both on |
What's happening here is:
As discussed today at status, there are 2 main solutions:
We could also split the first conversion stage into two, merging functions in the first and constraining parameters in the second. I don't know how much work that would be, and it wouldn't change our current handling of generics. @mwhicks1 could you weigh in on this? Any additional thoughts? |
Why are we modifying the called function's atom count based on the thing being passed in? This seems like a weakness to our handling of generics? Since
Maybe I've misread what you mean by "modifies its atom count;" perhaps you mean that a new atom is created, for the call, which is then used to constrain the one attached to the declaration parameter's atom? In any case, why is it the "inner" atom that's constrained? If I have
then it is the outer
There is no "body of
This seems wrong, per my comment above about what a generic is: One caller's instantiation should not affect the instantiations at other callers.
I like the idea of having a pass over the whole program that deals with merging, all at once, and only after that's done deals with generating constraints through the examination of definitions. How hard would this be to do? |
Yes, this is our weakness. We don't have constraint variables per-call, but per function. But I suppose context-sensitivity is how to properly handle polymorphic function calls.
Do we have separate atoms for a call site? Regardless, in this case the parameter's atom count is changed when constrained to equality with the argument. Code execution reaches this point which allows size differences in Cvars if one is generic. It handles it with calls to
It is constrained to the newly created atom(s), which pad out the pointer depth beyond the generic "T"
Sorry, this is hypothetical, since we don't have a larger example. A variable with more pointer levels than "T" should have them constrained to other variables within the body of a function it's an argument for. (If for example there's a dereference loop). If we do not add atoms to "T", we would lose this ability.
Unfortunately, this is the current situation. Our code handles polymorphism properly when "T" is a base type, but with additional pointer levels it over-constrains them all.
This was a last-minute suggestion. I'll review some of that code today for an estimate. |
I guess one takeaway here is that for things to work as generally as Checked C will allow, we have to handle generic instantiations context-sensitively, and we are not doing that now. Maybe when/if that happens, this issue will go away. But I don't see how this issue gets fixed if fundamentally you cannot instantiate a polymorphic function with different (pointer) types. |
* split variable adder and constraint adder passes * populate typedef map during variable adder phase * avoid numparam crash * Add ReasonFailed to brainTransplant; Refactor insertNewFVConstraint * another assert * add tests proto vs body * formatting, clarity * remove xfail from tests, add grep * wording: 'new'->'seen' * more mergefailure reasons * remove calls to braintransplant (regression fail: 80) * split add variable phase at higher level * only save merged FVC (regression fail: 24) * make special case match description * remove code for braintransplant * restore the safety of PragramVariableAdder * first pass comments; assert for backwards merge * second comment pass - usage and defn * add test for #427, now solved
Uh oh!
There was an error while loading. Please reload this page.
In this example, merging the second declaration of
free
fails even though the declarations should be compatible. This affects the bc benchmark in PtrDist.The text was updated successfully, but these errors were encountered: