Skip to content

Commit 7960660

Browse files
committed
SILGen: TupleShuffleExprs in the rvalue emission path can't have scalar-to-tuple or tuple-to-scalar
1 parent 003d9c0 commit 7960660

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

lib/SILGen/SILGenExpr.cpp

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,13 +2527,9 @@ static void emitTupleShuffleExprInto(RValueEmitter &emitter,
25272527
// Map outer initializations into a tuple of inner initializations:
25282528
// - fill out the initialization elements with null
25292529
TupleInitialization innerTupleInit;
2530-
if (E->isSourceScalar()) {
2531-
innerTupleInit.SubInitializations.push_back(nullptr);
2532-
} else {
2533-
CanTupleType innerTuple =
2534-
cast<TupleType>(E->getSubExpr()->getType()->getCanonicalType());
2535-
innerTupleInit.SubInitializations.resize(innerTuple->getNumElements());
2536-
}
2530+
CanTupleType innerTuple =
2531+
cast<TupleType>(E->getSubExpr()->getType()->getCanonicalType());
2532+
innerTupleInit.SubInitializations.resize(innerTuple->getNumElements());
25372533

25382534
// Map all the outer initializations to their appropriate targets.
25392535
for (unsigned outerIndex = 0; outerIndex != outerInits.size(); outerIndex++) {
@@ -2551,18 +2547,16 @@ static void emitTupleShuffleExprInto(RValueEmitter &emitter,
25512547
#endif
25522548

25532549
// Emit the sub-expression into the tuple initialization we just built.
2554-
if (E->isSourceScalar()) {
2555-
emitter.SGF.emitExprInto(E->getSubExpr(),
2556-
innerTupleInit.SubInitializations[0].get());
2557-
} else {
2558-
emitter.SGF.emitExprInto(E->getSubExpr(), &innerTupleInit);
2559-
}
2550+
emitter.SGF.emitExprInto(E->getSubExpr(), &innerTupleInit);
25602551

25612552
outerTupleInit->finishInitialization(emitter.SGF);
25622553
}
25632554

25642555
RValue RValueEmitter::visitTupleShuffleExpr(TupleShuffleExpr *E,
25652556
SGFContext C) {
2557+
assert(!E->isSourceScalar());
2558+
assert(!E->isResultScalar());
2559+
25662560
// If we're emitting into an initialization, we can try shuffling the
25672561
// elements of the initialization.
25682562
if (Initialization *I = C.getEmitInto()) {
@@ -2574,11 +2568,7 @@ RValue RValueEmitter::visitTupleShuffleExpr(TupleShuffleExpr *E,
25742568

25752569
// Emit the sub-expression tuple and destructure it into elements.
25762570
SmallVector<RValue, 4> elements;
2577-
if (E->isSourceScalar()) {
2578-
elements.push_back(visit(E->getSubExpr()));
2579-
} else {
2580-
visit(E->getSubExpr()).extractElements(elements);
2581-
}
2571+
visit(E->getSubExpr()).extractElements(elements);
25822572

25832573
// Prepare a new tuple to hold the shuffled result.
25842574
RValue result(E->getType()->getCanonicalType());

0 commit comments

Comments
 (0)