Commit Graph

462 Commits

Author SHA1 Message Date
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
Andrew Trick
a80686b485 [SIL] bridge MoveValue and BeginBorrow .isFromVarDecl 2024-01-22 08:29:07 -08:00
Andrew Trick
e4d8277723 SwiftCompilerSources: add UseList ignoreTypeDependence 2024-01-17 08:37:14 -08:00
Andrew Trick
f69dfe4e79 Add OperandOwnership.endsLifetime
And rename `uses.lifetimeEndingUses` to `uses.endingLifetime`
2024-01-17 08:37:14 -08:00
Andrew Trick
d8b901052a Add Swift SIL instructions needed by AddressUseVisitor 2024-01-17 08:37:14 -08:00
Erik Eckstein
3229749257 SwiftCompilerSources: move some private utilities of passes into OptUtils
* `var Function.initializedGlobal`
* `func getGlobalInitialization`

and add `var CollectionLikeSequence.singleElement`
2024-01-10 09:34:01 +01: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
d0b47b878c SwiftCompilerSources: add CollectionLikeSequence.contains() 2023-12-19 02:05:16 -08:00
Andrew Trick
3f0d309ed4 SwiftCompilerSources: add Sequence.walk() 2023-12-19 02:05:16 -08:00
Andrew Trick
53d3c63ef7 [SIL] add Value.hasLifetime 2023-12-19 02:05:16 -08:00
Andrew Trick
ed53ab764a [SIL] add Value.lifetimeEndingUses 2023-12-19 02:05:16 -08:00
Andrew Trick
2a9aef9eb8 [SIL] add BeginApplyInst.token 2023-12-19 02:05:16 -08:00
Andrew Trick
0ddf2a8514 [SIL] add BasicBlock.singleSuccessor 2023-12-19 02:05:16 -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
7a18dd46d5 [SIL] Add Argument.incomingOperand(inPredecessor:) 2023-12-18 09:43:10 -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