mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[silgen] Hoist specialization code in emitTupleDispatch so that it does not cause the SIL emission code to be split.
This commit is contained in:
@@ -1402,6 +1402,18 @@ void PatternMatchEmission::emitTupleDispatchWithOwnership(
|
||||
ArrayRef<RowToSpecialize> rows, ConsumableManagedValue src,
|
||||
const SpecializationHandler &handleCase,
|
||||
const FailureHandler &outerFailure) {
|
||||
// Construct the specialized rows.
|
||||
SmallVector<SpecializedRow, 4> specializedRows;
|
||||
specializedRows.resize(rows.size());
|
||||
for (unsigned i = 0, e = rows.size(); i != e; ++i) {
|
||||
specializedRows[i].RowIndex = rows[i].RowIndex;
|
||||
|
||||
auto pattern = cast<TuplePattern>(rows[i].Pattern);
|
||||
for (auto &elt : pattern->getElements()) {
|
||||
specializedRows[i].Patterns.push_back(elt.getPattern());
|
||||
}
|
||||
}
|
||||
|
||||
auto firstPat = rows[0].Pattern;
|
||||
auto sourceType = cast<TupleType>(firstPat->getType()->getCanonicalType());
|
||||
SILLocation loc = firstPat;
|
||||
@@ -1429,18 +1441,6 @@ void PatternMatchEmission::emitTupleDispatchWithOwnership(
|
||||
destructured.push_back(memberCMV);
|
||||
}
|
||||
|
||||
// Construct the specialized rows.
|
||||
SmallVector<SpecializedRow, 4> specializedRows;
|
||||
specializedRows.resize(rows.size());
|
||||
for (unsigned i = 0, e = rows.size(); i != e; ++i) {
|
||||
specializedRows[i].RowIndex = rows[i].RowIndex;
|
||||
|
||||
auto pattern = cast<TuplePattern>(rows[i].Pattern);
|
||||
for (auto &elt : pattern->getElements()) {
|
||||
specializedRows[i].Patterns.push_back(elt.getPattern());
|
||||
}
|
||||
}
|
||||
|
||||
// Maybe revert to the original cleanups during failure branches.
|
||||
const FailureHandler *innerFailure = &outerFailure;
|
||||
FailureHandler specializedFailure = [&](SILLocation loc) {
|
||||
|
||||
Reference in New Issue
Block a user