Erik Eckstein
7fb4fc0f36
MandatoryPerformanceOptimizations: fix the linkage of function-signature-specialized functions
...
We need to keep the original linkage because it would be illegal to call a shared not-serialized function from a serialized function.
Also, rename the API to create the specialized function.
2024-02-02 07:27:38 +01:00
eeckstein
fb5228d453
Merge pull request #71267 from eeckstein/function-signature-opt
...
MandatoryPerformanceOptimizations: perform function signature optimization to remove metatype arguments
2024-02-01 07:53:36 +01:00
eeckstein
13201e03c3
Merge pull request #71275 from eeckstein/fix-object-outliner
...
ObjectOutliner: don't outline objects with tail allocations
2024-02-01 07:47:24 +01:00
Andrew Trick
3002513c4e
[NFC] disable verbose lifetime diagnostics by default
2024-01-31 18:58:45 -08:00
Erik Eckstein
bd7db677ed
MandatoryPerformanceOptimizations: perform function signature optimization to remove metatype arguments
...
Generic specialization already takes care of removing metatype arguments of generic functions.
But sometimes non-generic functions have metatype arguments which must be removed.
We need handle this case with a function signature optimization.
This enables, for example, to use `OptionSet` in embedded swift.
rdar://121206953
2024-01-31 17:16:18 +01:00
Erik Eckstein
80051feb4c
MandatoryPerformanceOptimizations: trigger another iteration if dead allocations were removed
2024-01-31 17:16:18 +01:00
Erik Eckstein
31f3102540
swift SIL: fix Function.isGeneric
...
It didn't work for functions in generic contexts, which don't add a generic parameter themselves
2024-01-31 17:16:18 +01:00
Erik Eckstein
3b239b25f3
swift SIL: add Function thunk APIs
...
* `var thunkKind`
* `set(thunkKind:)`
2024-01-31 17:16:13 +01:00
Erik Eckstein
250e2680aa
SwiftCompilerSources: add some module-level APIs
...
* `Context.lookupFunction`
* `ModulePassContext.loadFunction`
* `ModulePassContext.createSpecializedFunctionDeclaration`
* `ModulePassContext.moveFunctionBody`
* `ModulePassContext.mangle(withDeadArguments:)`
2024-01-31 17:16:13 +01:00
Erik Eckstein
fa0be3c10f
SwiftCompilerSources: bridge some SIL APIs
...
* `TryApplyInst.specializationInfo`
* `BasicBlock.addFunctionArgument`
* `Function.appendNewBlock`
2024-01-31 17:16:12 +01:00
Erik Eckstein
a98448b89a
swift Builder: add a few instruction creation functions
2024-01-31 17:16:12 +01:00
Erik Eckstein
240fa6d937
SIL: make swift ParameterInfo convertible back to C++ SILParameterInfo
2024-01-31 17:16:12 +01:00
Erik Eckstein
7a62f15dae
pass Context: verify that only the currently transformed function is modified
2024-01-31 17:16:12 +01:00
Erik Eckstein
eb626c2814
ObjectOutliner: don't outline objects with tail allocations
...
An object with tail allocated elements is in risk of being passed to malloc_size, which does not work for non-heap allocated objects.
Conservatively, disable objects with tail allocations.
rdar://121886093
2024-01-31 16:25:21 +01:00
Andrew Trick
ddceffaf3b
LifetimeDependenceDiagnostics pass
...
Initial diagnostic pass to enforce ~Escapable types.
2024-01-30 11:45:55 -08:00
Andrew Trick
4f03241759
Bridge Argument.varDecl
2024-01-30 08:38:57 -08:00
Andrew Trick
25cff623ab
Improve LifetimeDependenceUtils
2024-01-30 08:38:57 -08:00
Andrew Trick
17319fa843
Improve the AddressUtils and OwnershipLiveness APIs
2024-01-30 08:38:57 -08:00
Andrew Trick
800fa167a9
ForwardingUtils; minor cleanup
2024-01-30 08:38:57 -08:00
Andrew Trick
1c8a150d95
SwiftCompilerSources: register the new instructions.
2024-01-30 08:38:57 -08:00
Andrew Trick
4796e55256
SwiftCompilerSources CopyingInstruction
...
And UnmanagedRetain/Release.
2024-01-30 08:38:57 -08:00
Andrew Trick
9950784adb
SwiftCompilerSources API for SourceDestAddrInstructions.
2024-01-30 08:38:57 -08:00
Andrew Trick
1396d6b9d0
Bridge YieldInfo
2024-01-30 08:38:57 -08:00
Andrew Trick
9770ce41a2
Improve the ArgumentConvention API
2024-01-30 08:38:57 -08:00
Arnold Schwaighofer
204b20c4ad
Merge pull request #71182 from aschwaighofer/oslog_string_section
...
OSLog: os_log strings should be in the __oslogstring section on machO
2024-01-26 13:37:10 -08:00
Arnold Schwaighofer
edd7eaa0d7
OSLog: os_log strings should be in the __oslogstring section on machO
...
rdar://121384422
2024-01-26 08:30:56 -08:00
Erik Eckstein
6b046a14eb
StackPromotion: prevent resilient classes from being stack promoted.
...
Usually resilient classes cannot be promoted anyway, because their initializers are not visible and let the object appear to escape.
But in some rare situations this check is needed.
rdar://121558570
2024-01-26 09:38:14 +01:00
Andrew Trick
2ef870a52b
Add LifetimeDependence utilities
2024-01-22 23:57:03 -08:00
Andrew Trick
37171e698a
Handle mark_dependence [nonescaping] like a borrowing instruction.
2024-01-22 23:57:03 -08:00
Andrew Trick
d663924eb0
Rewrite OwnershipUtils
...
For AddressUtils and LifetimeDepenendenceUtils.
2024-01-22 23:55:50 -08:00
Andrew Trick
3f8a35e64f
ForwardingUtils comments and cleanup.
2024-01-22 23:55:29 -08:00
Andrew Trick
3bf7e715e7
Add AddressUtils.swift
2024-01-22 23:42:54 -08:00
Andrew Trick
d9a8a0eb60
Added SourceDestAddrInstruction
2024-01-22 23:42:54 -08:00
Andrew Trick
e7a3ceb0d5
SwiftCompilerSources: add VarDecl.sourceLoc
2024-01-22 08:29:07 -08:00
Andrew Trick
a80686b485
[SIL] bridge MoveValue and BeginBorrow .isFromVarDecl
2024-01-22 08:29:07 -08:00
nate-chandler
94f3b2291c
Merge pull request #70997 from nate-chandler/alias-analysis-builtin
...
[AliasAnalysis] Improve builtin's effects to depend on escapingness.
2024-01-19 12:38:48 -08:00
Nate Chandler
75ccbaed04
[AliasAnalysis] Builtin effects depend on escaping
...
Mostly restore the behavior of getMemoryEffectsFn on builtins other than
`once` and `onceWithContext` to before
8a8a895239 but keeping the improvement to
return `Instruction.memoryEffects` in the face of escaping.
2024-01-19 07:16:52 -08:00
Andrew Trick
8341b73b8c
Update OwnershipLiveness comments for code review.
2024-01-17 09:07:02 -08:00
Andrew Trick
b6b45f0701
Rename AddressUseVisitor to AddressLifetimeDefUseWalker.
2024-01-17 08:37:14 -08:00
Andrew Trick
fa27b4ba02
Reorder code in OwnershipUtils.swift.
...
To occur in the order that people will likely want to read.
2024-01-17 08:37:14 -08:00
Andrew Trick
196ae17405
Add a reborrow cache to EnclosingValues.
...
Along with motivating unit tests.
2024-01-17 08:37:14 -08:00
Andrew Trick
c10c545cbe
OwnershipUtils review feedback: code formatting.
2024-01-17 08:37:14 -08:00
Andrew Trick
d445754e6f
OwnershipUtils review feedback: Comments and examples.
2024-01-17 08:37:14 -08:00
Andrew Trick
9a822b75a1
AddressUseVisitor
2024-01-17 08:37:14 -08:00
Andrew Trick
a9126d4fd0
Add OwnershipLiveness.swift. Core OSSA APIs.
...
This is what you need to correctly analyze OSSA.
- computeLinearLiveness
- computeInteriorLiveness
- InteriorUseVisitor
- OwnershipUseVisitor
- LivenessBoundary
Along with BorrowUtils.swift, all of our OSSA transformations are
built on top of these fundamentals. With these APIs, we can build
anything OSSA-related in SwiftCompilerSources. These utilities are
immediately needed for borrowed arguments and lifetime dependence. In
the near future, we can also use them to complete OSSA lifetimes and
*correctly* fixup OSSA after transformation without introducing lots
of copies and creating lots of incorrect corner cases.
2024-01-17 08:37:14 -08:00
Andrew Trick
e4d8277723
SwiftCompilerSources: add UseList ignoreTypeDependence
2024-01-17 08:37:14 -08:00
Andrew Trick
8a2ae0b23c
BorrowIntroducer unit tests
2024-01-17 08:37:14 -08:00
Andrew Trick
1646a667c1
Add BorrowUtils: OSSA infrastructure for borrow scopes.
...
Key APIs necessary for using OSSA.
- BorrowingInstruction
- BeginBorrowValue
- scopeEndingOperands
- BorrowIntroducers
- EnclosingValues
- innerAdjacentPhis
These need to be complete to be correct.
2024-01-17 08:37:14 -08:00
Andrew Trick
2cac9fbd4c
ForwardingUtils.swift cleanup. Make the API easier to extend.
2024-01-17 08:37:14 -08:00
Andrew Trick
5759d428e2
ForwardingUtils comment formatting.
...
Format comments so they are readable on github and 80-col tools.
2024-01-17 08:37:14 -08:00