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 {
422422
423423 return buildFn ( specializedFunction, nestedFunctionPassContext)
424424 }
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+ }
425433}
426434
427435struct SimplifyContext : MutatingContext {
Original file line number Diff line number Diff line change @@ -397,6 +397,8 @@ struct BridgedPassContext {
397397 SwiftInt paramCount,
398398 BridgedFunction bridgedApplySiteCallee,
399399 bool isSerialized) const ;
400+
401+ bool completeLifetime (BridgedValue value) const ;
400402};
401403
402404bool FullApplySite_canInline (BridgedInstruction apply);
Original file line number Diff line number Diff line change 2121#include " swift/Demangling/Demangler.h"
2222#include " swift/SIL/ApplySite.h"
2323#include " swift/SIL/DynamicCasts.h"
24+ #include " swift/SIL/OSSALifetimeCompletion.h"
2425#include " swift/SIL/SILBridging.h"
2526#include " swift/SIL/SILCloner.h"
2627#include " swift/SIL/SILFunction.h"
@@ -2041,6 +2042,16 @@ ClosureSpecializer_createEmptyFunctionWithSpecializedSignature(BridgedStringRef
20412042 return {specializedApplySiteCallee};
20422043}
20432044
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+
20442055bool FullApplySite_canInline (BridgedInstruction apply) {
20452056 return swift::SILInliner::canInlineApplySite (
20462057 swift::FullApplySite (apply.unbridged ()));
You can’t perform that action at this time.
0 commit comments