Erik Eckstein
95c2c50018
DiagnosticEngine: support StringRef as diagnostic argument
2024-10-02 07:10:29 +02:00
Erik Eckstein
701a7f7275
SwiftCompilerSources: don't make anything public in the Optimizer module
...
The Optimizer module is a leave module. No other modules depend on it. Therefore nothing must be public in this module.
2024-10-02 07:10:28 +02:00
Erik Eckstein
4a1d6925e9
MandatoryPerformanceOptimizations: specialize witness tables to support class existentials with generic classes
2024-09-25 19:32:14 +02:00
Erik Eckstein
7ffd270008
embedded: move the VTableSpecializer pass into MandatoryPerformanceOptimizations
...
MandatoryPerformanceOptimizations already did most of the vtable specialization work.
So it makes sense to remove the VTableSpecializerPass completely and do everything in MandatoryPerformanceOptimizations.
2024-09-25 19:32:14 +02:00
Erik Eckstein
351d42b3b3
SIL: add some Type APIs and make Type a DiagnosticArgument
2024-09-25 19:31:40 +02:00
Erik Eckstein
7ecb407226
SwiftCompilerSources: bridge SILDeclRef
...
And move NominalTypeDecl and DeclRef from Type.swift into a new file Declarations.swift.
Also add some APIs to NominalTypeDecl
2024-09-25 19:31:40 +02:00
Erik Eckstein
0ee51e4d90
StaticInitCloner: skip begin_access instructions when cloning the initial value of a global
...
Fixes a crash when simplifying a load of an UnsafePointer-global which points to another global.
rdar://135223354
2024-09-14 14:12:36 +02:00
Andrew Trick
e4036b970b
Improve LocalVariableAccessWalker to handle switch_enum_addr.
2024-08-19 18:01:49 -07:00
Allan Shortlidge
9062271185
SILGen: Skip SIL verification and optimization if errors were emitted.
...
In lazy typechecking mode, errors in the program may only be discovered during
SILGen, which can leave the SIL in a bad state for subsequent stages of
compilation. If errors were detected, skip SIL verification and optimization to
prevent knock-on failures.
Partially reverts https://github.com/swiftlang/swift/pull/75428 , which included
a more targeted fix for one of the possible knock-on effects of bad SIL coming
out of SILGen.
Resolves rdar://132107752.
2024-08-12 15:34:59 -07:00
Erik Eckstein
52d6ae334d
DeinitDevirtualizer: don't erase the destroy instruction if the the destroyed value can't be de-virtualized
...
This can happen if the destroyed type is resilient.
Fixes a verifier crash.
2024-08-12 13:34:50 +02:00
Alexander Cyon
c18a24e499
[SwiftCompilerSources] Fix typos
2024-08-08 22:22:39 -07:00
Erik Eckstein
21fedfa61e
Verifier: fix a stupid bug in borrowed-from verification
...
... which made the verification useless.
2024-08-07 18:02:39 +02:00
Erik Eckstein
def3b6fab0
AccessUtils: recognize addressor calls of globals as a "global" access base
...
Makes e.g. alias analysis more precise in the early stage of the pass pipeline where addressor calls are not inlined, yet.
2024-08-05 17:12:46 +02:00
Erik Eckstein
ac3e2cb141
EscapeUtils: handle more use types for unchecked_addr_cast
...
Handle `apply` and `try_apply`.
Also, improve test cases
2024-08-05 17:02:07 +02:00
Andrew Trick
3e98d2e232
Fix an assert in LifetimeDependenceUtils to allow all valid cases.
2024-07-31 22:58:39 -07:00
Andrew Trick
11ba799cd4
LifetimeDependence: diagnose yield and store-to-yield.
2024-07-30 16:27:48 -07:00
Andrew Trick
11640461ef
Lifetime dependence: add inferrence for setters.
...
A nonescapable computed property should always depend on 'newValue'. We simply
infer that now. There's no way to explicitly spell the dependence.
2024-07-30 15:57:57 -07:00
Andrew Trick
ba9f12a80f
LifetimeDependenceDiagnostics support for inout reassignment.
...
This relies on parameter dependence targets.
i.e. dependsOn in parameter position instead of result position.
2024-07-30 15:57:57 -07:00
Andrew Trick
f3cf529b5d
[SwiftCompilerSources] use debugLog in diagnostic passes
2024-07-30 15:57:56 -07:00
Andrew Trick
d065a3e576
Merge pull request #75562 from atrick/nfc-lifedep
...
[nfc] LifetimeDiagnostics cleanup
2024-07-30 09:03:24 -07:00
Andrew Trick
b4cdbd276b
LifetimeDependenceUtils comment typo.
2024-07-29 23:44:02 -07:00
Andrew Trick
f6d147855f
AddressUtils comment
2024-07-29 23:44:02 -07:00
Andrew Trick
103c59b273
[SwiftCompilerSources] Add assert to Builder.init(after:)
...
This API is incorrect for terminators. Assert that it isn't used
incorrectly. Later, we should rename it.
2024-07-29 23:44:02 -07:00
Erik Eckstein
6cfec91f69
EscapeInfo: handle store_borrow
2024-07-29 17:33:45 +02:00
Erik Eckstein
c6e3f51217
EscapeInfo: handle unchecked_addr_cast
...
It's dangerous to continue walking over an `unchecked_addr_cast` which casts between two different types.
We can only do this if the result is known to be the end of the walk, i.e. the cast result is not used in a relevant way.
2024-07-29 17:33:44 +02:00
Erik Eckstein
1440ae7b71
EscapeInfo: handle is_unique
2024-07-29 17:33:44 +02:00
Erik Eckstein
da5857d5ec
EscapeInfo: improve handling of begin_applys which yield an address value
...
Instead of just aborting if a `begin_apply` gets an address argument, follow the yielded values and see if they actually escape
2024-07-29 17:33:44 +02:00
Erik Eckstein
4c49e0039b
Verifier: in the swift verifier call the bridged C++ verificationFailure function in case of a failure
...
This brings all the nice verifier features to the swift verifier, like printing the surrounding instructions in case of a failure, etc.
2024-07-29 17:33:43 +02:00
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
Erik Eckstein
04e0907ab0
SIL: rename Type.instanceTypeOfMetatype -> Type.loweredInstanceTypeOfMetatype
...
The same for SILType
It needs to be made clear that this is not the "original", but the lowered SIL type.
NFC
2024-07-29 17:33:36 +02:00
Andrew Trick
c32c238720
Fix LifetimeDependenceDiagnostics to handle invalid SIL types
...
Invalid types are not considered Escapable. This makes it difficult to make any
assumptions about nonescapable types.
Fixes rdar://132348528 (Fix LifetimeDependenceDiagnostics to handle invalid SIL types)
2024-07-23 16:03:32 -07:00
Andrew Trick
c41dc33c10
LocalVariableUtils: handle projections inside initializers.
...
These projections don't have access scopes, so the utility was treating them
like escapes.
Fixes: rdar://131499478 (Difficulties composing non-escapable types)
2024-07-12 19:58:14 -07:00
Andrew Trick
ad2e58ed43
Assert that mark_dependence operands are distinct.
...
Various downstream passes assume that the dependent value is not the same as the
base value.
2024-07-05 10:42:31 -07:00
Erik Eckstein
c61733f985
SwiftCompilerSources: refactor Function.mayBindDynamicSelf
...
Instead of bridging the whole function, just bridge `hasDynamicSelfMetadata` and do the other work in swift.
2024-06-25 17:59:23 +02:00
Erik Eckstein
715a765b6e
Deinit-Devirtualization: fix a crash when trying to de-virtualize a non-copyable generic
...
rdar://129980818
2024-06-17 13:47:46 +02:00
Nate Chandler
81fa65772f
[OwnershipLiveness] End at extend_lifetime.
...
When visiting consumes, also visit `extend_lifetime` instructions.
These instructions are not lifetime ending, but together with the
consumes, they enclose the users of a value.
Add a flag to LinearLiveness to control whether these instructions are
added so that the verifier can use verify that all such instructions
appear outside the linear lifetime boundary (not including them).
2024-06-05 16:28:28 -07:00
Ellie Shin
c3ded85c4f
Update SILBridgedFunction APIs.
...
Add isAnySerialized() and canBeInlinedIntoCaller(SerializedKind).
2024-05-29 15:54:36 -07:00
Kshitij Jain
64da348ee9
Merge pull request #73688 from jkshtj/main
...
[Autodiff] Adds logic to rewrite call-sites using functions specialized by the closure-spec optimization
2024-05-23 14:21:31 -07:00
Andrew Trick
b88566a36c
Merge pull request #73621 from atrick/fix-access-mark-uninit
...
Allow AddressUseDefWalker to continue past MarkUninitializedInst
2024-05-22 18:18:51 -07:00
Kshitij
12faf79911
[Autodiff] Adds logic to rewrite call-sites using functions specialized by the closure-spec optimization
2024-05-21 12:02:28 -07:00
Erik Eckstein
941a7427d8
handle upcast instructions in statically initialized globals
...
This allows statically initialized multi-dimensional arrays in embedded swift.
2024-05-21 13:33:06 +02:00
Erik Eckstein
af68435d90
Optimizer: support static initialization of global arrays
...
The buffer of global arrays could already be statically initialized.
The missing piece was the array itself, which is basically a reference to the array buffer.
For example:
```
var a = [1, 2, 3]
```
ends up in two statically initialized globals:
1. the array buffer, which contains the elements
2. the variable `a` which is a single reference (= pointer) of the array buffer
This optimization removes the need for lazy initialization of such variables.
rdar://127757554
2024-05-16 21:34:36 +02:00
Kshitij Jain
c37d31cc64
Merge pull request #73596 from jkshtj/specialize
...
[Autodiff] Adds logic to generate specialized functions in the closure-spec pass
2024-05-14 18:55:23 -07:00
Andrew Trick
1ac4b4dd9d
[SwiftCompilerSources] Add swift_get_access_base unit tests.
...
Add a unit test harness to SwiftCompilerSources to match the one in C++ since
both source bases have different implementations of the same utilities, and they
must be consistent for correctness.
2024-05-14 10:31:24 -07:00
Kshitij
ce2161ee43
[Autodiff] Fixes build issues on Linux
2024-05-13 19:25:18 -07:00
Kshitij
74166a4ab6
[Autodiff] Moves bridging code accesses in closure-spec opt behind APIs
...
Addresses some other surfacial feedback as well.
2024-05-13 15:37:30 -07:00
Kshitij
ab751d57ab
[Autodiff] Adds logic to generate specialized functions in the closure-spec pass
2024-05-13 11:16:42 -07:00
Nate Chandler
87e4c65e28
[Gardening] SIL: "liferange" -> "liverange"
2024-05-10 15:54:07 -07:00
Kshitij Jain
01654fd323
Merge pull request #71775 from jkshtj/main
...
[Autodiff] Adds part of the Autodiff specific closure-specialization optimization pass
2024-05-10 08:51:01 -07:00
Nate Chandler
c84e196b16
[Test] Reenable SIL unit tests on windows.
...
Use `fflush(stdout)` from C++.
Issue 73252.
2024-05-06 12:20:16 -07:00