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
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
13db95eac3
BridgedASTType::isEscapable
2024-01-30 08:38:57 -08:00
Andrew Trick
e7a3ceb0d5
SwiftCompilerSources: add VarDecl.sourceLoc
2024-01-22 08:29:07 -08:00
Erik Eckstein
bc99986cf9
SIL: add a dependency token operand to global_addr
...
Optionally, the dependency to the initialization of the global can be specified with a dependency token `depends_on <token>`.
This is usually a `builtin "once"` which calls the initializer for the global variable.
2024-01-10 09:33:58 +01:00
nate-chandler
7365f9f36b
Merge pull request #70774 from nate-chandler/nfc/20240108/1/deinit-barrier-component-predicates
...
[NFC] SIL: Clarified deinit barrier APIs.
2024-01-08 23:11:38 -08:00
Nate Chandler
77fd37be99
[NFC] SIL: Renamed maySynchronize.
...
Dropped the NotConsideringSideEffects suffix.
2024-01-08 13:35:20 -08:00
Andrew Trick
264cbaea42
Add mark_dependence [nonescaping] flag.
...
The dependent 'value' may be marked 'nonescaping', which guarantees that the
lifetime dependence is statically enforceable. In this case, the compiler
must be able to follow all values forwarded from the dependent 'value', and
recognize all final (non-forwarded, non-escaping) use points. This implies
that `findPointerEscape` is false. A diagnostic pass checks that the
incoming SIL to verify that these use points are all initially within the
'base' lifetime. Regular 'mark_dependence' semantics ensure that
optimizations cannot violate the lifetime dependence after diagnostics.
2024-01-04 14:47:35 -08:00
Andrew Trick
2128c21106
Migrate SwiftCompilerSources to FunctionConvention.
...
Layers:
- FunctionConvention: AST FunctionType: results, parameters
- ArgumentConventions: SIL function arguments
- ApplyOperandConventions: applied operands
The meaning of an integer index is determined by the collection
type. All the mapping between the various indices (results,
parameters, SIL argument, applied arguments) is restricted to the
collection type that owns that mapping. Remove the concept of a
"caller argument index".
2024-01-03 12:24:50 -08:00
Meghana Gupta
ba4cedd5e5
Merge pull request #70582 from meg-gupta/resultdependsoninsil
...
Make _resultDependsOn/_resultDependsOnSelf available in SIL
2024-01-02 10:49:20 -08:00
Erik Eckstein
85be96354f
SimplifyBuiltin: fix simplification of is_same_metatype with dynamic_self types
...
Dynamic self types are not the same as non-dynamic self types.
Fixes a miscompile with dynamic self type comparisons.
rdar://119943508
2024-01-02 09:23:42 +01:00
Meghana Gupta
3c56a7a88e
Bridge hasResultDependsOnSelf()
2023-12-29 02:06:15 -08:00
Meghana Gupta
334ede0b01
Bridge hasResultDependsOn()
2023-12-29 02:06:12 -08:00
Andrew Trick
7dc3d72483
Merge pull request #70485 from atrick/bridge-util
...
[NFC] Bridging and utilities for SwiftCompilerSources required by lifetime dependence utilities.
2023-12-19 13:07:45 -08:00
Andrew Trick
c1f0f06907
[SIL] Add FunctionConvention.swift
...
Bridge information about the AST function type that does not require a
SIL function body.
Support querying the function type's ResultInfo.
2023-12-18 09:43:18 -08:00
Andrew Trick
3407ccd693
[SIL] bridge Argument.isReborrow
2023-12-18 09:28:23 -08:00
Andrew Trick
b637f06acd
[SIL] Bridge findPointerEscape() and fix OnoneSimplifyable
...
Do not bridge the hasPointerEscape flag until it is implemented.
2023-12-18 09:16:55 -08:00
Erik Eckstein
84e06322b9
SwiftCompilerSources: bridge_object_to_word is not a ForwardingInstruction
...
Fix this mismatch between C++ SIL and swift SIL.
Fixes a crash in begin_borrow simplification
Also add an assert to catch such cases.
rdar://119763595
2023-12-18 11:08:22 +01:00
Erik Eckstein
60baf111ff
Remove Type.selfOrAnyFieldHasValueDeinit
...
It's not needed anymore
2023-12-13 20:03:02 +01:00
Erik Eckstein
e652f2c92e
SIL: add the alloc_vector and vector instructions
...
* `alloc_vector`: allocates an uninitialized vector of elements on the stack or in a statically initialized global
* `vector`: creates an initialized vector in a statically initialized global
2023-12-09 18:49:55 +01:00
Erik Eckstein
0bd6034270
SwiftCompilerSources: add some Builder APIs
...
* `createAddressToPointer`
* `createLoadBorrow`
2023-12-09 18:48:50 +01:00
eeckstein
10ff55b2b3
Merge pull request #70155 from eeckstein/refactoring
...
MemoryLifetimeVerifier: use CalleeCache instead of AliasAnalysis
2023-12-04 08:53:59 +01:00
Erik Eckstein
0897d8a720
MemoryLifetimeVerifier: use CalleeCache instead of AliasAnalysis
...
To verify if a function may read from an indirect argument, don't use AliasAnalysis.
Instead use the CalleeCache to get the list of callees of an apply instruction.
Then use a simple call-back into the swift Function to check if a callee has any relevant memory effect set.
This avoids a dependency from SIL to the Optimizer.
It fixes a linker error when building some unit tests in debug.
2023-12-01 19:20:18 +01:00
zoecarver
69498e2f2e
[opt] Add three new perf annotations: @_noRuntime, @_noExistential, and @_noObjCBridging.
2023-12-01 09:13:24 -07:00
Erik Eckstein
8681131c58
add some comments in the bridging headers
2023-11-28 09:02:10 +01:00
eeckstein
67ebbee39e
Merge pull request #69955 from eeckstein/deinit-devirtualizer
...
Optimizer: de-virtualize deinits of non-copyable types
2023-11-27 12:41:49 +01:00
Erik Eckstein
37c715c58c
SwiftCompilerSources: add EndLifetimeInst
2023-11-27 09:21:33 +01:00
Erik Eckstein
6f6c0a5608
SwiftCompilerSources: add a few enum related APIs in Type and Builder
...
* `Type.getEnumCases`
* `Builder.createUncheckedTakeEnumDataAddr`
* `Builder.createSwitchEnumAddr`
2023-11-27 09:21:33 +01:00
Erik Eckstein
263f4d4cde
SILBridging: remove writeCharToStderr
...
It's not needed
2023-11-27 09:21:33 +01:00
Erik Eckstein
fc534e1c28
SwiftCompilerSources: better APIs for handling resilient nominal types
...
* add `NominalTypeDecl.isResilient`
* make the return type of `Type.getNominalFields` optional and return nil in case the nominal type is resilient.
This forces users of this API to think about what to do in case the nominal type is resilient.
2023-11-27 09:21:33 +01:00
Erik Eckstein
7752fbfdf9
SIL: add Type.selfOrAnyFieldHasValueDeinit
...
Implemented by adding a recursive property in TypeLowering
2023-11-27 09:21:32 +01:00
Erik Eckstein
9bbee4411b
SwiftCompilerSources: consider indirect error results in Function.numArguments
2023-11-27 08:51:12 +01:00
Erik Eckstein
3bfabf6e8a
SimplifyBeginBorrow: don't remove begin_borrow instructions which have the [point_escape] flag set.
2023-11-14 12:26:23 +01:00
Erik Eckstein
95c83e9899
Swift SIL: add BeginBorrowInst.isLexical
2023-11-13 20:18:07 +01: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
Kuba Mracek
2936a33680
[embedded] Wrap SwiftCompilerSources initialization state into swiftModulesInitialized API
2023-11-07 10:00:53 -08:00
Kuba Mracek
f0dd174df3
[embedded] Require SwiftCompilerSources to use embedded Swift
2023-11-07 10:00:53 -08:00
Hamish Knight
5d99fe63e9
Rename get() -> unbridged() on bridging wrappers
2023-10-31 11:06:39 +00:00
Hamish Knight
3cb74e911b
Address review feedback
2023-10-30 23:50:01 +00:00
Hamish Knight
2a6d93f505
[Basic] Improve API of BridgedArrayRef + BridgedData
...
Remove the default constructor footgun present with
the struct implementations, and sprinkle some
`SWIFT_NAME` and bridging utilities to make them
nicer to work with.
2023-10-30 23:49:59 +00:00
Hamish Knight
cae5d33368
[AST] Move BridgedNominalTypeDecl + BridgedVarDecl to ASTBridging
...
And renaming OptionalBridgedVarDecl to
BridgedNullableVarDecl for consistency with the
existing nullable AST node wrappers.
2023-10-30 23:49:55 +00:00
Erik Eckstein
b6938475b9
Optimizer: add simplification for the convert_escape_to_noescape instruction
...
Including the required bridging stuff.
%2 = thin_to_thick_function %1 to $() -> ()
%3 = convert_escape_to_noescape %2 : $() -> () to $@noescape () -> ()
->
%3 = thin_to_thick_function %1 to $@noescape () -> ()
2023-10-27 10:47:07 +02:00
Andrew Trick
ca7253a25c
Add the @_unsafeNonEscapableResult function
...
This will allow NonEscapable types to be returned from a function.
2023-10-17 12:44:31 -07:00
Andrew Trick
045253e614
Add SILType::isEscapable
2023-10-17 12:44:31 -07:00
Andrew Trick
3f6751a75e
Add SWIFT_IMPORT_UNSAFE to new SIL bridging
2023-10-12 15:44:28 -07:00
Andrew Trick
d7c1c50d9b
SwiftCompilerSources: VarDecl bridging for SIL.
2023-10-12 14:33:37 -07:00
Andrew Trick
e2333cdcfc
SwiftCompilerSources: diagnostics bridging.
2023-10-12 14:33:37 -07:00
Erik Eckstein
f57bc64852
Builder Bridging: some refactoring to simplify the code
...
NFC
2023-10-09 17:43:22 +02:00