Andrew Trick
28daec01a7
Add InstructionRange.overlapsWithPath() utility.
2025-04-16 16:43:23 -07:00
Andrew Trick
2bdaa68e98
SwiftCompilerSources: add IgnoredUseInst as incidental
...
Fixes rdar://148540048 (Assigning span value to `_` results in an incorrect escape diagnostic)
2025-04-16 16:42:36 -07:00
eeckstein
a9c6da6c70
Merge pull request #80819 from eeckstein/copy-block-optimization
...
Optimizer: remove redundant `copy_block` instructions
2025-04-15 20:17:02 +02:00
Anton Korobeynikov
87ca0f8680
Fix ownership issues with sequences of partial_apply's in AutoDiff closure specialization pass ( #80662 )
...
Each partial_apply consumes its arguments, therefore we should never release intermediate ones in the sequence of closures.
Fixes #78847
2025-04-15 07:14:44 -07:00
Erik Eckstein
199eb1d6e7
Optimizer: remove redundant copy_block instructions
...
Removes a `copy_block` if its only uses, beside ownership instructions, are callees of function calls
```
%2 = copy_block %0
%3 = begin_borrow [lexical] %2
%4 = apply %3() : $@convention(block) @noescape () -> ()
end_borrow %3
destroy_value %2
```
->
```
%4 = apply %0() : $@convention(block) @noescape () -> ()
```
rdar://118521396
2025-04-15 11:02:39 +02:00
Erik Eckstein
18ea816e79
SIL: make CopyBlockInst conform to UnaryInstruction
2025-04-15 11:02:39 +02:00
Andrew Trick
4b5d5197ae
Merge pull request #80782 from atrick/rdar143992296-addressliverange
...
Fix AddressOwnershipLiveRange to include the full range.
2025-04-12 15:02:35 -07:00
Andrew Trick
c9279d9899
Fix AddressOwnershipLiveRange to include the full range.
...
This allows further extension of access scopes.
Fixes rdar://143992296 (Use of `RawSpan` in switch context causes compiler crash
in AddressOwnershipLiveRange)
2025-04-11 23:49:07 -07:00
Meghana Gupta
2c462ba368
Merge pull request #80733 from meg-gupta/updatectb
...
Handle a special case of borrowed from instruction in CopyToBorrowOptimization
2025-04-11 21:12:54 -07:00
Meghana Gupta
fe780b670f
Handle a special case of borrowed from instruction in CopyToBorrowOptimization
2025-04-11 13:21:22 -07:00
Andrew Trick
ccb26bcd89
LocalVariableUtils: add unit tests
2025-04-10 23:27:55 -07:00
Andrew Trick
37ecd0e9bd
LocalVariableUtils: fix data flow propagation of escapes.
...
This is only used for lifetime dependence diagnostics.
Fix a couple of obvious problems with data flow propagation that crept in during
"cleanup" because no unit tests existed.
2025-04-10 23:27:55 -07:00
Andrew Trick
6e51dd8534
Merge pull request #80628 from atrick/address-escape-effect
...
Fix escape analysis: addressable parameters.
2025-04-08 13:40:02 -07:00
Andrew Trick
05a9acbb40
Fix escape analysis: addressable parameters.
...
An address-type parameter may escape via an indirect argument if the function's
result depends on the argument's address.
2025-04-08 00:07:30 -07:00
Slava Pestov
ec82f6bf4d
SIL: Remove SILWitnessTable::AssociatedConformanceWitness::SubstType
2025-04-07 21:36:06 -04:00
nate-chandler
1d3e669d63
Merge pull request #80555 from nate-chandler/bug/20250404/1
...
[SIL] Fix bridged begin_apply results.
2025-04-07 07:25:16 -07:00
Erik Eckstein
f5ca12d42b
Simplification: check for isolated conformances when simplifying metatype casts
...
rdar://147417762
2025-04-05 09:00:30 +02:00
Erik Eckstein
9df1039379
SIL: add matchesActorIsolation
...
Returns true if the conformance is not isolated or if its isolation matches the isolation `inFunction`.
2025-04-05 09:00:30 +02:00
Nate Chandler
df2fb88e9b
[SIL] Fix bridged begin_apply results.
...
The `yield_once_2` adds an extra result at the end, the deallocation.
Fix the indexing for the token and yielded results.
2025-04-04 18:12:26 -07:00
Erik Eckstein
f4955978d8
SIL: fix AllocStackInst.isLexical
...
If wrongly returned false.
2025-04-03 23:04:49 +02:00
Erik Eckstein
f8d6efd485
SimplifyAllocStack: bail if the address of the allocated existential escapes
...
This is not a problem if the alloc_stack already contains the opened existential.
Fixes a miscompile
rdar://148253142
2025-04-03 23:04:49 +02:00
Erik Eckstein
1100bf9bfb
SimplifyAllocStack: rename a variable and update a comment
...
NFC
2025-04-03 06:58:00 +02:00
Erik Eckstein
ee18f8c168
Simplification: fix a crash in alloc_stack simplification
...
Handle the case that a type dependent operand is a dynamic-self argument and not an open-existential instruction.
rdar://148258964
2025-04-01 10:58:45 +02:00
Artem Chikin
66334f8f1b
Merge pull request #79290 from artemcm/ConstProtoSIL
...
[Compile Time Values] Implement a mandatory SIL pass to verify '@const' values
2025-04-01 00:12:27 -07:00
Andrew Trick
81ca8fd3ec
Enable NonEscapableType support on Windows.
...
SwiftCompilerSources for Windows is now fully enabled, so there is no
longer any reason to gate these passes under an OS check.
commit d482ab73bc
Author: Hiroshi Yamauchi <hjyamauchi@gmail.com >
Date: Fri Dec 13 09:24:44 2024 -0800
Update the pinned toolchain for Windows and enable SwiftCompilerSources for Win/ARM64
2025-03-31 11:21:06 -07:00
Artem Chikin
281f84da0f
[Compile Time Values] Rewrite the 'Diagnose Unknown Compile Time Values' diagnostic pass in Swift
2025-03-28 10:30:07 -07:00
Artem Chikin
72a420919a
[Compile Time Values] Add mandatory optimization pipeline driver for '@const' globals
2025-03-27 14:33:38 -07:00
Artem Chikin
d484ec7c1f
[Compile Time Values] Implement a mandatory SIL pass to verify '@const' values
2025-03-27 14:33:35 -07:00
Doug Gregor
e0b52cd20e
[SIL] Extend checked-cast instructions with "prohibit isolated conformances" flag
...
When performing a dynamic cast to an existential type that satisfies
(Metatype)Sendable, it is unsafe to allow isolated conformances of any
kind to satisfy protocol requirements for the existential. Identify
these cases and mark the corresponding cast instructions with a new flag,
`[prohibit_isolated_conformances]` that will be used to indicate to the
runtime that isolated conformances need to be rejected.
2025-03-26 22:31:47 -07:00
Andrew Trick
97b249bd11
Merge pull request #80263 from atrick/markdep-addr
...
SIL: add mark_dependence_addr
2025-03-26 10:33:42 -07:00
Erik Eckstein
8b2d27007f
DiagnoseInfiniteRecursion: re-implement the pass in swift and fix a bug
...
Fixes a false alarm in case of recursive calls with different type parameters.
For example:
```
protocol P {
associatedtype E: P
}
func noRecursionMismatchingTypeArgs1<T: P>(_ t: T.Type) {
if T.self == Int.self {
return
}
noRecursionMismatchingTypeArgs1(T.E.self)
}
```
2025-03-26 09:14:38 +01:00
Erik Eckstein
ac55dae26c
AST: add the possibility to compare SubstitutionMaps
2025-03-26 08:45:38 +01:00
Erik Eckstein
85a6df30d6
SIL: add lookup(method:) in VTable and WitnessTable
2025-03-26 08:45:23 +01:00
Erik Eckstein
1844c14c44
SIL: add var ClassMethodInst.member
2025-03-26 08:45:07 +01:00
Erik Eckstein
67556cfbf4
SIL: add some Function APIs
...
* `var wasDeserializedCanonical`
* `var genericSignature`
* `func mapTypeIntoContext`
* `var forwardingSubstitutionMap`
2025-03-26 08:45:07 +01:00
Erik Eckstein
59ad8b6623
Optimizer: add var Context.currentModuleContext
2025-03-26 08:43:55 +01:00
Erik Eckstein
1ce545ba3d
SIL: add some DeclRef APIs
...
* `var decl`
* `func ==`
* `func calleesAreStaticallyKnowable`
2025-03-26 08:43:55 +01:00
Erik Eckstein
b39a6cdd22
AST: add var GenericSignature.genericParameters
2025-03-26 07:30:11 +01:00
Erik Eckstein
42bba8f484
AST: add some Declaration APIs
...
* `var Declaration.parentModule`
* `var AbstractFunctionDecl.isOverridden`
2025-03-26 07:30:11 +01:00
Erik Eckstein
e1af31bc19
AST: add var Conformance.rootConformance
2025-03-26 07:30:10 +01:00
Erik Eckstein
d523e303c3
SIL/AST: move some SIL.Type APIs to the TypeProperties protocol which makes them also available for AST.Type and AST.CanonicalType
2025-03-26 07:30:10 +01:00
Erik Eckstein
380ea889bc
SIL: fix self-argument APIs in Function
...
`var selfArgument` should return an optional, i.e. nil if the function doesn't have a self argument.
2025-03-26 07:30:10 +01:00
Andrew Trick
69b6b1d309
LifetimeDependenceDefUseWalker: handle addressable dependencies
2025-03-25 23:02:45 -07:00
Andrew Trick
d9dd93560d
Support mark_dependence_addr in SIL passes.
2025-03-25 23:02:45 -07:00
Andrew Trick
e7000e4668
SIL: Add mark_dependence_addr
2025-03-25 23:02:42 -07:00
Kuba (Brecka) Mracek
41ae31647a
Merge pull request #76045 from kubamracek/mergeable-traps
...
Add -Xfrontend -mergeable-traps as a way to emit mergeable traps
2025-03-25 07:13:18 -07:00
eeckstein
02fc68badf
Merge pull request #80237 from eeckstein/fix-alias-of-end-apply
...
AliasAnalysis: fix effect of `end_apply` / `abort_apply` for read-only coroutines
2025-03-24 21:08:40 +01:00
Kuba Mracek
ed5e89a501
Also respect -mergeable-traps when merging cond_fails in SILOptimizer
2025-03-24 09:04:44 -07:00
Erik Eckstein
be73bd552e
AliasAnalysis: fix effect of end/abort_apply for read-only coroutines
...
The lifetime of yielded values always end at the end_apply.
This is required because a yielded address is non-aliasing inside the begin/end_apply scope, but might be aliasing after the end_apply.
For example, if the callee yields an `ref_element_addr` (which is encapsulated in a begin/end_access).
Therefore, even if the callee does not write anything, the effects must be "read" and "write".
Fixes a SIL verifier error
rdar://147601749
2025-03-24 10:51:53 +01:00
Andrew Trick
001b162dc9
Surface addressableForDeps in SILType and FunctionConventions
...
With this approach, you cannot tell whether a parameter is addressable only
from the function type. Instead you need the SILValue that will be passed to the
call site.
2025-03-23 19:00:42 -07:00