You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR #14691 adjusts the deinitialization point according to expiring value analysis (which was discussed in #13704). This issue asks if folded-out param conditionals should impact the deinitialization point.
Consider for example the following program:
proc test() {
var r =new R(1);
writeln(r);
// point 1writeln("before param conditional");
iffalse {
writeln(r);
}
// point 2writeln("after param conditional");
}
test();
Should the record deinitializer for r be run at point 1 or point 2?
In favor of point 1:
The compiler knows that r is not actually used after this point so can deinitialize it early, and generally freeing memory earlier is better
In favor of point 2:
A human programmer will more easily be able to predict the deinitialization point if it does not rely on compile-time constant folding and param conditional folding.
The current implementation does point 1, but we could extend param conditional folding to adjust PRIM_END_OF_STATEMENT calls to change it to point 2.
Note that split-init rules, which are conceptually related, apply to the code before param conditionals are folded.
The text was updated successfully, but these errors were encountered:
Address deinit point and param loops and conditionals
Per the discussion in #14817, this PR updates the compiler so that the
last-mention point for a variable mentioned in a folded-away param
conditional or loop is after that loop.
Reviewed by @benharsh - thanks!
- [x] full local testing
PR #14691 adjusts the deinitialization point according to expiring value analysis (which was discussed in #13704). This issue asks if folded-out param conditionals should impact the deinitialization point.
Consider for example the following program:
Should the record deinitializer for r be run at point 1 or point 2?
In favor of point 1:
r
is not actually used after this point so can deinitialize it early, and generally freeing memory earlier is betterIn favor of point 2:
The current implementation does point 1, but we could extend param conditional folding to adjust PRIM_END_OF_STATEMENT calls to change it to point 2.
Note that split-init rules, which are conceptually related, apply to the code before param conditionals are folded.
The text was updated successfully, but these errors were encountered: