Commit Graph

674 Commits

Author SHA1 Message Date
Jakub Florek
df24019195 Rename Cloner.cloneRecursivelyToGlobal. 2025-09-10 16:18:50 +01:00
Meghana Gupta
ce128e71e2 Update SIL verification for borrow accessors 2025-09-09 15:25:08 -07:00
Meghana Gupta
0bec28f510 Update borrowed from for guaranteed results of borrow accessors 2025-09-09 15:20:05 -07:00
Meghana Gupta
a798f21fd2 Introduce ResultConvention::Guaranteed and ResultConvention::GuaranteedAddress in SwiftCompilerSources 2025-09-09 14:45:41 -07:00
Andrew Trick
592642087f Merge pull request #84010 from atrick/lifedep-mutating-default
@_lifetime defaults
2025-09-04 15:44:46 -07:00
Erik Eckstein
d802b5955f SIL: Fix ResultInfo.init(bridged: OptionalBridgedResultInfo)
The initializer has to be optional because OptionalBridgedResultInfo can be nil
2025-09-04 08:15:46 +02:00
Erik Eckstein
b8a49692eb Optimizer: add TypeSubstitutionCloner and func cloneAndSpecializeFunction
Also move `func cloneFunction` from ContextCommon.swift to OptUtils.swift
2025-09-04 08:15:45 +02:00
Erik Eckstein
231042b9a8 SIL: some Cloner cleanups and improvements
* move some Cloner utilities from ContextCommon.swift directly into Cloner.swift
* add an `cloneRecursively` overload which doesn't require the `customGetCloned` closure argument
* some small cleanups
2025-09-04 08:15:45 +02:00
Erik Eckstein
65d69fe965 SIL/AST: add some APIs
* `GenericSignature.isEmpty`
* `Builder.emitDestroy`
* `Function.abi`
* `KeyPathInst.substitutionMap`
* `KeyPathInst.hasPattern`
2025-09-04 08:15:44 +02:00
Andrew Trick
ed9283e1ad [NFC] drive-by comment 2025-09-03 22:42:13 -07:00
Janat Baig
f21eb5375e Merge branch 'main' into temp-branch 2025-09-02 20:23:25 -04:00
Jakub Florek
eae7864370 Merge pull request #83988 from MAJKFL/new-sil-licm-pass-copy
New SIL LICM pass
2025-09-01 10:28:17 +01:00
Erik Eckstein
3de5d6a13e SIL: add get+set for enforcement in BeginAccessInst 2025-08-30 07:29:15 +02:00
nate-chandler
9fe43836f6 Merge pull request #83907 from nate-chandler/rdar158149082
[AllocBoxToStack] Don't destroy in dead-ends.
2025-08-28 13:36:28 -07:00
Jakub Florek
07ac8b3478 Add new loop invariant code motion. 2025-08-28 21:00:33 +01:00
Jakub Florek
3514b2b9df Bridge array semantics call and loop tree 2025-08-28 21:00:09 +01:00
Jakub Florek
e3140e0ae0 Add new generalized cloner. 2025-08-28 20:57:57 +01:00
eeckstein
8cea77eac0 Merge pull request #83913 from eeckstein/fix-deinit-devirtualization-for-arrays
Optimizer: de-virtualize deinits of `builtin "destroyArray"`
2025-08-28 18:21:07 +02:00
Erik Eckstein
e5081a511f AliasAnalysis: fix aliasing of ref_tail_addr access bases
In contrast to `ref_element_addr`, tail addresses can also be obtained via a superclass (in case the derived class doesn't add any stored properties).
Therefore if the instance types differ by sub-superclass relationship, they may alias.

Fixes a miscompile
2025-08-28 08:09:39 +02:00
Erik Eckstein
3da2c1476b SIL: add Builder.createCondBranch 2025-08-28 08:04:50 +02:00
Erik Eckstein
ab10dc23a5 SIL: add Context.getTupleType 2025-08-28 08:04:49 +02:00
Nate Chandler
f94168c875 [AllocBoxToStack] Restore isDeadEnd check.
The rewrite was missing the intentional omission of `dealloc_stack`s
corresponding to `[dead_end]` `dealloc_box`es.  Add the necessary
bridging to get to parity with the original.

Without this check, `dealloc_box [dead_end]`s are promoted to
`dealloc_stack`s but the memory projected out of such `alloc_box`s need
not be valid.

rdar://159271158
2025-08-27 17:02:27 -07:00
Slava Pestov
6c60f03f9e SIL: Split up Function.loweredFunctionType/InContext 2025-08-25 16:45:45 -04:00
Janat Baig
798c0f51a4 Merge branch 'main' into temp-branch 2025-08-23 11:11:04 -04:00
JanBaig
c2850c33c9 [SIL] Remove AssignByWrapper definition and registration 2025-08-22 23:06:59 -04:00
Doug Gregor
7a196ac3ba Merge pull request #83739 from DougGregor/embedded-weak-definitions-of-imports
[Embedded] Emit weak definitions for imported symbols
2025-08-17 20:25:02 -07:00
Doug Gregor
c91a4822d3 Serialize the "markedAsUsed" bit for SILGlobalVariable 2025-08-17 15:25:50 -07:00
Andrew Trick
eb1d5f484c [NFC] SwiftCompilerSources: add a correctly named filterUsers API
Rename existing filterUsers to filterUses.
2025-08-14 09:08:11 -07:00
Erik Eckstein
0a953b60ca SIL/AST: add var InjectEnumAddrInst.element and var EnumElementDecl.hasAssociatedValues 2025-08-03 11:06:15 +02:00
Erik Eckstein
eeb7946d55 SIL: add rawLayoutSubstitutedLikeType and rawLayoutSubstitutedCountType in Type 2025-08-03 11:06:14 +02:00
Erik Eckstein
b38490b2e2 SwiftCompilerSources: move PhiUpdater.swift from the Optimizer to the SIL module 2025-07-28 14:19:11 +02:00
Erik Eckstein
41a6b8e257 SwiftCompilerSources: move SIL-related Context APIs from Optimizer to the SIL module 2025-07-28 14:19:11 +02:00
Erik Eckstein
319f49ad9f SwiftCompilerSources: move the Verifier to the SIL module 2025-07-28 14:19:11 +02:00
Erik Eckstein
1eb49ec186 SwiftCompilerSources: move ForwardingUtils and BorrowUtils to the SIL module 2025-07-28 14:19:11 +02:00
Erik Eckstein
a767261fec SwiftCompilerSources: move the getAccessBaseTest to the SIL module 2025-07-28 14:19:10 +02:00
Erik Eckstein
e95283ba38 SwiftCompilerSources: make the testing infrastructure available in the SIL module
add `Test`, which is the SIL-equivalent of `FunctionTest`.
It's invocation closure gets a `TestContext` instead of a `FunctionContext`.

^ The commit message #2 will be skipped:

^ - test
2025-07-28 14:19:10 +02:00
Erik Eckstein
e89fdb56ba SwiftCompilerSources: move SIL-related datastructures from the Optimizer to the SIL module 2025-07-28 14:19:07 +02:00
Erik Eckstein
e2129b50ce SwiftCompilerSources: move the SSAUpdater utility from the Optimizer to the SIL module 2025-07-28 14:19:07 +02:00
Erik Eckstein
65c9828cb3 SwiftCompilerSources: move the Context protocols from the Optimizer to the SIL module
This allows to move many SIL APIs and utilities, which require a context, to the SIL module.

The SIL-part of SwiftPassInvocation is extracted into a base class SILContext which now lives in SIL.

Also: simplify the begin/end-pass functions of the SwiftPassInvocation.
2025-07-28 14:19:07 +02:00
Erik Eckstein
1343dc562d SILBridging: remove OptionalBridgedSILDebugVariable
This didn't work because the BridgedSILDebugVariable destructor was called even in the "none" case.

Fixes a compiler crash
rdar://154689481
2025-07-01 10:31:30 +02:00
eeckstein
1d3895610e Merge pull request #82349 from eeckstein/alloc-box-to-stack
Optimizer: re-implement and improve the AllocBoxToStack pass
2025-06-21 07:28:18 +02:00
Erik Eckstein
f70177ca13 SIL: fix typo in comment in Function.swift 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
c482b09878 SIL: let Builder.createAllocStack specify a debugVariable 2025-06-20 08:15:02 +02:00
Erik Eckstein
9bd85c6723 SIL: add some Function APIs
* `isReferencedInModule`
* `shouldOptimize`
2025-06-20 08:15:01 +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
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
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