Erik Eckstein
1355e94eca
Simplification: simplify builtin "canBeClass" and builtin "assert_configuration"
2023-05-11 08:11:44 +02:00
Erik Eckstein
b9169064c6
Swift SIL: add some APIs
...
* `Options.assertConfiguration`
* `Argument.isIndirectResult`
* in `Function`: `selfArgument`, `isTransparent`, `performanceConstraints` and `inlineStrategy`
* `BuiltinInst.substitutionMap`
* `SubstitutionMap.replacementTypes`
* `Type.canBeClass`
2023-05-11 08:11:44 +02:00
Erik Eckstein
82734b6ac2
Swift Optimizer: simplification for apply, try_apply, begin_apply and partial_apply
...
* move the apply of partial_apply transformation from simplify-apply to simplify-partial_apply
* delete dead partial_apply instructions
* devirtualize apply, try_apply and begin_apply
2023-05-11 08:11:44 +02:00
Erik Eckstein
6eff928989
Swift Optimizer: add a message to an assert
2023-05-11 08:11:44 +02:00
Erik Eckstein
92a17f8a01
Optimizer: extract the NamedReturnValueOptimization from CopyForwarding to a separate function pass
...
This allows to run the NamedReturnValueOptimization only late in the pipeline.
The optimization shouldn't be done before serialization, because it might prevent predictable memory optimizations in the caller after inlining.
2023-05-11 08:11:44 +02:00
Erik Eckstein
08e75f2c50
Swift SIL: add the Operand.set API
...
as a shortcut for `Instruction.setOperand`
2023-05-11 08:03:19 +02:00
Erik Eckstein
4dcd91af7b
Swift SIL: add all deallocation instructions and let them conform to the Deallocation protocol
2023-05-11 08:03:19 +02:00
Erik Eckstein
5e2e7e3884
SIL Bridging: use bool for boolean properties
...
This was a leftover from the time we didn't use C++ interop
2023-05-11 08:03:19 +02:00
Erik Eckstein
3d555a412a
refactor two swift passes
...
NFC
2023-05-10 16:04:57 +02:00
Erik Eckstein
fa1ecff143
Swift Optimizer: rewrite the MemBehaviorDumper test pass in swift.
2023-05-09 08:25:09 +02:00
Erik Eckstein
960ca70def
Swift Optimizer: add the module pass ReadOnlyGlobalVariables
...
It marks global `var` variables as `let` if they are never written.
2023-05-08 21:23:36 +02:00
Erik Eckstein
88a4a9769e
Swift Optimizer: add simplification for load
...
Replace loads of global let variables with there static initializer values.
2023-05-08 21:23:36 +02:00
Erik Eckstein
6d6b94e430
Swift Optimizer: add the InitializeStaticGlobals function pass
...
It converts a lazily initialized global to a statically initialized global variable.
When this pass runs on a global initializer `[global_init_once_fn]` it tries to create a static initializer for the initialized global.
```
sil [global_init_once_fn] @globalinit {
alloc_global @the_global
%a = global_addr @the_global
%i = some_const_initializer_insts
store %i to %a
}
```
The pass creates a static initializer for the global:
```
sil_global @the_global = {
%initval = some_const_initializer_insts
}
```
and removes the allocation and store instructions from the initializer function:
```
sil [global_init_once_fn] @globalinit {
%a = global_addr @the_global
%i = some_const_initializer_insts
}
```
The initializer then becomes a side-effect free function which let's the builtin-simplification remove the `builtin "once"` which calls the initializer.
2023-05-08 21:23:36 +02:00
Erik Eckstein
2b117fd3ee
Swift Optimizer: add APIs to copy from or to a global static initializer
...
* `Context.copyStaticInitializer(fromInitValue:, to:)`
* `FunctionPassContext.createStaticInitializer(for:,initValue:)`
2023-05-08 21:23:36 +02:00
Erik Eckstein
78ce13dbd6
WalkUtils: Don't treat end_access as leaf-use in the AddressDefUseWalker
...
Instead just ignore it.
2023-05-08 21:23:36 +02:00
Erik Eckstein
3e04b8681c
make ModulePassContext conform to CustomStringConvertible
...
and let its description return a dump of the whole module.
This is useful for debugging
2023-05-08 21:23:36 +02:00
Erik Eckstein
e95c6425f2
Swift SIL: add some APIs for global variables
2023-05-08 21:23:36 +02:00
Erik Eckstein
c4096bc723
Swift Optimizer: simplify builtin "once"
...
If the callee is side effect-free we can remove the whole builtin "once".
2023-05-08 21:23:36 +02:00
Erik Eckstein
9b51e69dac
Swift Optimizer: constant fold builtins in the simplification passes
2023-05-08 21:23:36 +02:00
Erik Eckstein
88973a3cd5
Swift Optimizer: add simplification for tuple_extract
...
Replace tuple_extract(tuple(x)) -> x
2023-05-08 21:23:36 +02:00
Erik Eckstein
5a3ab6ee2e
Swift Optimizer: add simplifications for destructure_struct and destructure_tuple
...
Eliminate the redundant instruction pair
```
%t = tuple (%0, %1, %2)
(%3, %4, %5) = destructure_tuple %t
```
and replace the results %3, %4, %5 with %0, %1, %2, respectively.
The same for structs.
2023-05-08 21:23:36 +02:00
Erik Eckstein
0a05124023
Swift Optimizer: add simplification of debug_step
...
When compiling with optimizations, unconditionally remove `debug_step`
2023-05-08 21:23:36 +02:00
Erik Eckstein
a8c9aae1e0
Swift Optimizer: add simplification for cond_fail
2023-05-08 21:23:36 +02:00
Erik Eckstein
8a8a895239
alias analysis: compute more precise memory effects of builtin "once"
...
* Check if the address in question is even visible from outside the function
* Return the memory effects of the called function
Also, add a new API `Instruction.memoryEffects`, which is internally used by `mayReadFromMemory` et al.
2023-05-08 21:23:36 +02:00
eeckstein
3bad9069a6
Merge pull request #65622 from eeckstein/improve-escape-utils
...
EscapeUtils: better handling of noescape closures and convert_function instructions
2023-05-04 07:54:23 +02:00
Erik Eckstein
5992e68d23
EscapeUtils: better handling of noescape closures and convert_function instructions
...
* Assume that a noescape closure argument cannot escape a called function
* Handle convert_function instructions
rdar://108837480
2023-05-03 19:53:19 +02:00
Erik Eckstein
da3f126322
CalleeAnalysis: no need to provide the PassManager to the getMemBehaviorFn
...
A NFC simplification
2023-05-03 14:33:45 +02:00
Alex Lorenz
220e6faad4
Revert "[cxx-interop][SwiftCompilerSources] Use swift::DiagnosticEngine instead of BridgedDiagnosticEngine"
...
This reverts commit e9dedf3c27 .
The revert is required as foreign reference types are available for SwiftStdlib 5.8 and above, but the Swift compiler
sources back deploy to older stdlibs as well.
2023-04-11 15:28:14 -07:00
Erik Eckstein
7d70a70acf
SIL: add the drop_deinit instruction
...
his instruction is a marker for a following destroy instruction to suppress the call of the move-only type's deinitializer.
2023-04-11 10:25:48 +02:00
Slava Pestov
3d9a79e4b1
Merge pull request #64777 from slavapestov/sil-optimizer-variadic-generics
...
SIL optimizer fixes for variadic generics
2023-04-03 11:30:03 -04:00
Slava Pestov
e24cbbc42f
SILOptimizer: Bridge new Pack_Inout, Pack_Owned, Pack_Guaranteed ownership kinds
2023-03-30 14:10:27 -04:00
Nate Chandler
fc13686403
[ObjCBridgingOpt] Look through copy_value insts.
2023-03-29 11:39:43 -07:00
Erik Eckstein
010efc1ca6
Swift Bridging: use C++ instead of C bridging for the optimizer
2023-03-21 15:33:09 +01:00
Erik Eckstein
04c90166c4
Swift Bridging: use C++ instead of C bridging for BridgedBuilder
2023-03-21 15:33:09 +01:00
Erik Eckstein
b4510105a6
Swift Bridging: remove BridgedNode
2023-03-21 15:33:09 +01:00
Erik Eckstein
7905a9ac64
Swift Bridging: remove C bridging functions for SILDebugLocation
2023-03-21 15:33:09 +01:00
Erik Eckstein
82d9da5981
Swift Bridging: use C++ instead of C bridging for BridgedMultiValueResult
2023-03-21 15:33:09 +01:00
Erik Eckstein
47ac2d2818
Swift Bridging: use C++ instead of C bridging for BridgedArgument
2023-03-21 15:33:09 +01:00
Erik Eckstein
7789b4063e
Swift Bridging: remove BridgedMemoryBehavior and use swift.MemoryBehavior instead
2023-03-21 15:33:09 +01:00
Erik Eckstein
4445373808
Swift Bridging: use C++ instead of C bridging for BridgedInstruction
2023-03-21 15:33:09 +01:00
Erik Eckstein
c4f5bab5b7
Swift Bridging: use C++ instead of C bridging for BridgedBasicBlock
2023-03-21 15:33:09 +01:00
Erik Eckstein
c0c0b80c81
Swift Bridging: use C++ instead of C bridging for BridgedGlobalVar
2023-03-21 15:33:09 +01:00
Erik Eckstein
ae7770d911
Swift Bridging: use C++ instead of C bridging for BridgedFunction
2023-03-21 15:33:09 +01:00
Erik Eckstein
e469c16744
Swift Bridging: remove BridgedType and directly use the C++ SILType instead
2023-03-21 15:33:09 +01:00
Erik Eckstein
598644fb92
Swift Bridging: use C++ instead of C bridging for the bridged witness table classes
2023-03-21 15:33:09 +01:00
Erik Eckstein
151f09769f
Swift Bridging: use C++ instead of C bridging for BridgedVTable and BridgedVTableEntry
2023-03-21 15:33:09 +01:00
Erik Eckstein
fc2ad09d4b
Swift Bridging: use C++ instead of C bridging for BridgedSuccessor
2023-03-21 15:33:09 +01:00
Erik Eckstein
eecea088e7
Swift Bridging: use C++ instead of C bridging for BridgedOperand and BridgedValue
2023-03-21 15:33:09 +01:00
Michael Gottesman
4a309575d7
[sil] Rename [moved] flag on debug_value/alloc_stack to moveable_value_debuginfo.
...
This is in preparation for wiring up debug info support for noncopyable
values. Originally this flag name made sense since it was set when we performed
consume operator checking. Now I am going to use it for noncopyable types as
well. I think the new name uses_moveable_value_debuginfo actually describes what
the flag is supposed to do, tell IRGen that the value may be moved since it
needs to use moveable value debug info emission.
2023-03-19 15:38:42 -07:00
Erik Eckstein
053a38d44b
Swift SIL: mark SIL object classes as immortal
...
This avoids ARC operations on those objects which improves compile time.
2023-03-14 21:07:03 +01:00