Erik Eckstein
fe367e8013
Optimizer/IRGen: allow enums in static initializers of globals
...
The main change here is in IRGen which needs to be able to emit constant enum values.
Use `emitValueInjection` to create the enum constant.
Usually this method creates code in the current function.
But if all arguments to the enum are constant, the builder never has to emit an instruction.
Instead it can constant fold everything and just returns the final constant.
Also, create statically initialized let-globals as constant global (`constant` instead of `global`).
2023-05-25 16:28:41 +02:00
Erik Eckstein
d02765fd54
Swift SIL: some new APIs and some refactoring
2023-05-25 16:28:41 +02:00
Erik Eckstein
5c0ae940eb
Optimizer: add simplification for the value_to_bridge_object instruction
...
This comes up in the code for constructing an empty string literal.
With this optimization it's possible to statically initialize empty string global variables.
2023-05-25 16:28:41 +02:00
Erik Eckstein
38de5b1ab5
Swift SIL/Optimizer: implement cloning of static init values of globals in Swift
...
* add the StaticInitCloner utility
* remove bridging of `copyStaticInitializer` and `createStaticInitializer`
* add `Context.mangleOutlinedVariable` and `Context.createGlobalVariable`
2023-05-22 15:34:26 +02:00
Erik Eckstein
ee1c52bc77
Swift SIL: add some APIs
2023-05-22 15:34:26 +02:00
Erik Eckstein
b707b5a595
Swift SIL: improve the Builder
...
* add new create-functions for instructions
* allow the Builder to build static initializer instructions for global variables
* some refactoring to simplify the implementation
2023-05-22 15:34:26 +02:00
Erik Eckstein
a4225a9088
Swift SIL: add a few SIL instructions and instruction APIs
2023-05-22 15:34:26 +02:00
Erik Eckstein
7bbf66ab5b
ReadOnlyGlobalVariables: don't convert external global vars to lets
...
Because we don't know if external variables will be written
Fixes a miscompile
rdar://109476745
2023-05-19 18:28:22 +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
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
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
e95c6425f2
Swift SIL: add some APIs for global variables
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
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
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
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
e24cbbc42f
SILOptimizer: Bridge new Pack_Inout, Pack_Owned, Pack_Guaranteed ownership kinds
2023-03-30 14:10:27 -04: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
Erik Eckstein
318c30895f
Swift Optimizer: eliminate ARC operations on types which are marked as immortal
...
A type (mostly classes) can be attributed with `@_semantics("arc.immortal")`.
ARC operations on values of such types are eliminated.
This is useful for the bridged SIL objects in the swift compiler sources.
2023-03-14 21:07:03 +01:00
Erik Eckstein
3fca8cd06e
Swift SIL: speed up Operand.value
...
Instead of doing the type casts and/or conformance lookup on the swift side, do it on the C++ side.
It makes a significant performance difference because `Operand.value` is a time critical function
2023-03-14 21:07:03 +01:00
Erik Eckstein
f1095556c9
Swift SIL: let var UnaryInstruction.operand return an Operand and not a Value
...
To avoid confusion. Instead add specific getters for unary instructions with dedicated names.
NFC
2023-02-21 17:57:29 +01:00
eeckstein
40f05faf03
Merge pull request #63690 from eeckstein/fix-same-metatype-simplification
...
Swift Optimizer: fix a crash when simplifying same-metatype comparisons of function types
2023-02-16 06:45:00 +01:00
Erik Eckstein
40ed0fb388
Swift Optimizer: fix a crash when simplifying same-metatype comparisons of function types
...
The instance type of a metatype instruction is not necessarily a legal lowered SIL Type.
Lower the type before converting it to a SILType.
rdar://105502403
2023-02-15 21:14:32 +01:00
Erik Eckstein
8984046972
Effects: remove the isExclusive flag from the escapingToArgument effect
...
An argument-to-argument escape always involves a store, which makes an exclusive escape impossible.
2023-02-15 18:17:32 +01:00
Erik Eckstein
7a3ae09cfc
Effects: add some comments and add enum argument labels
...
For clarity
2023-02-15 18:17:32 +01:00
Erik Eckstein
dfde580872
Effects: bail if effects are requested for not supported projection paths
...
Effects are only defined for operations which don't involve a load.
In case the argument's path involves a load we need to return the global effects.
2023-02-11 08:55:20 +01:00
Erik Eckstein
6226d56a52
SmallProjectionPath: add mayHaveTwoClassProjections
2023-02-11 08:55:20 +01:00
Erik Eckstein
8daa54a8c5
SmallProjectionPath: replace hasNoClassProjection with mayHaveClassProjection
...
It's less confusing.
NFC
2023-02-11 08:55:20 +01:00
Erik Eckstein
cef6ef9a84
SIL: add a debug_step instruction
...
This instruction can be inserted by Onone optimizations as a replacement for deleted instructions to
ensure that it's possible to single step on its location.
2023-02-09 06:50:05 +01:00
Erik Eckstein
e92f27c01a
Swift SIL: add some APIs to Location
...
* `hasValidLineNumber`
* `isAutoGenerated`
* `isDebugSteppable`
2023-02-09 06:50:05 +01:00
Erik Eckstein
b1c6ae60cd
Swift SIL: add metatype APIs to Type
...
* `var isMetatype: Bool`
* `var instanceTypeOfMetatype: Type`
2023-02-09 06:49:58 +01:00
Erik Eckstein
713f6c3946
Swift SIL: add Type.nominal and Type.isOrContainsObjectiveCClass APIs
2023-02-09 06:49:58 +01:00