Skip to content

Commit 1846159

Browse files
Merge pull request #73270 from aschwaighofer/large_types_reg2mem_yield_begin_apply
LargeTypesReg2Mem: Fix yield and begin_apply instructions
2 parents f544aac + ff46829 commit 1846159

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3612,6 +3612,23 @@ class AssignAddressToDef : SILInstructionVisitor<AssignAddressToDef> {
36123612
singleValueInstructionFallback(kp);
36133613
}
36143614

3615+
void visitBeginApplyInst(BeginApplyInst *apply) {
3616+
auto builder = assignment.getBuilder(++apply->getIterator());
3617+
auto addr = assignment.createAllocStack(origValue->getType());
3618+
assignment.mapValueToAddress(origValue, addr);
3619+
for (auto &opd : apply->getAllOperands()) {
3620+
if (assignment.contains(opd.get())) {
3621+
auto builder = assignment.getBuilder(apply->getIterator());
3622+
auto loaded = builder.createLoad(
3623+
apply->getLoc(), assignment.getAddressForValue(opd.get()),
3624+
LoadOwnershipQualifier::Unqualified);
3625+
opd.set(loaded);
3626+
}
3627+
}
3628+
builder.createStore(apply->getLoc(), origValue, addr,
3629+
StoreOwnershipQualifier::Unqualified);
3630+
}
3631+
36153632
void visitApplyInst(ApplyInst *apply) {
36163633
// The loadable by address transformation ignores large tuple return types.
36173634
auto builder = assignment.getBuilder(++apply->getIterator());
@@ -3865,6 +3882,8 @@ class RewriteUser : SILInstructionVisitor<RewriteUser> {
38653882
userInstructionFallback(kp);
38663883
}
38673884

3885+
void visitYieldInst(YieldInst *yield) { userInstructionFallback(yield); }
3886+
38683887
void visitFixLifetimeInst(FixLifetimeInst *f) {
38693888
auto addr = assignment.getAddressForValue(f->getOperand());
38703889
auto builder = assignment.getBuilder(f->getIterator());

0 commit comments

Comments
 (0)