@@ -929,6 +929,11 @@ OwnershipRAUWHelper::OwnershipRAUWHelper(OwnershipFixupContext &inputCtx,
929
929
if (!isValid ())
930
930
return ;
931
931
932
+ // If we are not in ownership, we can always RAUW successfully so just bail
933
+ // and leave the object valid.
934
+ if (!oldValue->getFunction ()->hasOwnership ())
935
+ return ;
936
+
932
937
// Otherwise, lets check if we can perform this RAUW operation. If we can't,
933
938
// set ctx to nullptr to invalidate the helper and return.
934
939
if (!canFixUpOwnershipForRAUW (oldValue, newValue, inputCtx)) {
@@ -1030,12 +1035,16 @@ SILBasicBlock::iterator
1030
1035
OwnershipRAUWHelper::perform (SingleValueInstruction *maybeTransformedNewValue) {
1031
1036
assert (isValid () && " OwnershipRAUWHelper invalid?!" );
1032
1037
1033
- // Make sure to always clear our context after we transform.
1034
- SWIFT_DEFER { ctx->clear (); };
1035
1038
SILValue actualNewValue = newValue;
1036
1039
if (maybeTransformedNewValue)
1037
1040
actualNewValue = maybeTransformedNewValue;
1038
1041
1042
+ if (!oldValue->getFunction ()->hasOwnership ())
1043
+ return replaceAllUsesAndErase (oldValue, actualNewValue, ctx->callbacks );
1044
+
1045
+ // Make sure to always clear our context after we transform.
1046
+ SWIFT_DEFER { ctx->clear (); };
1047
+
1039
1048
if (oldValue->getType ().isAddress ())
1040
1049
return replaceAddressUses (oldValue, actualNewValue);
1041
1050
0 commit comments