19 Commits

Author SHA1 Message Date
Michael Gottesman
fe9c21fd87 [sil] Add a new instruction cast_implicit_actor_to_optional_actor.
This instruction converts Builtin.ImplicitActor to Optional<any Actor>. In the
process of doing so, it masks out the bits we may have stolen from the witness
table pointer of Builtin.ImplicitActor. The bits that we mask out are the bottom
two bits of the top nibble of the TBI space on platforms that support TBI (that
is bit 60,61 on arm64). On platforms that do not support TBI, we just use the
bottom two tagged pointer bits (0,1).

By using an instruction, we avoid having to represent the bitmasking that we are
performing at the SIL level and can instead just make the emission of the
bitmasking an IRGen detail. It also allows us to move detection if we are
compiling for AArch64 to be an IRGen flag instead of a LangOpts flag.

The instruction is a guaranteed forwarding instruction since we want to treat
its result as a borrowed projection from the Builtin.ImplicitActor.
2025-10-16 10:52:04 -07:00
Erik Eckstein
41a6b8e257 SwiftCompilerSources: move SIL-related Context APIs from Optimizer to the SIL module 2025-07-28 14:19:11 +02:00
Andrew Trick
128b0e711a Add Value.isForwarded(from:)
A simple utility on ForwardingInstructions that should be defined alongside
similar utilities rather than inside a pass.
2025-02-10 09:11:22 -08:00
Erik Eckstein
ac4bc89c9a SIL: add the borrowed-from instruction.
It declares from which enclosing values a guaranteed phi argument is borrowed from.
2024-04-10 13:38:10 +02:00
Andrew Trick
581010d00c SIL: Make drop_deinit a ForwardingInstruction.
drop_deinit forwards ownership while effectively stripping the deinitializer. It is similar to a type cast.

Fixes rdar://125590074 ([NonescapableTypes] Nonescapable types
cannot have deinits)
2024-04-03 18:53:18 -07:00
Andrew Trick
89063c93e4 Add Value.definingInstructionOrTerminator 2024-04-03 10:46:09 -07:00
Holly Borla
2c6344f461 [SILOptimizer] Handle FunctionExtractIsolationInst in the mandatory passes. 2024-02-26 17:59:27 -08:00
Andrew Trick
760fa24d1e Add ForwardingInstruction.preservesIdentity.
Mirror isIdentityPreservingRefCase.

I don't know why this does not apply to boxes and existentials, but am convervatively staying consistent with the
current behavior.
2024-02-26 00:20:46 -08:00
Andrew Trick
0752ea5824 Add OwnershipTransitionInstruction.
These instructions carry lifetime dependence from a single operand to a single result. They are not forwarding
instructions because we use them to indicate the boundaries of a forwarded lifetime.
2024-02-26 00:12:07 -08:00
Andrew Trick
f9a26d42d3 Make MoveOnlyWrapperToCopyableBoxInst a ConversionInstruction.
This appears to be an obvious oversight.
2024-02-25 10:29:15 -08:00
Andrew Trick
0b81392dff Code formatting cleanup related to ForwardingInstruction. 2024-02-25 10:29:15 -08:00
Erik Eckstein
c805f6cbd8 SwiftCompilerSources: refactor and fix forwarding instructions
* add ForwardingInstruction conformances to missing forwarding instruction classes
* move all the forwarding instruction conformance definitions into ForwardingInstructions.swift
* remove the default implementations of the requirements, so that every instruction needs to specify them
2024-02-22 07:12:11 +01:00
Andrew Trick
800fa167a9 ForwardingUtils; minor cleanup 2024-01-30 08:38:57 -08:00
Andrew Trick
4796e55256 SwiftCompilerSources CopyingInstruction
And UnmanagedRetain/Release.
2024-01-30 08:38:57 -08:00
Andrew Trick
3f8a35e64f ForwardingUtils comments and cleanup. 2024-01-22 23:55:29 -08:00
Erik Eckstein
eb597cb6d8 Swift SIL: add a few ownership APIs to ForwardingInstruction
* `canForwardGuaranteedValues`
* `canForwardOwnedValues`
* `setForwardingOwnership`
* `Operand.canAccept(ownership:)`
2023-11-13 20:18:07 +01:00
Andrew Trick
75ea3821ed Fix initial ForwardingInstruction implementation and handle phis 2023-10-10 13:40:23 -07:00
Andrew Trick
69a884565a Fix ownership of select_enum instruction
This instruction was given forwarding ownership in the original OSSA
implementation. That will obviously lead to memory leaks. Remove
ownership from this instruction and verify that it is never used for
non-trivial types.
2023-10-08 01:34:48 -07:00
Andrew Trick
bce9817162 SwiftCompilerSources: add ForwardingInstruction 2023-10-03 23:54:57 -07:00