When a load/load_borrow is canonicalized, canonicalization should
continue from where the load was before rather than the first
instruction that was after it. Enables narrowing the load through
a sequence of projections.
A destroy_value of Optional.none can be deleted.
A move-only struct with deinit has a non trivial SILType but OwnershipKind::None,
such values cannot be deleted.
For years, optimizer engineers have been hitting a common bug caused by passes
assuming all SILValues have a parent function only to be surprised by SILUndef.
Generally we see SILUndef not that often so we see this come up later in
testing. This patch eliminates that problem by making SILUndef uniqued at the
function level instead of the module level. This ensures that it makes sense for
SILUndef to have a parent function, eliminating this possibility since we can
define an API to get its parent function.
rdar://123484595
We want to preserve the borrow scope during switch dispatch so that move-only
checking doesn't try to analyze destructures or consumes out of it. SILGen
should mark anywhere that's a potential possibility with its own marker so that
it gets borrow checked independently.
We weren't looking at the length of an opaque archetype's type parameter,
which could lead to unbounded growth in the number of emitted specializations.
Fixes rdar://problem/121867690.
This adds SIL-level support and LLVM codegen for normal results of a coroutine.
The main user of this will be autodiff as VJP of a coroutine must be a coroutine itself (in order to produce the yielded result) and return a pullback closure as a normal result.
For now only direct results are supported, but this seems to be enough for autodiff purposes.
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.
This may involve changing the linkage of the specialized function.
If called from a serialized function we cannot make the specialized function shared and non-serialized.
The only other option is to keep the original function's linkage.
rdar://121675461
This was enabled in ossa recently.
There are 2 bugs:
- In CheckedCastBrJumpThreading::Edit::canRAUW, we don't check for canFixUpOwnershipForRAUW.
- Currently modifyCFGForSuccessPreds has to be called after modifyCFGForFailurePreds.
But modifyCFGForFailurePreds can modify cfg in a way such that OSSA RAUW can no longer be done in modifyCFGForSuccessPreds.
This will require an algorithmic change, disabling temporarily to unblock rdar://121484645
It's better to ask SILType if it is MoveOnly than go to the AST type and
ask if it is noncopyable, because some types in SIL do not have a
well-defined notion of conformance in the AST.
These calls were being made on types either with a type parameter, or a
SIL-only type that doesn't actually have conformances.
In such cases, it's better to use SILType's move-only query methods.
Marker protocols can be ignored in the specialization, because they have no witness and the conformance will be checked before the specialization is applied.
Also fixes an issue where multiple requirements on the same type caused type mismatches in the erased signature.