File tree Expand file tree Collapse file tree 4 files changed +25
-7
lines changed Expand file tree Collapse file tree 4 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -1033,9 +1033,16 @@ ANY_OWNERSHIP_BUILTIN(IntInstrprofIncrement)
1033
1033
}
1034
1034
CONSTANT_OWNERSHIP_BUILTIN (Owned, MustBeInvalidated, COWBufferForReading)
1035
1035
CONSTANT_OWNERSHIP_BUILTIN (Owned, MustBeInvalidated, UnsafeGuaranteed)
1036
- CONSTANT_OWNERSHIP_BUILTIN (Owned, MustBeInvalidated, GetCurrentAsyncTask)
1037
1036
#undef CONSTANT_OWNERSHIP_BUILTIN
1038
1037
1038
+ #define SHOULD_NEVER_VISIT_BUILTIN (ID ) \
1039
+ OperandOwnershipKindMap OperandOwnershipKindBuiltinClassifier::visit##ID( \
1040
+ BuiltinInst *, StringRef) { \
1041
+ llvm_unreachable (" Builtin should never be visited! E.x.: It may not have arguments" ); \
1042
+ }
1043
+ SHOULD_NEVER_VISIT_BUILTIN (GetCurrentAsyncTask)
1044
+ #undef SHOULD_NEVER_VISIT_BUILTIN
1045
+
1039
1046
// Builtins that should be lowered to SIL instructions so we should never see
1040
1047
// them.
1041
1048
#define BUILTIN_SIL_OPERATION (ID, NAME, CATEGORY ) \
Original file line number Diff line number Diff line change @@ -1402,8 +1402,7 @@ static ManagedValue emitBuiltinGetCurrentAsyncTask(
1402
1402
loc,
1403
1403
ctx.getIdentifier (getBuiltinName (BuiltinValueKind::GetCurrentAsyncTask)),
1404
1404
SGF.getLoweredType (ctx.TheNativeObjectType ), SubstitutionMap (), { });
1405
- SGF.enterEndLifetimeCleanup (apply);
1406
- return ManagedValue::forUnmanaged (apply);
1405
+ return SGF.emitManagedRValueWithEndLifetimeCleanup (apply);
1407
1406
}
1408
1407
1409
1408
Optional<SpecializedEmitter>
Original file line number Diff line number Diff line change @@ -1347,9 +1347,10 @@ class EndLifetimeCleanup : public Cleanup {
1347
1347
};
1348
1348
} // end anonymous namespace
1349
1349
1350
- CleanupHandle SILGenFunction::enterEndLifetimeCleanup (SILValue value) {
1350
+ ManagedValue SILGenFunction::emitManagedRValueWithEndLifetimeCleanup (
1351
+ SILValue value) {
1351
1352
Cleanups.pushCleanup <EndLifetimeCleanup>(value);
1352
- return Cleanups. getTopCleanup ( );
1353
+ return ManagedValue::forUnmanaged (value );
1353
1354
}
1354
1355
1355
1356
namespace {
Original file line number Diff line number Diff line change @@ -2001,8 +2001,19 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
2001
2001
// / Enter a cleanup to emit a ReleaseValue/DestroyAddr of the specified value.
2002
2002
CleanupHandle enterDestroyCleanup (SILValue valueOrAddr);
2003
2003
2004
- // / Enter cleanup to emit an EndLifetime operation for the given value.
2005
- CleanupHandle enterEndLifetimeCleanup (SILValue value);
2004
+ // / Return an owned managed value for \p value that is cleaned up using an end_lifetime instruction.
2005
+ // /
2006
+ // / The end_lifetime cleanup is not placed into the ManagedValue itself and
2007
+ // / thus can not be forwarded. This means that the ManagedValue is treated
2008
+ // / as a +0 value. This means that the owned value will be copied by SILGen
2009
+ // / if it is ever needed as a +1 value (meaning any time that the value
2010
+ // / escapes).
2011
+ // /
2012
+ // / DISCUSSION: end_lifetime ends the lifetime of an owned value in OSSA
2013
+ // / without resulting in a destroy being emitted. This cleanup should only
2014
+ // / be used for owned values that do not need to be destroyed if they do not
2015
+ // / escape the current call frame but need to be copied if they escape.
2016
+ ManagedValue emitManagedRValueWithEndLifetimeCleanup (SILValue value);
2006
2017
2007
2018
// / Enter a cleanup to emit a DeinitExistentialAddr or DeinitExistentialBox
2008
2019
// / of the specified value.
You can’t perform that action at this time.
0 commit comments