Skip to content

Commit 568c156

Browse files
committed
Mem2Reg: fix a wrong assert
An empty tuple doesn't need to be assigned before it is passed to destroy_addr. I found this by experimenting with the pass pipeline. Not sure if this crash can happen with the current pipeline.
1 parent ba7ecfb commit 568c156

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/SILOptimizer/Transforms/SILMem2Reg.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,15 @@ static void replaceLoad(LoadInst *LI, SILValue val, AllocStackInst *ASI) {
375375

376376
static void replaceDestroy(DestroyAddrInst *DAI, SILValue NewValue) {
377377
SILFunction *F = DAI->getFunction();
378+
auto Ty = DAI->getOperand()->getType();
378379

379-
assert(DAI->getOperand()->getType().isLoadable(*F) &&
380+
assert(Ty.isLoadable(*F) &&
380381
"Unexpected promotion of address-only type!");
381382

382-
assert(NewValue && "Expected a value to release!");
383+
assert(NewValue || (Ty.is<TupleType>() && Ty.getAs<TupleType>()->getNumElements() == 0));
383384

384385
SILBuilderWithScope Builder(DAI);
385386

386-
auto Ty = DAI->getOperand()->getType();
387387
auto &TL = F->getTypeLowering(Ty);
388388

389389
bool expand = shouldExpand(DAI->getModule(),

0 commit comments

Comments
 (0)