Skip to content

Commit 463922c

Browse files
committed
Allow RAUW to optimize struct_extract from function args
1 parent 698ed8e commit 463922c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/SILOptimizer/Utils/OwnershipOptUtils.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,11 @@ static bool canFixUpOwnershipForRAUW(SILValue oldValue, SILValue newValue,
350350
if (oldValue.getOwnershipKind() != OwnershipKind::Guaranteed)
351351
return true;
352352

353-
SILValue newRoot = findOwnershipReferenceRoot(newValue);
354-
if (newRoot && isa<SILFunctionArgument>(newRoot))
353+
SILValue newRoot = findOwnershipReferenceAggregate(newValue);
354+
if (newRoot && isa<SILFunctionArgument>(newRoot)
355+
&& newRoot->getOwnershipKind() == OwnershipKind::Guaranteed) {
355356
return true;
356-
357+
}
357358
// Check that the old lifetime can be extended and record the necessary
358359
// book-keeping in the OwnershipFixupContext.
359360
context.clear();
@@ -875,7 +876,7 @@ OwnershipLifetimeExtender::borrowOverValue(SILValue newValue,
875876
SILValue guaranteedValue) {
876877
// Avoid borrowing guaranteed function arguments.
877878
if (newValue.getOwnershipKind() == OwnershipKind::Guaranteed) {
878-
SILValue newRoot = findOwnershipReferenceRoot(newValue);
879+
SILValue newRoot = findOwnershipReferenceAggregate(newValue);
879880
if (newRoot && isa<SILFunctionArgument>(newRoot))
880881
return newValue;
881882
}

0 commit comments

Comments
 (0)