Commit Graph

14 Commits

Author SHA1 Message Date
Michael Gottesman
2dd1ef2322 Merge pull request #75759 from gottesmm/variable-name-utils-refactor
[variable-name-utils] Change internal representation to use StringRef instead of a SILValue
2024-08-07 19:37:46 -07:00
Michael Gottesman
0039b286b5 [variable-name-inference] Eliminate the old value representation and just use StringRef. 2024-08-07 13:14:50 -07:00
Michael Gottesman
1e2fb39362 [variable-name-utils] Fix thinko.
rootValue isn't always around... so stash the ASTContext on construction.
2024-08-07 13:14:50 -07:00
Michael Gottesman
63b67389b0 [variable-name-utils] Convert all DebugVarCarryingInst|VarDeclCarryingInst to the new representation of storing a StringRef. 2024-08-07 13:14:50 -07:00
Michael Gottesman
76f67cf092 [variable-name-utils] Convert all gep like instructions except ref_element_addr to be put on the stack as StringRefs instead of values. 2024-08-07 13:14:50 -07:00
Michael Gottesman
3d85f47671 [variable-name-utils] Store a std::variant instead of a pointer union and add the ability to append StringRef.
CONTEXT: This code works by building up a stack of SIL values of values that
need to be transformed into a StringRef as part of generating our name path and
then as a second phase performs the conversion of those values to StringRef as
we pop from the stack.

This is the first in a string of commits that are going to refactor
VariableNameUtils so that the stack will only contain StringRef instead of SIL
entities. This will be accomplished by moving the SIL value -> StringRef code
from the combining part of the algorithm (where we drain the stack) to the
construction of the stack.

The reason why I am doing this is two fold:

1. By just storing StringRef into the stack I am simplifying the code. Today as
mentioned above in the context, we gather up the SILValue we want to process and
then just convert them to StringRef. This means that any time one has to add a
new instruction, one has to update two different pieces of code. By trafficking
in StringRef instead, one only has to update one piece of code.

2. I want to add some simple code that allows for us to get names from closures
which would require me to recurse. I am nervous about putting
values/instructions from different functions in the same data structure. Today
it is safe, but it is bad practice. Instead, by just using StringRef in the
stack, I can avoid this problem.
2024-08-07 13:14:50 -07:00
Michael Gottesman
d8d4989325 [region-isolation] Add a comment to VariableNamePathArray that explains its "snapshot" functionality and why it is useful. 2024-08-05 16:58:20 -07:00
Michael Gottesman
bcbf5c515e [region-isolation] Emit an error when we assign a non-disconnected value into a sending result.
rdar://127318392
2024-07-18 21:29:08 -07:00
Michael Gottesman
51ef67d7df [variable-name-utils] Refactor inferName/inferNameAndRoot helpers onto VariableNameInferrer.
I have been using these in TransferNonSendable and they are useful in terms of
reducing the amount of code that one has to type to use this API. I am going to
need to use it in SILIsolationInfo, so it makes sense to move it into
SILOptimizer/Utils.

NFCI.
2024-04-11 15:41:18 -07:00
Michael Gottesman
f2b5b86e2e [region-isolation] Learn how to find variable names around phi arguments.
With this, the only remaining "task or actor isolated" error is due to changes I
need to land around async let.
2024-03-12 13:43:02 -07:00
Michael Gottesman
e21c0a6c39 [sil] Teach variable name inference how to look through more instructions. 2024-02-22 13:50:06 -08:00
Michael Gottesman
9154082d12 [sil] Teach VariableNameInferrer how to look through /all/ accessors. 2024-02-22 13:50:06 -08:00
Michael Gottesman
7df13b3c1f [sil] Refactor VariableNameUtils for handling more kinds of writes to temporaries. 2024-02-06 16:18:34 -08:00
Michael Gottesman
a569160f21 [sil] Refactor out the variable name inferer from MoveOnlyDiagnostics.cpp -> VariableNameUtils.
I am going to reuse this for TransferNonSendable. In the process I made a few
changes to make it more amenable to both use cases and used the current set of
tests that we have for noncopyable types to validate that I didn't break
anything.
2024-02-06 13:42:35 -08:00