Skip to content

Commit d6a1015

Browse files
committed
[+0-normal-args] Be sure if we are forwarding arguments into memory, that we do it at +1.
This can only happen when +0 is enabled. The reason why is that guaranteed self is immutable so can not be passed inout without going through a var. There are no other cases I can think of where an ArgumentSource will put self into memory. This is tested by the updated SILGen +0 tests. rdar://34222540
1 parent 6dc41d8 commit d6a1015

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/SILGen/ArgumentSource.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void ArgumentSource::forwardInto(SILGenFunction &SGF, Initialization *dest) && {
236236
llvm_unreachable("cannot forward an l-value");
237237
case Kind::RValue: {
238238
auto loc = getKnownRValueLocation();
239-
std::move(*this).asKnownRValue(SGF).forwardInto(SGF, loc, dest);
239+
std::move(*this).asKnownRValue(SGF).ensurePlusOne(SGF, loc).forwardInto(SGF, loc, dest);
240240
return;
241241
}
242242
case Kind::Expr: {
@@ -248,7 +248,7 @@ void ArgumentSource::forwardInto(SILGenFunction &SGF, Initialization *dest) && {
248248
auto loc = getKnownTupleLocation();
249249
auto rvalue = std::move(*this).getKnownTupleAsRValue(SGF, SGFContext(dest));
250250
if (!rvalue.isInContext())
251-
std::move(rvalue).forwardInto(SGF, loc, dest);
251+
std::move(rvalue).ensurePlusOne(SGF, loc).forwardInto(SGF, loc, dest);
252252
return;
253253
}
254254
}

0 commit comments

Comments
 (0)