@@ -1275,9 +1275,11 @@ void Implementation::rewriteUses(InstructionDeleter *deleter) {
1275
1275
first = builder.createOwnedMoveOnlyWrapperToCopyableValue (
1276
1276
getSafeLoc (inst), first);
1277
1277
}
1278
+ // NOTE: oldInst may be nullptr if our operand is a SILArgument
1279
+ // which can happen with switch_enum.
1278
1280
SILInstruction *oldInst = operand.get ()->getDefiningInstruction ();
1279
1281
operand.set (first);
1280
- if (deleter)
1282
+ if (oldInst && deleter)
1281
1283
deleter->forceTrackAsDead (oldInst);
1282
1284
continue ;
1283
1285
}
@@ -1309,9 +1311,11 @@ void Implementation::rewriteUses(InstructionDeleter *deleter) {
1309
1311
// NOTE: This needs to be /after/the interior pointer operand usage
1310
1312
// above so that we can use the end scope of our interior pointer base
1311
1313
// value.
1314
+ // NOTE: oldInst may be nullptr if our operand is a SILArgument
1315
+ // which can happen with switch_enum.
1312
1316
SILInstruction *oldInst = operand.get ()->getDefiningInstruction ();
1313
1317
operand.set (innerValue);
1314
- if (deleter)
1318
+ if (oldInst && deleter)
1315
1319
deleter->forceTrackAsDead (oldInst);
1316
1320
continue ;
1317
1321
}
@@ -1370,9 +1374,11 @@ void Implementation::rewriteUses(InstructionDeleter *deleter) {
1370
1374
borrowBuilder.createGuaranteedMoveOnlyWrapperToCopyableValue (
1371
1375
loc, value);
1372
1376
}
1377
+ // NOTE: oldInst may be nullptr if our operand is a SILArgument
1378
+ // which can happen with switch_enum.
1373
1379
auto *oldInst = operand.get ()->getDefiningInstruction ();
1374
1380
operand.set (value);
1375
- if (deleter)
1381
+ if (oldInst && deleter)
1376
1382
deleter->forceTrackAsDead (oldInst);
1377
1383
1378
1384
// If we have a terminator that is a trivial use (e.x.: we
@@ -1443,9 +1449,11 @@ void Implementation::rewriteUses(InstructionDeleter *deleter) {
1443
1449
iterValue = consumeBuilder.createOwnedMoveOnlyWrapperToCopyableValue (
1444
1450
loc, iterValue);
1445
1451
}
1452
+ // NOTE: oldInst may be nullptr if our operand is a SILArgument
1453
+ // which can happen with switch_enum.
1446
1454
auto *oldInst = operand.get ()->getDefiningInstruction ();
1447
1455
operand.set (iterValue);
1448
- if (deleter)
1456
+ if (oldInst && deleter)
1449
1457
deleter->forceTrackAsDead (oldInst);
1450
1458
1451
1459
// Then go through our available values and use the interval map to
0 commit comments