Pavel Yaskevich
286f975c29
Merge pull request #82320 from xedin/hide-solver-hacks-behind-a-flag
...
[ConstraintSystem] Guard all the performance hacks with a flag
2025-06-20 00:12:16 -07:00
Erik Eckstein
6714a72256
Optimizer: re-implement and improve the AllocBoxToStack pass
...
This pass replaces `alloc_box` with `alloc_stack` if the box is not escaping.
The original implementation had some limitations. It could not handle cases of local functions which are called multiple times or even recursively, e.g.
```
public func foo() -> Int {
var i = 1
func localFunction() { i += 1 }
localFunction()
localFunction()
return i
}
```
The new implementation (done in Swift) fixes this problem with a new algorithm.
It's not only more powerful, but also simpler: the new pass has less than half lines of code than the old pass.
The pass is invoked in the mandatory pipeline and later in the optimizer pipeline.
The new implementation provides a module-pass for the mandatory pipeline (whereas the "regular" pass is a function pass).
This is required because the mandatory pass needs to remove originals of specialized closures, which cannot be done from a function-pass.
In the old implementation this was done with a hack by adding a semantic attribute and deleting the function later in the pipeline.
I still kept the sources of the old pass for being able to bootstrap the compiler without a host compiler.
rdar://142756547
2025-06-20 08:15:04 +02:00
Erik Eckstein
fa56ba2c3c
link SwiftCompilerSources modules to lldb-moduleimport-test and swift-remoteast-test
...
This is needed once we implement mandatory passes in Swift, because those testing tools might parse swift interface files from the SDK.
2025-06-20 08:15:03 +02:00
Erik Eckstein
f70177ca13
SIL: fix typo in comment in Function.swift
2025-06-20 08:15:03 +02:00
Erik Eckstein
b256bab988
fix BridgedPassContext::addFunctionToPassManagerWorklist
...
A new function must not be added to the pass-manager's worklist if done from a module pass.
2025-06-20 08:15:03 +02:00
Erik Eckstein
fc8f264d56
SIL: add some instruction APIs
...
* some APIs for `MarkUnresolvedNonCopyableValueInst`
* `AllocBoxInst.hasDynamicLifetime`
2025-06-20 08:15:03 +02:00
Erik Eckstein
2259fe6972
SIL: add some instruction creation functions in Builder
2025-06-20 08:15:03 +02:00
Erik Eckstein
c19aa69940
SIL: implement Function.isSerialized and Function.isAnySerialized with serializedKind
...
No need for bridging functions
2025-06-20 08:15:02 +02:00
Erik Eckstein
c70298220d
SIL: fix debug locations for various kind of instructions
...
There are some restrictions for which kind of locations can be on which kind of instructions.
This change implements them correctly.
2025-06-20 08:15:02 +02:00
Erik Eckstein
c482b09878
SIL: let Builder.createAllocStack specify a debugVariable
2025-06-20 08:15:02 +02:00
Erik Eckstein
28dd6f7064
Optimizer: improve the SpecializationCloner
...
* add `cloneFunctionBody` without an `entryBlockArguments` argument
* remove the `swift::ClosureSpecializationCloner` from the bridging code and replace it with a more general `SpecializationCloner`
2025-06-20 08:15:02 +02:00
Erik Eckstein
7deec66ffe
Optimizer: add two utilities in OptUtils.swift
...
* `MultipleValueInstruction.replace(with:)`
* `eraseIfDead(functions:)`
2025-06-20 08:15:01 +02:00
Erik Eckstein
9bd85c6723
SIL: add some Function APIs
...
* `isReferencedInModule`
* `shouldOptimize`
2025-06-20 08:15:01 +02:00
Erik Eckstein
d8e4e501f6
Optimizer: add some SIL modification APIs to Context
...
* `insertFunctionArgument`
* `BeginAccessInst.set(accessKind:)`
* `erase(function:)`
2025-06-20 08:15:01 +02:00
Erik Eckstein
de28cf04cc
Optimizer: add Context. mangle(withBoxToStackPromotedArguments)
2025-06-20 08:15:01 +02:00
Erik Eckstein
bc7024edfe
Optimizer: fix ModulePassContext.mangle(withDeadArguments:)
...
If mangled the wrong argument indices.
2025-06-20 08:15:00 +02:00
Erik Eckstein
5b9c206059
Optimizer: remove don't use locationOfNextNonMetaInstruction for getting Builder locations from instructions
...
This does not work in some situations.
2025-06-20 08:15:00 +02:00
Erik Eckstein
63cb683cb7
SIL: improve some Location APIs
...
* rename `var autoGenerated` -> `var asAutoGenerated`
* add `var asCleanup`
* add `func withScope`
2025-06-20 08:15:00 +02:00
Erik Eckstein
4212c611e5
Optimizer: add Context.createSpecializedFunctionDeclaration
...
Originally this was a "private" utility for the ClosureSpecialization pass.
Now, make it a general utility which can be used for all kind of function specializations.
2025-06-20 08:15:00 +02:00
Erik Eckstein
57e08affcb
SIL: add ApplySite.calleeArgument(of operand: Operand, in callee: Function)
...
This is a safer API than using
```
let argIdx = applySite.calleeArgumentIndex(of: op)
let arg = callee.arguments[argIdx]
```
because there is no potential misuse of the index.
2025-06-20 08:14:59 +02:00
Erik Eckstein
f83fb1b14a
Optimizer: add FunctionWorklist and CrossFunctionValueWorklist
...
Originally, `FunctionWorklist` was a private utility in MandatoryPerformanceOptimizations.
Moved this to `Worklist.swift` to make it generally available.
Also, simplify the `pop()` function which changes the popping order - therefore some test changes were necessary.
2025-06-20 08:14:59 +02:00
Erik Eckstein
40363d87c4
Optimizer: fix the InstructionRange utility for control flow graphs with unreachable blocks
...
`InstructionRange.contains` did yield a wrong result if the range ended in the begin-block and another instruction was inserted in an unreachable block.
2025-06-20 08:14:59 +02:00
Erik Eckstein
1f304e5609
SIL: improve APIs for Box types
...
* move `isBox` from `SIL.Type` to `TypeProperties` to make it also available for AST types
* add `BoxFieldsArray.isMutable(fieldIndex:)`
2025-06-20 08:14:59 +02:00
Erik Eckstein
094b246874
SIL: FunctionArgument.copyFlags needs a MutatingContext argument
...
SIL may only be modified through a MutatingContext. Otherwise analysis notifications may get lost.
2025-06-20 08:14:59 +02:00
Erik Eckstein
d025e9f7a5
SIL: add var Argument.decl: ValueDecl?
2025-06-20 08:14:58 +02:00
michael-yuji
d526a2f615
Merge pull request #82314 from michael-yuji/mchiu/freebsd-not-libstdcxx-platform
...
Remove FreeBSD from SWIFT_LIBSTDCXX_PLATFORMS as libc++ is the default standard library on FreeBSD
2025-06-19 22:15:34 -07:00
Michael Gottesman
857ed26104
Merge pull request #82311 from gottesmm/pr-29a7ec5f7fd1b97205b69527c465cac0e3b4128a
...
Revert "[flow-isolation] Allow for initialization of fields of a Global Actor isolated class in its nonisolated inits"
2025-06-19 17:35:44 -07:00
Konrad 'ktoso' Malawski
57a6a9931a
[Concurrency] Task.immediate returning Never error must not have throwing operation
...
rdar://153855920
2025-06-20 09:32:37 +09:00
Michael Buch
14c3d8dca5
Merge pull request #82335 from charles-zablit/charles-zablit/demangling/move-NodePrinter
...
[swift][Demangling][NFC] Move NodePrinter declarations to a header
2025-06-19 22:38:38 +01:00
Saleem Abdulrasool
157fdd3977
Merge pull request #82342 from compnerd/unsafe
...
stdlib: handle `unsafe` annotations in additional places
2025-06-19 11:10:14 -07:00
Anthony Latsis
30a8b59c6e
ASTBridging: Bridge swift::TypeAttrKind directly
2025-06-19 18:11:40 +01:00
Anthony Latsis
8501c8776e
ASTBridging: Bridge swift::ExternKind directly
2025-06-19 18:11:40 +01:00
Anthony Latsis
0b0ebfc9fb
ASTBridging: Bridge swift::ExposureKind directly
2025-06-19 18:11:40 +01:00
Anthony Latsis
b2b79f3ad7
ASTBridging: Bridge swift::InlineKind directly
2025-06-19 18:11:40 +01:00
Anthony Latsis
6527be558a
ASTBridging: Bridge swift::NonIsolatedModifier directly
2025-06-19 18:11:40 +01:00
Anthony Latsis
29ef3e300f
ASTBridging: Bridge swift::InheritActorContextModifier directly
2025-06-19 18:11:40 +01:00
Anthony Latsis
68bb4b33f9
ASTBridging: Bridge swift::EffectsKind directly
2025-06-19 18:11:40 +01:00
Anthony Latsis
12de029d97
ASTBridging: Bridge swift::AccessLevel directly
2025-06-19 18:11:40 +01:00
Anthony Latsis
cf09773d66
ASTBridging: Bridge swift::Associativity directly
2025-06-19 18:11:40 +01:00
Anthony Latsis
38360fe625
ASTBridging: Bridge swift::DeclAttrKind directly
2025-06-19 18:11:39 +01:00
Anthony Latsis
7de8827169
BasicBridging: Turn BridgedOptional into a macro
2025-06-19 18:11:38 +01:00
Dario Rexin
6db11b60a3
Merge pull request #82347 from drexin/wip-153681688
...
[IRGen] Fix placeholder logic for emission of conditionally inverted …
2025-06-19 09:05:48 -07:00
Egor Zhdan
e4fb2549b9
Merge pull request #82309 from swiftlang/egorzhdan/span-shared-cache
...
[cxx-interop] Make usages of Swift Span `@_alwaysEmitIntoClient` in the overlay
2025-06-19 16:46:07 +01:00
Pavel Yaskevich
91ae0e0391
Merge pull request #82326 from xedin/rdar-152940244
...
[CSSimplify] VariadicGenerics: Don't attempt to wrap optional into on…
2025-06-19 08:27:18 -07:00
Hamish Knight
c3fc76fb7a
[test] Add a few more known type-checker crashers
2025-06-19 14:47:52 +01:00
Hamish Knight
61aa5a0b07
[test] Add some more known type-checker crashers
2025-06-19 14:42:54 +01:00
Hamish Knight
f62cb8f91a
[test] Use guard malloc in 4c84d3d852cdd1d4.swift
...
This should hopefully make it crash reliably.
2025-06-19 14:42:54 +01:00
Anthony Latsis
722bc0f086
ASTBridging: Bridge swift::DiagID directly
2025-06-19 12:29:27 +01:00
John McCall
a2ded3606e
Merge pull request #82327 from rjmccall/non-recursive-print-options
...
Introduce non-recursive print options and use them to handle IUO printing more elegantly
2025-06-19 18:40:03 +09:00
John Hui
a0d3ad7bd0
Merge pull request #82006 from j-hui/jump-to-def-for-macro-expanded-clang-imports
...
[SourceKit] Support location info for macro-expanded Clang imports
2025-06-19 02:01:40 -07:00