@@ -2348,41 +2348,45 @@ JumpDest PatternMatchEmission::getSharedCaseBlockDest(CaseStmt *caseBlock) {
2348
2348
}
2349
2349
2350
2350
void PatternMatchEmission::emitAddressOnlyAllocations () {
2351
- for (auto &entry: SharedCases) {
2351
+ for (auto &entry : SharedCases) {
2352
2352
CaseStmt *caseBlock = entry.first ;
2353
2353
2354
+ if (!caseBlock->hasBoundDecls ()) {
2355
+ continue ;
2356
+ }
2357
+
2354
2358
// If we have a shared case with bound decls, then the 0th pattern has the
2355
2359
// order of variables that are the incoming BB arguments. Setup the VarLocs
2356
2360
// to point to the incoming args and setup initialization so any args needing
2357
2361
// 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 ;
2363
2366
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 ();
2377
2380
}
2378
2381
}
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
+ });
2386
2390
}
2387
2391
2388
2392
// Now we have all of our cleanups entered, so we can record the
0 commit comments