File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
SwiftCompilerSources/Sources/Optimizer/PassManager
include/swift/SILOptimizer
lib/SILOptimizer/PassManager Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -422,6 +422,14 @@ struct FunctionPassContext : MutatingContext {
422
422
423
423
return buildFn ( specializedFunction, nestedFunctionPassContext)
424
424
}
425
+
426
+ /// Makes sure that the lifetime of `value` ends at all control flow paths, even in dead-end blocks.
427
+ /// Inserts destroys in dead-end blocks if those are missing.
428
+ func completeLifetime( of value: Value ) {
429
+ if _bridged. completeLifetime ( value. bridged) {
430
+ notifyInstructionsChanged ( )
431
+ }
432
+ }
425
433
}
426
434
427
435
struct SimplifyContext : MutatingContext {
Original file line number Diff line number Diff line change @@ -397,6 +397,8 @@ struct BridgedPassContext {
397
397
SwiftInt paramCount,
398
398
BridgedFunction bridgedApplySiteCallee,
399
399
bool isSerialized) const ;
400
+
401
+ bool completeLifetime (BridgedValue value) const ;
400
402
};
401
403
402
404
bool FullApplySite_canInline (BridgedInstruction apply);
Original file line number Diff line number Diff line change 21
21
#include " swift/Demangling/Demangler.h"
22
22
#include " swift/SIL/ApplySite.h"
23
23
#include " swift/SIL/DynamicCasts.h"
24
+ #include " swift/SIL/OSSALifetimeCompletion.h"
24
25
#include " swift/SIL/SILBridging.h"
25
26
#include " swift/SIL/SILCloner.h"
26
27
#include " swift/SIL/SILFunction.h"
@@ -2041,6 +2042,16 @@ ClosureSpecializer_createEmptyFunctionWithSpecializedSignature(BridgedStringRef
2041
2042
return {specializedApplySiteCallee};
2042
2043
}
2043
2044
2045
+ bool BridgedPassContext::completeLifetime (BridgedValue value) const {
2046
+ SILValue v = value.getSILValue ();
2047
+ SILFunction *f = v->getFunction ();
2048
+ DeadEndBlocks *deb = invocation->getPassManager ()->getAnalysis <DeadEndBlocksAnalysis>()->get (f);
2049
+ DominanceInfo *domInfo = invocation->getPassManager ()->getAnalysis <DominanceAnalysis>()->get (f);
2050
+ OSSALifetimeCompletion completion (f, domInfo, *deb);
2051
+ auto result = completion.completeOSSALifetime (v, OSSALifetimeCompletion::Boundary::Availability);
2052
+ return result == LifetimeCompletion::WasCompleted;
2053
+ }
2054
+
2044
2055
bool FullApplySite_canInline (BridgedInstruction apply) {
2045
2056
return swift::SILInliner::canInlineApplySite (
2046
2057
swift::FullApplySite (apply.unbridged ()));
You can’t perform that action at this time.
0 commit comments