Skip to content

Commit 24883bf

Browse files
committed
[SILGen] Copied opaque tuple fields before switch.
The switch_enum_addr consumes its operand so a copy is needed.
1 parent 5ce0148 commit 24883bf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/SILGen/SILGenPattern.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,11 @@ void PatternMatchEmission::emitEnumElementDispatch(
20412041
// be passed take_on_success if src is an address only type.
20422042
assert(src.getFinalConsumption() != CastConsumptionKind::TakeOnSuccess &&
20432043
"Can only have take_on_success with address only values");
2044+
if (src.getType().isAddressOnly(SGF.F) &&
2045+
src.getOwnershipKind() == OwnershipKind::Guaranteed) {
2046+
// If it's an opaque value with guaranteed ownership, we need to copy.
2047+
src = src.copy(SGF, PatternMatchStmt);
2048+
}
20442049

20452050
// Finally perform the enum element dispatch.
20462051
return emitEnumElementObjectDispatch(rows, src, handleCase, outerFailure,

0 commit comments

Comments
 (0)