Commit Graph

663 Commits

Author SHA1 Message Date
Andrew Trick
15fef6868c BorrowUtils: add a comment 2024-02-12 09:57:14 -08:00
Andrew Trick
d0ac09493a Bridge MarkDependence.resolveToNonEscaping 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
Andrew Trick
72fff912e7 SwiftCompilerSources: bridge Type.isEmpty 2024-02-12 09:57:14 -08:00
Andrew Trick
340bd26d23 SwiftCompilerSources: bridge isNoEscape and mayEscape. 2024-02-12 09:57:14 -08:00
Andrew Trick
ced850d092 SwiftCompilerSources: bridge GlobalVariable.varDecl 2024-02-12 09:57:14 -08:00
Andrew Trick
b1601a958b Fix ApplySite.originalParameter(of:). 2024-02-12 09:57:14 -08:00
Andrew Trick
79fe8bad30 SwiftCompilerSources: improve MarkDependenceInst. 2024-02-12 09:57:14 -08:00
Andrew Trick
da3f583492 Add mark_dependence [unresolved]
In preparation for inserting mark_dependence instructions for lifetime
dependencies early, immediately after SILGen. That will simplify the
implementation of borrowed arguments.

Marking them unresolved is needed to make OSSA verification
conservative until lifetime dependence diagnostics runs.
2024-02-08 22:53:16 -08: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
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