Vars of such types should be given lexical `alloc_stack`s by
`AllocBoxToStack` which requires that the `alloc_box` insts formed for
them have an associated borrow scope which in turn requires that type
lowering for move only structs and enums have their lexical bits set.
rdar://110901430
Previously, the utility bailed out on lexical lifetimes because it
didn't respect deinit barriers. Here, deinit barriers are found and
added to liveness if the value is lexical. This enables copies to be
propagated without hoisting destroys over deinit barriers.
rdar://104630103
This provides a way to test liveness based on non-SSA values. The move
checker is now using pruned liveness this way. So we need a way to
test that liveness no longer makes any assumptions about SSA
values. These test cases need to explicitly specify all the def and
use instructions.
There is a preexisting function with this name that takes a
BorrowedValue. The new function calls that preexisting function if a
BorrowedValue can be constructed from the SILValue. Otherwise, it looks
for direct uses of the value which qualify as "pointer escapes".
Encapsulate all the complexity of reborrows and guaranteed phi in 3
ownership liveness interfaces:
LinerLiveness, InteriorLiveness, and ExtendedLiveness.
This API is the inverse of visitEnclosingDefs when called on a phi.
This replaces the visitAdjacentReborrowsOfPhi algorithm with a small
loop that simply checks all the phis in the current block.
This should all be fairly efficient once SILArgument has a "reborrow"
flag.
For most uses, some access scopes must be "respected"--if an extended
value's original lifetime originally extends beyond an access scope, its
canonicalized lifetime must not end _within_ such scopes (although
ending before them is fine). Currently, to be conservative, the utility
applies this behavior to all access scopes.
For move-only values, however, lifetimes end at final consumes without
regard to access scopes.
Allow this behavior to be controlled by whether or not a
NonLocalAccessBlockAnalysis is provided to the utility in its
constructor.
rdar://104635319
When encountering inside a borrow scope a non-lexical move_value or a
move_value [lexical] where the borrowed value is itself already lexical,
delete the move_value and regard its uses as uses of the moved-from
value.
In preparation for adding OwnershipLiveness.
Rename Simple LiveRangeSummary to LiveRangeSummary.
Add initializeDefNode helpers to avoid confusion about the argument
type.
Add defBegin/defEnd iterators in MultiDefPrunedLiveness.
Create a few sections for unit test. Ideally these would be in
separate files using a static global registry. For now, at least make
it possible to survey the available tests without reading them all
every time.
When shrinking a borrow scope like
%borrow = begin_borrow %value
barrier
%copy = copy_value %borrow
end_borrow %borrow
the copy will be rewritten to be a copy of the borrowee:
%borrow = begin_borrow %value
barrier
%copy = copy_value %value
^^^^^^
end_borrow %borrow
If, as here, shrinking next encounters a barrier, then the insertion
point will be that rewritten copy_value instruction.
In such a case, when rather than creating a new end_borrow there and
deleting the old, just reuse the old one. The lifetime of the value
being copied will be canonicalized by CopyPropagation regardless.
Made bare @instruction and @block more useful. Rather than referring to
the first instruction and block in the current function, instead, they
now refer to the instruction after the test_specification instruction
(which must always exist) and the block containing the
test_specification instruction.
Checked that applies of empty functions, or their callees, or their
callees' callees, are not deinit barriers. Checked that applies of
unknown functions, or their callees, or their callees' calles, are
deinit barriers.
With guaranteed phis, we'll be able to encounter cases where the last
users are BranchInsts which use but don't consume a value. But even
without them, we can still test the API.
Previously, SILFunction_getSelfArgumentIndex was directly using the
function type rather than interacting with the function convention.
Here, it is made to interact with the convention.
Being able to dump the function with a separate test allows other
unit-tests to skip that step and for FileChecking to focus only on the
specific things dumped between the begin and end of the unit test in
question.
The testing works by way of a new pass "UnitTestRunner" and a new
instruction test_specification. When a function contains
test_specification instructions, it invokes the UnitTest subclass named
in the test_specification instruction with the arguments specified in
that instruction.
For example, when running the unit-test-runner class, having the
instructions
```
test_specification "my-neato-utility 19 @function[callee].block[2] @trace[2]"
test_specification "my-neato-utility 43 @block @trace"
```
would result in the test associated with "my-neato-utility" in
UnitTestRunner.cpp being invoked twice. Once with (19, aBlock, aValue),
and once with (43, anotherBlock, someOtherValue). That UnitTest
subclass class would need to call takeUInt, takeBlock, and takeTrace on
the Arguments struct it is invoked with. It would then pass those
arguments along to myNeatoUtility and dump out interesting results. The
results would then be FileChecked.