cui fliter
127077b3aa
chore: fix some comments
...
Signed-off-by: cui fliter <imcusg@gmail.com >
2024-03-05 17:23:22 +08:00
Andrew Trick
7aab3c54ec
Factor InstructionRange.beginningInstruction for use elsewhere.
2024-03-04 16:03:54 -08:00
Erik Eckstein
8137adf89e
SwiftCompilerSources: support Undef.parentFunction and PlaceholderValue.parentFunction
...
After support in the C++ SIL, we can implement parentFunction for those values in swift, too.
It simplifies a few things.
2024-03-01 09:07:12 +01:00
Michael Gottesman
11f0ff6e32
[sil] Ensure that all SILValues have a parent function by making it so that SILUndef is uniqued at the function instead of module level.
...
For years, optimizer engineers have been hitting a common bug caused by passes
assuming all SILValues have a parent function only to be surprised by SILUndef.
Generally we see SILUndef not that often so we see this come up later in
testing. This patch eliminates that problem by making SILUndef uniqued at the
function level instead of the module level. This ensures that it makes sense for
SILUndef to have a parent function, eliminating this possibility since we can
define an API to get its parent function.
rdar://123484595
2024-02-27 13:14:47 -08:00
Meghana Gupta
4fe0429705
Merge pull request #71880 from meg-gupta/ossasilcombine
...
Add silcombines for destructure_tuple and destructure_struct
2024-02-26 14:01:05 -08:00
Meghana Gupta
7508a90af0
Enable destructure_struct/destructure_tuple simplifications in silcombine
2024-02-26 10:58:08 -08:00
Andrew Trick
56126e9db9
Fix LetPropertyLowering to correctly find mark_uninitialized uses.
2024-02-26 00:20:46 -08:00
Andrew Trick
a7e4e900c4
Fix LifetimeDependenceUtils to use OwnershipTransitionInstruction
2024-02-26 00:20:46 -08:00
Andrew Trick
5fc50a0092
AddressUtils: refactor the findSingleInitializer API.
2024-02-25 10:29:15 -08:00
Andrew Trick
a3cbc28078
SwiftCompilerSources: Add enum BeginAccess.AccessKind
...
So we can switch over it.
2024-02-25 10:22:06 -08:00
Erik Eckstein
a13a6e0bf7
SIL: verify forwarding conformances
...
Verify that the C++ view of forwarding instructions agrees with the swift ForwardInstruction conformances.
2024-02-22 07:12:11 +01:00
Erik Eckstein
71fcae7fe8
SwiftCompilerSources: add the ability to implement SIL verification in swift
2024-02-22 07:12:10 +01:00
Meghana Gupta
12ac8042ab
Handle YieldInst in LifetimeDependenceUtils
2024-02-19 15:28:04 -08:00
Andrew Trick
41043948c1
LifetimeDependenceDiagnostics: enable mutably borrowed lifetimes.
...
This allows basic prototyping. A separate analysis will ensure no
mutation of the original value during the borrow.
2024-02-15 02:39:34 -08:00
Andrew Trick
68037faa61
LifetimeDependenceScopeFixup: handle nested access
...
After extending access scopes, rewrite the mark_depenendence to be on
the outermost scope.
2024-02-13 22:22:28 -08:00
Andrew Trick
f0b04004ff
LifetimeDepenenceUtils; improve VariableIntroducerUseDefWalker
...
Stop at formal access to a mutable variable.
2024-02-13 20:57:02 -08:00
Andrew Trick
bc0f60afc9
LifetimeDependenceDiagnostics: cleanup. remove unused code.
2024-02-13 20:57:02 -08:00
Meghana Gupta
75bd5b08dd
Add LifetimeDependenceScopeFixup pass
2024-02-13 16:52:01 -08:00
Andrew Trick
c440cca939
Merge pull request #71570 from atrick/lifetime-inherit
...
LifetimeDependenceInsertion: do not emit inherited dependencies.
2024-02-12 23:02:14 -08:00
eeckstein
77cd7b5e87
Merge pull request #71554 from eeckstein/fix-escape-utils
...
EscapeUtils: fix escape result in case an address is stored
2024-02-13 07:13:51 +01:00
Andrew Trick
ecf2e36717
LifetimeDependenceDiagnostics: FIXME for @_unsafeNonEscapableResult
...
Reminder to add a builtin to reliably enforce this unsafe attribute.
2024-02-12 20:05:25 -08:00
Andrew Trick
1cdf9d56ac
LifetimeDefUseWalker handles inherited dependencies.
...
This is needed when we don't insert mark_dependence.
2024-02-12 20:05:24 -08:00
Andrew Trick
ade2ed6ddb
LifetimeDependenceInsertion: do not emit inherited dependencies.
...
These were always redundant. And there is no way to emit them
correctly for valid OSA when the original dependence scope is in the
caller.
NFC without:
-enable-experimental-feature NonescapableTypes
-enable-lifetime-dependence-diagnostics
2024-02-12 20:05:21 -08:00
Andrew Trick
2e7c29cdf5
Restrict findSingleInitializer @out arguments.
...
The client should handle @in/@inout arguments differently.
2024-02-12 20:03:38 -08:00
Andrew Trick
c4eab6a54a
Merge pull request #71266 from atrick/lifetime-insertion
...
Add the LifetimeDependenceInsertion pass.
2024-02-12 13:07:03 -08:00
Nate Chandler
f9ee089c04
[Test] Added troubleshooting note.
2024-02-12 10:23:13 -08:00
Andrew Trick
8c092911ef
Add the LifetimeDependenceInsertion pass.
...
Insert mark_dependence [nonescaping] markers at every lifetime
introducer that produces a lifetime-dependent value.
2024-02-12 09:57:14 -08:00
Andrew Trick
274c47877f
LifetimeDepenenceDiagnostics improvements
...
Better handling of @_unsafeNonescapableResult
Improve diagnostic clarity.
2024-02-12 09:57:14 -08:00
Andrew Trick
af39b0fb1f
LifetimeDependenceUtils improvements
...
Improve noescape function handling. Use the mayEscape API.
Improve handling of @_unsafeNonescapableResult.
Improve handling of initialized scopes. Use findSingleInitializer.
2024-02-12 09:57:14 -08:00
Andrew Trick
ac457abab9
LifetimeDependenceUseDefWalker: track the owner of the value.
2024-02-12 09:57:14 -08:00
Andrew Trick
b08f2dedf1
Add AccessBase.findSingleInitializer
2024-02-12 09:57:14 -08:00
Andrew Trick
63413916a1
LifetimeDependenceDiagnostics; handle @_unsafeNonescapableResult.
2024-02-12 09:57:14 -08:00
Andrew Trick
8b24382494
SwiftCompilerSources: cleanup and extend ArgumentConventions
...
Provide APIs needed by lifetime dependence diagnostics, namely LifetimeDependenceConvention.
Reorganize the APIs so it's easy to find related functionality which
API is responsible for which functionality.
Remove the originalFunctionConvention complexity. It is no longer
needed for lifetime dependence inference, and generally should be
avoided in SIL.
Add some placeholder FIXMEs because this not a good PR in which to
change existing functionality.
2024-02-12 09:57:14 -08:00
Andrew Trick
15fef6868c
BorrowUtils: add a comment
2024-02-12 09:57:14 -08:00
Andrew Trick
f713587aa5
Fix OSSA support for mark_dependence [nonescaping]
...
Handle escapes to function results.
2024-02-12 09:57:14 -08:00
Erik Eckstein
abd6ce0c9d
EscapeUtils: fix escape result in case an address is stored
...
This unusual situation can happen if an address is converted to a raw pointer and that pointer is stored to a memory location.
In this case the walkers need to follow load instructions even if the visitor and current projection path don't say so.
Fixes a miscompile
rdar://122805546
2024-02-12 17:56:09 +01:00
Erik Eckstein
38bfc03994
MandatoryPerformanceOptimizations: set the [perf_constraint] flag on functions with performance constraints
2024-02-05 12:38:53 +01:00
Erik Eckstein
86f23b089f
SIL: add the [perf_constraint] flag in SILFunction
...
Specifies that the optimizer and IRGen must not add runtime calls which are not in the function originally.
This attribute is set for functions with performance constraints or functions which are called from functions with performance.
2024-02-05 12:26:30 +01:00
Erik Eckstein
6493872ec5
BooleanLiteralFolding: remove dead blocks
...
Remove all dead blocks which are a result of constant folding condition branches
2024-02-02 11:45:38 +01:00
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
7a62f15dae
pass Context: verify that only the currently transformed function is modified
2024-01-31 17:16:12 +01:00