Commit Graph

490 Commits

Author SHA1 Message Date
Andrew Trick
7dea051bf6 Review feedback; Builder.createEndAccess() 2024-03-05 17:08:13 -08:00
Andrew Trick
28c1fdb96f SwiftCompilerSources: Add Instruction.endInstruction
To make the ScopedInstruction abstraction useful and formalize to use-points of scoped operations.

This is specifically for scoped operations that use their operands up to the end of their scope.

This is not for the many instructions that introduce scoped lifetimes. Allocations are not considered scoped
operations. Every owned value has a scoped lifetime just like an allocation, but the scope-ending instructions are not
considered use points.
2024-03-05 17:08:13 -08:00
cui fliter
127077b3aa chore: fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-03-05 17:23:22 +08:00
Andrew Trick
d6d8323775 Add SingleInlineArray read/_modify accessors
For mutable access.
2024-03-04 10:17:13 -08:00
Erik Eckstein
8137adf89e SwiftCompilerSources: support Undef.parentFunction and PlaceholderValue.parentFunction
After support in the C++ SIL, we can implement parentFunction for those values in swift, too.
It simplifies a few things.
2024-03-01 09:07:12 +01:00
Holly Borla
2c6344f461 [SILOptimizer] Handle FunctionExtractIsolationInst in the mandatory passes. 2024-02-26 17:59:27 -08:00
Andrew Trick
e3198ed38e Fix AccessUtils.swift to use the project_box reference root. 2024-02-26 00:20:46 -08:00
Andrew Trick
7574c1fede Fix AccessUtils Value.referenceRoot to handle ForwardingInstructions.
This fixes all analyses that use AccessUtils in the presence of new
forwarding instructions. This is also needed for consistency with the
C++ source base. And for general sanity.

Utilities that walk the use-def chain should never hard-code a list of
opcodes that happened to work with some specific pass. Passes should
never assume that a basic SIL utility handles specific SIL operations
a certain way. Instead, the utility needs to be defined in terms of
SIL semantics. In this case, the utility is supposed to handle all
instructions that semantically forward ownership of a reference.
2024-02-26 00:20:46 -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
d7205edd70 Code formatting cleanup related to CopyingInstruction 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
Andrew Trick
a3cbc28078 SwiftCompilerSources: Add enum BeginAccess.AccessKind
So we can switch over it.
2024-02-25 10:22:06 -08:00
eeckstein
d1961e1126 Merge pull request #71808 from eeckstein/global_async_function_pointers
Support statically initialized global async function pointers
2024-02-22 16:44:38 +01:00
Erik Eckstein
9aff04a65a Support statically initialized global async function pointers
rdar://123327436
2024-02-22 09:38:18 +01: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
Erik Eckstein
68cc6c8780 SwiftCompilerSources: add all missing instruction classes
And require that all new instructions must be added and registered in SwiftCompilerSources as well.
2024-02-22 07:12:10 +01:00
Erik Eckstein
aadb0598c9 SIL: remove the var operands requirement from UnaryInstruction
It's not needed because UnaryInstruction is "derived" from Instruction which has this property.
2024-02-22 07:12:10 +01:00
Meghana Gupta
14578db701 Bridge createEndAccess 2024-02-13 00:12:23 -08:00
Andrew Trick
fcb8612c18 Format SingleInlineArray for use in lit tests. 2024-02-12 20:03:38 -08:00
Andrew Trick
e9762432d5 Improve Operand.isAddressInitialization to handle indirect results. 2024-02-12 09:57:14 -08:00
Andrew Trick
8b24382494 SwiftCompilerSources: cleanup and extend ArgumentConventions
Provide APIs needed by lifetime dependence diagnostics, namely LifetimeDependenceConvention.

Reorganize the APIs so it's easy to find related functionality which
API is responsible for which functionality.

Remove the originalFunctionConvention complexity. It is no longer
needed for lifetime dependence inference, and generally should be
avoided in SIL.

