Skip to content

Commit 6da455e

Browse files
committed
[Distributed] cleanups: use more managed values and cleanups
1 parent a5c2236 commit 6da455e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/SILGen/SILGenDistributed.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,8 +1354,7 @@ void SILGenFunction::emitDistributedThunk(SILDeclRef thunk) {
13541354
// --- Prepare storage for the return value
13551355
// %38 = alloc_stack $String // users: %54, %56, %50, %75
13561356
auto remoteCallReturnBuf = emitTemporaryAllocation(loc, resultType);
1357-
// remoteCallReturnValue = emitManagedBufferWithCleanup(remoteCallReturnBuf); // FIXME: !!!!!!!!!!!!!!!!!!!!!!!!!!
1358-
remoteCallReturnValue = ManagedValue::forUnmanaged(remoteCallReturnBuf); // FIXME: !!!!!!!!!!!!!!!!!!!!!!!!!!
1357+
remoteCallReturnValue = emitManagedBufferWithCleanup(remoteCallReturnBuf);
13591358

13601359
auto systemRef = emitActorPropertyReference(
13611360
*this, loc, selfValue.getValue(),
@@ -1465,7 +1464,7 @@ void SILGenFunction::emitDistributedThunk(SILDeclRef thunk) {
14651464
SmallVector<SILValue, 7> remoteCallArgs;
14661465
// 'out' arguments:
14671466
if (!resultType.isVoid())
1468-
remoteCallArgs.push_back(remoteCallReturnValue.getValue()); // return value buffer
1467+
remoteCallArgs.push_back(remoteCallReturnValue.forward(*this)); // return value buffer
14691468
// function arguments:
14701469
remoteCallArgs.push_back(selfValue.getValue()); // on actor
14711470
remoteCallArgs.push_back(remoteCallTargetValue.getValue()); // target
@@ -1518,9 +1517,7 @@ void SILGenFunction::emitDistributedThunk(SILDeclRef thunk) {
15181517

15191518
auto result = remoteCallReturnValue.getValue();
15201519

1521-
// FIXME: this should be done by emitting the block, before we create the buffer, this way the cleanup won't be here to be flushed yet
1522-
// B.createDeallocStack(loc, result); // FIXME: the reason this is manual is because I could not figure out how to NOT destroy_addr the result on this error exit path
1523-
1520+
// TODO(distributed): make those into cleanups
15241521
B.createEndAccess(loc, invocationEncoderAccess, /*aborted=*/false);
15251522

15261523
// FIXME: these are very hacky, how to do properly?

lib/SILGen/SILGenFunction.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,13 +1072,16 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
10721072
SourceLocArgs
10731073
emitSourceLocationArgs(SourceLoc loc, SILLocation emitLoc);
10741074

1075+
/// Emit a 'String' literal for the passed 'text'.
1076+
///
1077+
/// See also: 'emitLiteral' which works with various types of literals,
1078+
/// however requires an expression to base the creation on.
10751079
ManagedValue
10761080
emitStringLiteral(SILLocation loc,
10771081
StringRef text,
10781082
StringLiteralExpr::Encoding encoding = StringLiteralExpr::Encoding::UTF8,
10791083
SGFContext ctx = SGFContext());
10801084

1081-
10821085
/// Emit a call to the library intrinsic _doesOptionalHaveValue.
10831086
///
10841087
/// The result is a Builtin.Int1.

0 commit comments

Comments
 (0)