Mishal Shah
e8de333daf
Revert "Add a mark_dependence while emitting SIL for uninitialized array allocation "
2023-11-12 09:43:13 -08:00
Erik Eckstein
6ff3b91fe4
SimplifyDestructure: support simplifying a destructure_struct with a copy_value in place
...
Replace
```
%s = struct (%0, %1, %2)
%c = copy_value %s // can also be a chain of multiple copies
(%3, %4, %5) = destructure_struct %c
```
with
```
%c0 = copy_value %0
%c1 = copy_value %1
%c2 = copy_value %2
%s = struct (%0, %1, %2) // keep the original struct
```
and replace the results %3, %4, %5 with %c0, %c1, %c2, respectively.
2023-11-09 18:34:53 +01:00
Erik Eckstein
2c84de3f4f
Optimizer: add a few "lookThrough" utilities
...
* move `Value.lookThoughOwnershipInstructions` from the ObjCBridgingOptimization pass to OptUtils
* add `lookThroughBorrow` and `lookThroughCopy`
2023-11-09 18:34:53 +01:00
Erik Eckstein
899034b129
EscapeUtils: handle load_borrow
2023-11-08 17:31:28 +01:00
Erik Eckstein
7b8f433fed
EscapeUtils: add EscapeVisitorWithResult.cleanupOnAbort()
...
Useful to destroy the result if it's not returned
2023-11-08 17:31:10 +01:00
Finagolfin
bf137cb30d
[android] Add more changes to build the compiler
2023-11-06 21:53:56 +05:30
Meghana Gupta
192bb2eed2
Merge pull request #69450 from meg-gupta/uninarrayfix
...
Add a mark_dependence while emitting SIL for uninitialized array allocation
2023-10-31 22:07:14 -07:00
Slava Pestov
05ccd9734c
SIL: Introduce ThrowAddrInst
2023-10-31 16:58:54 -04:00
Meghana Gupta
25d1e53241
Handle mark_dependence in ObjectOutliner
2023-10-31 11:07:40 -07:00
Meghana Gupta
f707d8a7de
ObjectOutliner: isValidUseOfObject(Instruction) -> isValidUseOfObject(Operand)
2023-10-31 11:07:40 -07:00
Hamish Knight
3cb74e911b
Address review feedback
2023-10-30 23:50:01 +00:00
Hamish Knight
2a6d93f505
[Basic] Improve API of BridgedArrayRef + BridgedData
...
Remove the default constructor footgun present with
the struct implementations, and sprinkle some
`SWIFT_NAME` and bridging utilities to make them
nicer to work with.
2023-10-30 23:49:59 +00:00
Hamish Knight
dc899c53de
[AST] Use consistent naming for bridging functions
...
Add a `Bridged` prefix to match the name being
exposed to Swift, and to match the other bridging
functions. Also while here, use `SWIFT_NAME` for
some bridging functions that were missing it.
2023-10-30 23:49:58 +00:00
Hamish Knight
2ac0860716
[AST] Remove BridgedVarDecl + BridgedNominalTypeDecl duplicates
...
These are now stamped out by the ASTBridgingWrappers.
2023-10-30 23:49:56 +00:00
Hamish Knight
cae5d33368
[AST] Move BridgedNominalTypeDecl + BridgedVarDecl to ASTBridging
...
And renaming OptionalBridgedVarDecl to
BridgedNullableVarDecl for consistency with the
existing nullable AST node wrappers.
2023-10-30 23:49:55 +00:00
Hamish Knight
fce1cb54d5
[AST] Merge BridgedDiagnosticEngine + BridgedDiagEngine
...
Introduce a macro that can stamp out wrapper
classes for underlying C++ pointers, and use
it to define BridgedDiagnosticEngine in
ASTBridging. Then, migrate users of
BridgedDiagEngine onto it.
2023-10-30 23:49:55 +00:00
Hamish Knight
ce23252a3f
[Basic] Improve some bridging APIs
...
Improve APIs for BridgedStringRef,
BridgedOwnedString, and BridgedSourceLoc.
2023-10-30 23:49:53 +00:00
Hamish Knight
3e3fb584c3
[SwiftCompilerSources] NFC: Workaround a compiler bug
2023-10-30 23:49:52 +00:00
Hamish Knight
26bfe10456
[SwiftCompilerSources] NFC: Allow building Package.swift
...
Tweak the compiler flags such that it can be
built from within Xcode. This is only useful when
editing, but I find it very handy.
2023-10-30 23:49:51 +00:00
Erik Eckstein
e718bfe8ed
Optimizer: reimplement simplifications for copy_value and destroy_value in swift
...
So that they can run in the OnoneSimplification pass
2023-10-27 10:47:07 +02:00
Erik Eckstein
b6938475b9
Optimizer: add simplification for the convert_escape_to_noescape instruction
...
Including the required bridging stuff.
%2 = thin_to_thick_function %1 to $() -> ()
%3 = convert_escape_to_noescape %2 : $() -> () to $@noescape () -> ()
->
%3 = thin_to_thick_function %1 to $@noescape () -> ()
2023-10-27 10:47:07 +02:00
Erik Eckstein
8b9f2a73d0
SimplifyApply: optimize thick calls where the callee is a thin_to_thick_function
...
```
%2 = thin_to_thick_function %1
%3 = apply %2(...) : @callee_guaranteed
->
%2 = thin_to_thick_function %1
%3 = apply %1(...): @convention(thin)
```
2023-10-27 10:47:07 +02:00
Erik Eckstein
bd022b4051
InitializeStaticGlobals: fix a SIL verifier crash
...
When merging stores in a global initializer, it's possible that the merged store is inserted at the wrong location, causing a SIL verifier error.
This is hard to reproduce, but can happen.
The merged store must be inserted _after_ all other stores. Instead it's inserted after the store of the last property. Now, if properties are _not_ initialized in the order they are declared, this problem can show up.
rdar://117189962
2023-10-19 20:29:30 +02:00
Andrew Trick
681a2b72e0
Merge pull request #69164 from atrick/nonescapable_attr
...
Add a temporary @_nonEscapable and @_hasUnsafeNonEscapableResult attribute
2023-10-17 21:39:10 -07:00
Andrew Trick
ca7253a25c
Add the @_unsafeNonEscapableResult function
...
This will allow NonEscapable types to be returned from a function.
2023-10-17 12:44:31 -07:00
Andrew Trick
045253e614
Add SILType::isEscapable
2023-10-17 12:44:31 -07:00
Erik Eckstein
54d254f100
Optimizer: better handling of the complexity budget in redundant-load-elimination and dead-store-elimination.
...
Instead of having a budget for each optimized load or store, provide a budget for the whole function.
Fixes a build time problem.
rdar://116877696
2023-10-16 14:44:34 +02:00
Andrew Trick
972a69f17e
SwiftCompilerSources bridging review feedback
2023-10-12 14:33:37 -07:00
Andrew Trick
d7c1c50d9b
SwiftCompilerSources: VarDecl bridging for SIL.
2023-10-12 14:33:37 -07:00
Andrew Trick
e2333cdcfc
SwiftCompilerSources: diagnostics bridging.
2023-10-12 14:33:37 -07:00
Andrew Trick
ae5ad5557d
Add Swift BeginApplyInst::yieldedValues
2023-10-12 14:33:37 -07:00
swift-ci
bbd15fce69
Merge pull request #69152 from atrick/forwarding-utils
...
ForwardingUtils.swift improvements
2023-10-12 12:17:47 -07:00
Andrew Trick
13142e3957
ForwardingUtils.swift improvements
...
For diagnostics in the presence of dead values.
2023-10-12 09:39:34 -07:00
Erik Eckstein
04b1ab6941
Rename BridgedDiagnosticEngine -> BridgedDiagEngine
...
So that it does not collide with BridgedDiagnosticEngine in CASTBridging.h.
This hopefully fixes an asan crash.
rdar://116686158
2023-10-11 20:41:30 +02:00
Andrew Trick
bd157b3be4
ForwardingUtils.swift unit tests
2023-10-10 13:42:48 -07:00
Andrew Trick
75ea3821ed
Fix initial ForwardingInstruction implementation and handle phis
2023-10-10 13:40:23 -07:00
Andrew Trick
7592b18627
SwiftCompilerSources: Add a standardError utility
2023-10-10 13:40:02 -07:00
Andrew Trick
12ea57919a
Test.swift cleanup for usability
2023-10-10 13:39:59 -07:00
Nate Chandler
9ca6b9ac1f
[Test] Print to stdout.
...
In the C++ sources it is slightly more convenient to dump to stderr than
to print to stdout, but it is rather more unsightly to print to stderr
from the Swift sources. Switch to stdout. Also allows the dump
functions to be marked debug only.
2023-10-10 08:19:44 -07:00
nate-chandler
0270d0fda2
Merge pull request #69069 from nate-chandler/nfc/20231009/1
...
[SwiftCompilerSources] NFC: Renamed two helper fns
2023-10-09 11:33:08 -07:00
swift-ci
44307996e3
Merge pull request #69071 from eeckstein/bridging-followup
...
Follow-up on the bridging rework
2023-10-09 10:52:40 -07:00
Andrew Trick
e04abee2e9
Merge pull request #69049 from apple/fix-select-enum
...
Fix ownership of select_enum instruction
2023-10-09 10:02:34 -07:00
Erik Eckstein
22979b9a7a
fix an uninitialized pointer in BridgedSourceLoc
...
It's so easy to run into undefined behavior in C++
2023-10-09 17:32:51 +02:00
Nate Chandler
99576dc261
[SwiftCompilerSources] NFC: Renamed two helper fns
2023-10-09 07:40:18 -07:00
Erik Eckstein
2dbd6cc56b
SwiftCompilerSources: rework bridging
...
Introduce two modes of bridging:
* inline mode: this is basically how it worked so far. Using full C++ interop which allows bridging functions to be inlined.
* pure mode: bridging functions are not inlined but compiled in a cpp file. This allows to reduce the C++ interop requirements to a minimum. No std/llvm/swift headers are imported.
This change requires a major refactoring of bridging sources. The implementation of bridging functions go to two separate files: SILBridgingImpl.h and OptimizerBridgingImpl.h.
Depending on the mode, those files are either included in the corresponding header files (inline mode), or included in the c++ file (pure mode).
The mode can be selected with the BRIDGING_MODE cmake variable. By default it is set to the inline mode (= existing behavior). The pure mode is only selected in certain configurations to work around C++ interop issues:
* In debug builds, to workaround a problem with LLDB's `po` command (rdar://115770255).
* On windows to workaround a build problem.
2023-10-09 09:52:52 +02:00
Nate Chandler
e65e6678e5
[Gardening] Updated comment.
...
Mention that running FunctionTests written in swift requires
swift-in-compiler and fixed the name of the register function.
2023-10-08 09:42:24 -07:00
Andrew Trick
69a884565a
Fix ownership of select_enum instruction
...
This instruction was given forwarding ownership in the original OSSA
implementation. That will obviously lead to memory leaks. Remove
ownership from this instruction and verify that it is never used for
non-trivial types.
2023-10-08 01:34:48 -07:00
Nate Chandler
ae1f950315
[SwiftCompilerSources] Moved Test into Optimizer.
...
And changed the type of the context argument to FunctionPassContext.
2023-10-07 21:23:13 -07:00
nate-chandler
18ce3ab465
Merge pull request #69007 from nate-chandler/swiftcompilersources/test-bridging-registration-cleanup
...
[SwiftCompilerSources] Simplified test registration.
2023-10-07 21:22:04 -07:00
Kuba Mracek
5d8c55eacb
[embedded] Initial Swift Concurrency for embedded Swift
2023-10-06 20:04:03 -07:00