From 7adfc524478bcb8f21cdeccedf2eeebb9dd5421a Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Tue, 6 Aug 2019 15:09:01 -0700 Subject: [PATCH] SILGen: Emit bb args for shared loadable case bindings that come after address-only ones. Looks like a think-o; even if we see an address-only binding in a shared pattern block, we still expect bb args in the lowered basic block for anything that comes after it. rdar://problem/53956564 --- lib/SILGen/SILGenPattern.cpp | 2 +- .../SILGen/switch_mixed_address_only_loadable.swift | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/SILGen/switch_mixed_address_only_loadable.swift diff --git a/lib/SILGen/SILGenPattern.cpp b/lib/SILGen/SILGenPattern.cpp index c02daaeefff..8ba6dd12272 100644 --- a/lib/SILGen/SILGenPattern.cpp +++ b/lib/SILGen/SILGenPattern.cpp @@ -2341,7 +2341,7 @@ void PatternMatchEmission::initSharedCaseBlockDest(CaseStmt *caseBlock, // We don't pass address-only values in basic block arguments. SILType ty = SGF.getLoweredType(vd->getType()); if (ty.isAddressOnly(SGF.F)) - return; + continue; block->createPhiArgument(ty, ValueOwnershipKind::Owned, vd); } } diff --git a/test/SILGen/switch_mixed_address_only_loadable.swift b/test/SILGen/switch_mixed_address_only_loadable.swift new file mode 100644 index 00000000000..20d4638ede8 --- /dev/null +++ b/test/SILGen/switch_mixed_address_only_loadable.swift @@ -0,0 +1,13 @@ +// RUN: %target-swift-emit-silgen %s + +// rdar://problem/53956564 + +func foo(x: Int, y: T, z: Int) { + switch (x, y, z) { + case (let xx, let yy, let zz), (let xx, let yy, let zz): + _ = xx + _ = yy + _ = zz + break + } +}