Add some placeholder FIXMEs because this not a good PR in which to
change existing functionality.
2024-02-12 09:57:14 -08:00
Andrew Trick
28b60e051d Bridge SILFunctionType LifetimeDependenceInfo 2024-02-12 09:57:14 -08:00
Andrew Trick
03bda631f1 AccessUtils: comment typo 2024-02-12 09:57:14 -08:00
Andrew Trick
d0ac09493a Bridge MarkDependence.resolveToNonEscaping 2024-02-12 09:57:14 -08:00
Andrew Trick
72fff912e7 SwiftCompilerSources: bridge Type.isEmpty 2024-02-12 09:57:14 -08:00
Andrew Trick
340bd26d23 SwiftCompilerSources: bridge isNoEscape and mayEscape. 2024-02-12 09:57:14 -08:00
Andrew Trick
ced850d092 SwiftCompilerSources: bridge GlobalVariable.varDecl 2024-02-12 09:57:14 -08:00
Andrew Trick
b1601a958b Fix ApplySite.originalParameter(of:). 2024-02-12 09:57:14 -08:00
Andrew Trick
79fe8bad30 SwiftCompilerSources: improve MarkDependenceInst. 2024-02-12 09:57:14 -08:00
Andrew Trick
da3f583492 Add mark_dependence [unresolved]
In preparation for inserting mark_dependence instructions for lifetime
dependencies early, immediately after SILGen. That will simplify the
implementation of borrowed arguments.

Marking them unresolved is needed to make OSSA verification
conservative until lifetime dependence diagnostics runs.
2024-02-08 22:53:16 -08:00
Erik Eckstein
31f3102540 swift SIL: fix Function.isGeneric
It didn't work for functions in generic contexts, which don't add a generic parameter themselves
2024-01-31 17:16:18 +01:00
Erik Eckstein
3b239b25f3 swift SIL: add Function thunk APIs
* `var thunkKind`
* `set(thunkKind:)`
2024-01-31 17:16:13 +01:00
Erik Eckstein
fa0be3c10f SwiftCompilerSources: bridge some SIL APIs
* `TryApplyInst.specializationInfo`
* `BasicBlock.addFunctionArgument`
* `Function.appendNewBlock`
2024-01-31 17:16:12 +01:00
Erik Eckstein
a98448b89a swift Builder: add a few instruction creation functions 2024-01-31 17:16:12 +01:00
Erik Eckstein
240fa6d937 SIL: make swift ParameterInfo convertible back to C++ SILParameterInfo 2024-01-31 17:16:12 +01:00
Erik Eckstein
7a62f15dae pass Context: verify that only the currently transformed function is modified 2024-01-31 17:16:12 +01:00
Andrew Trick
4f03241759 Bridge Argument.varDecl 2024-01-30 08:38:57 -08:00
Andrew Trick
17319fa843 Improve the AddressUtils and OwnershipLiveness APIs 2024-01-30 08:38:57 -08:00
Andrew Trick
800fa167a9 ForwardingUtils; minor cleanup 2024-01-30 08:38:57 -08:00
Andrew Trick
1c8a150d95 SwiftCompilerSources: register the new instructions. 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
9950784adb SwiftCompilerSources API for SourceDestAddrInstructions. 2024-01-30 08:38:57 -08:00
Andrew Trick
1396d6b9d0 Bridge YieldInfo 2024-01-30 08:38:57 -08:00
Andrew Trick
9770ce41a2 Improve the ArgumentConvention API 2024-01-30 08:38:57 -08:00
Arnold Schwaighofer
edd7eaa0d7 OSLog: os_log strings should be in the __oslogstring section on machO
rdar://121384422
2024-01-26 08:30:56 -08:00
Andrew Trick
3f8a35e64f ForwardingUtils comments and cleanup. 2024-01-22 23:55:29 -08:00
Andrew Trick
d9a8a0eb60 Added SourceDestAddrInstruction 2024-01-22 23:42:54 -08:00
Andrew Trick
e7a3ceb0d5 SwiftCompilerSources: add VarDecl.sourceLoc 2024-01-22 08:29:07 -08:00