Skip to content

Commit 0806f40

Browse files
committed
[move-only] Fix SILCombine to preserve value deinit
Fix a special case in visitReleaseValueInst for enum-with-deinit. (cherry picked from commit 58f96a9)
1 parent 716eb85 commit 0806f40

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,10 @@ SILInstruction *SILCombiner::visitReleaseValueInst(ReleaseValueInst *RVI) {
10841084
SILValue Operand = RVI->getOperand();
10851085
SILType OperandTy = Operand->getType();
10861086

1087+
// Do not remove a release that calls a value deinit.
1088+
if (hasValueDeinit(OperandTy))
1089+
return nullptr;
1090+
10871091
// Destroy value of an enum with a trivial payload or no-payload is a no-op.
10881092
if (auto *EI = dyn_cast<EnumInst>(Operand)) {
10891093
if (!EI->hasOperand() ||

0 commit comments

Comments
 (0)