@@ -2348,41 +2348,45 @@ JumpDest PatternMatchEmission::getSharedCaseBlockDest(CaseStmt *caseBlock) {
23482348}
23492349
23502350void PatternMatchEmission::emitAddressOnlyAllocations () {
2351- for (auto &entry: SharedCases) {
2351+ for (auto &entry : SharedCases) {
23522352 CaseStmt *caseBlock = entry.first ;
23532353
2354+ if (!caseBlock->hasBoundDecls ()) {
2355+ continue ;
2356+ }
2357+
23542358 // If we have a shared case with bound decls, then the 0th pattern has the
23552359 // order of variables that are the incoming BB arguments. Setup the VarLocs
23562360 // to point to the incoming args and setup initialization so any args needing
23572361 // cleanup will get that as well.
2358- if (caseBlock->hasBoundDecls ()) {
2359- auto pattern = caseBlock->getCaseLabelItems ()[0 ].getPattern ();
2360- pattern->forEachVariable ([&](VarDecl *V) {
2361- if (!V->hasName ())
2362- return ;
2362+ auto pattern = caseBlock->getCaseLabelItems ()[0 ].getPattern ();
2363+ pattern->forEachVariable ([&](VarDecl *vd) {
2364+ if (!vd->hasName ())
2365+ return ;
23632366
2364- SILType ty = SGF.getLoweredType (V ->getType ());
2365- if (ty.isNull ()) {
2366- // If we're making the shared block on behalf of a previous case's
2367- // fallthrough, caseBlock's VarDecl's won't be in the SGF yet, so
2368- // determine phi types by using current vars of the same name.
2369- for (auto var : SGF.VarLocs ) {
2370- auto varDecl = dyn_cast<VarDecl>(var.getFirst ());
2371- if (varDecl && varDecl->hasName () && varDecl-> getName () == V-> getName ()) {
2372- ty = var. getSecond (). value -> getType ();
2373- if (var. getSecond (). box ) {
2374- ty = ty. getObjectType ();
2375- }
2376- }
2367+ SILType ty = SGF.getLoweredType (vd ->getType ());
2368+ if (ty.isNull ()) {
2369+ // If we're making the shared block on behalf of a previous case's
2370+ // fallthrough, caseBlock's VarDecl's won't be in the SGF yet, so
2371+ // determine phi types by using current vars of the same name.
2372+ for (auto var : SGF.VarLocs ) {
2373+ auto varDecl = dyn_cast<VarDecl>(var.getFirst ());
2374+ if (! varDecl || ! varDecl->hasName () ||
2375+ varDecl-> getName () != vd-> getName ())
2376+ continue ;
2377+ ty = var. getSecond (). value -> getType ();
2378+ if (var. getSecond (). box ) {
2379+ ty = ty. getObjectType ();
23772380 }
23782381 }
2379- if (ty.isAddressOnly (SGF.F .getModule ())) {
2380- assert (!Temporaries[V]);
2381- Temporaries[V] = SGF.emitTemporaryAllocation (V, ty);
2382- return ;
2383- }
2384- });
2385- }
2382+ }
2383+
2384+ if (ty.isAddressOnly (SGF.F .getModule ())) {
2385+ assert (!Temporaries[vd]);
2386+ Temporaries[vd] = SGF.emitTemporaryAllocation (vd, ty);
2387+ return ;
2388+ }
2389+ });
23862390 }
23872391
23882392 // Now we have all of our cleanups entered, so we can record the
0 commit comments