Skip to content

Commit b1ea908

Browse files
authored
In TempRVO, be more explicit on handling non - onstack partial_apply (#30837)
We should not optimize away the copy_addr of a guaranteed parameter of a non-onstack partial_apply. This is not a bug currently, because TempRVO checks if the lifetime end points of the temp object are destroy_addr's in TempRValueOptPass::checkTempObjectDestroy. This change makes it explicit on which partial_apply's are ok to optimize. rdar://61349083
1 parent bd44fb3 commit b1ea908

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/SILOptimizer/Transforms/TempRValueElimination.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,11 @@ bool TempRValueOptPass::collectLoads(
166166
}
167167
return true;
168168
}
169-
case SILInstructionKind::ApplyInst:
170169
case SILInstructionKind::PartialApplyInst:
170+
if (!cast<PartialApplyInst>(user)->isOnStack())
171+
return false;
172+
LLVM_FALLTHROUGH;
173+
case SILInstructionKind::ApplyInst:
171174
case SILInstructionKind::TryApplyInst: {
172175
ApplySite apply(user);
173176

0 commit comments

Comments
 (0)