Closed Aaron3154518 closed 3 years ago
That's a lot of words for Old Variables so here's an example:
Original code:
S1: int foo = 90;
S2: if (condition) {
int foo = foo + 1; // None of these changes persist outside the if
int bar = foo;
int foo = bar * 2; // Duplicate type declarations
}
S3: int baz = foo - 9;
S4: int foo = foo * 2;
Method 1:
S1: int foo__w__1 = 90; // Same rename as the writes in S2
S2: if (condition) {
foo__w__1 = foo__w__1 + 1; // No type decl, no rename
int bar = foo__w__1; // New variable so we are allowed to generate type decl
foo__w__1 = bar * 2;
}
S3: int baz = foo__w__1 - 9;
S4: int foo = foo__w__1 * 2;
Method 2:
S1: int foo__w__2 = 90; // w__3, didn't get renamed until after S2
S2: if (condition) {
int foo__w__1 = foo__w__2 + 1; // Don't perform SSA on the first write
int bar = foo__w__1;
foo__w__2 = bar * 2; // The last write to foo will have the same rename as outside this scope, no type decl
}
S3: int baz = foo__w__2 - 9;
S4: int foo = foo__w__2 * 2;
@cathieO When you get the chance, can you look over this an point out anything I missed/other solutions and give general thoughts? It's a lot, but I can go over it at Wednesday's meeting with better explanations.
Compound statements can be broken up.
non-issue
Currently compound statements are not properly handled in our code. Here are some proposed solutions:
Many compound statements include a new scope (such as if statements). Thus we must distinguish between old/new variables. Old variables exist outside of the new scope, new variables are created within the new scope and cannot leave it.
New Variables:
Old Variables: