Skip to content

Commit 848312e

Browse files
Merge pull request #71517 from aschwaighofer/large_types_reg2mem_optional_fix
LargeTypesReg2Mem: Handle the optional projections with larger payloads
2 parents 288ad68 + ed7dead commit 848312e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4266,8 +4266,11 @@ static void runPeepholesAndReg2Mem(SILPassManager *pm, SILModule *silMod,
42664266
// switch_enum.
42674267
if (auto *pred = bb.getSinglePredecessorBlock()) {
42684268
// switch_enum handles the basic block arguments independently.
4269-
if (isa<SwitchEnumInst>(pred->getTerminator()))
4270-
continue;
4269+
if (auto sw = dyn_cast<SwitchEnumInst>(pred->getTerminator())) {
4270+
if (assignment.isLargeLoadableType(sw->getOperand()->getType())) {
4271+
continue;
4272+
}
4273+
}
42714274
}
42724275

42734276
// Handle all other basic block arguments.
@@ -4282,7 +4285,8 @@ static void runPeepholesAndReg2Mem(SILPassManager *pm, SILModule *silMod,
42824285
// Large try apply results have to be stored to their stack location
42834286
// in the success block.
42844287
if (auto *pred = bb.getSinglePredecessorBlock()) {
4285-
if (auto *term = dyn_cast<TryApplyInst>(pred->getTerminator())) {
4288+
if (isa<TryApplyInst>(pred->getTerminator()) ||
4289+
isa<SwitchEnumInst>(pred->getTerminator())) {
42864290
assert(bb.getArguments().size() == 1);
42874291
shouldDeleteBlockArgument = false;
42884292
// We will emit the store to initialize after parsing all other

0 commit comments

Comments
 (0)