Commit Graph

14 Commits

Author SHA1 Message Date
Erik Eckstein
9eddb24c41 EscapeUtils: replace ...byWalkingDown APIs with an initialWalkingDirection parameter
It simplifies the EscapeUtils API
NFC
2024-07-29 17:33:43 +02: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
Erik Eckstein
799bd0a5f5 Swift Optimizer: some reformatting in the optimization passes
Use tail closures for all optimization passes.
NFC.
2023-08-04 10:33:52 +02:00
Erik Eckstein
f1095556c9 Swift SIL: let var UnaryInstruction.operand return an Operand and not a Value
To avoid confusion. Instead add specific getters for unary instructions with dedicated names.

NFC
2023-02-21 17:57:29 +01:00
Erik Eckstein
490c8fa1c2 ComputeEscapeEffects: some refactoring
Mostly source-code restructuring to make the source easier to read.
NFC
2023-02-15 18:42:38 +01:00
Erik Eckstein
8984046972 Effects: remove the isExclusive flag from the escapingToArgument effect
An argument-to-argument escape always involves a store, which makes an exclusive escape impossible.
2023-02-15 18:17:32 +01:00
Erik Eckstein
7a3ae09cfc Effects: add some comments and add enum argument labels
For clarity
2023-02-15 18:17:32 +01:00
Erik Eckstein
113e23df03 ComputeEscapeEffects: correctly handle "exclusive" argument -> return effects
* Disallow stores in the return -> argument path. When walking up in the EscapeUtils, it's allowed to follow stores. Therefore stores wouldn't be handled correctly.
* Also make sure that there is a return -> argument path at all

Fixes a wrong address-escaping effect in case the called function copies an indirect argument to a newly created object.
rdar://105133434
2023-02-13 16:10:17 +01:00
Erik Eckstein
caea41a4e0 ComputeEscapeEffects: don't support exclusive argument -> argument effects.
Exclusive argument -> argument effects cannot appear because such an effect would involve a store which is not permitted for exclusive escapes.
2023-02-13 16:10:17 +01:00
Erik Eckstein
cc68bd98c9 Swift Optimizer: rework pass context types and instruction passes
* split the `PassContext` into multiple protocols and structs: `Context`, `MutatingContext`, `FunctionPassContext` and `SimplifyContext`
* change how instruction passes work: implement the `simplify` function in conformance to `SILCombineSimplifyable`
* add a mechanism to add a callback for inserted instructions
2023-01-16 15:11:34 +01:00
Erik Eckstein
6c35258f83 Swift SIL: rename parent accessors to parentX, e.g. Instruction.parentBlock
It makes it easier to read
2023-01-16 15:11:34 +01:00
Erik Eckstein
60609eb809 Swift SIL: invert Type.isNonTrivialOrContainsRawPointer to Type.isTrivialNonPointer
This is consistent with `Type.isTrivial`.
Also, introduce corresponding properties in `Value`: `hasTrivialType` and `hasTrivialNonPointerType`, because
1. It's less to type than `Type.isTrivial(in: function)` because `Value` knows in which function it is.
2. It fixes the corner case where value is an `Undef`, which has not parent function.
2022-10-20 09:20:28 +02:00
Erik Eckstein
0a2d233d1e compute effects: Don't modify the effects if they didn't change
This avoids sending a change notification which can trigger unnecessary other invalidations.
2022-10-20 09:20:28 +02:00
Erik Eckstein
e1c65bd1d6 Swift Optimizer: rename the ComputeEffects pass to ComputeEscapeEffects 2022-10-05 07:38:11 +02:00