Skip to content

Commit e5f0ac6

Browse files
committed
OpaqueValues: ensure no-implicit-copy captures are correct
1 parent e39a31a commit e5f0ac6

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

lib/SILGen/SILGenProlog.cpp

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,31 +1341,14 @@ static void emitCaptureArguments(SILGenFunction &SGF,
13411341
arg = SILValue(fArg);
13421342

13431343
if (isNoImplicitCopy && !arg->getType().isMoveOnly()) {
1344-
// FIXME: this incompatible with -enable-sil-opaque-values
1345-
switch (fnConv.getSILArgumentConvention(argIndex)) {
1346-
case SILArgumentConvention::Indirect_Inout:
1347-
case SILArgumentConvention::Indirect_InoutAliasable:
1348-
case SILArgumentConvention::Indirect_In:
1349-
case SILArgumentConvention::Indirect_In_Guaranteed:
1350-
case SILArgumentConvention::Indirect_In_CXX:
1351-
case SILArgumentConvention::Pack_Inout:
1352-
case SILArgumentConvention::Pack_Owned:
1353-
case SILArgumentConvention::Pack_Guaranteed:
1344+
if (fnConv.isSILIndirect(paramInfo)) {
13541345
arg = SGF.B.createCopyableToMoveOnlyWrapperAddr(VD, arg);
1355-
break;
1356-
1357-
case SILArgumentConvention::Direct_Owned:
1358-
arg = SGF.B.createOwnedCopyableToMoveOnlyWrapperValue(VD, arg);
1359-
break;
1360-
1361-
case SILArgumentConvention::Direct_Guaranteed:
1346+
1347+
} else if (paramInfo.isGuaranteedInCallee()) {
13621348
arg = SGF.B.createGuaranteedCopyableToMoveOnlyWrapperValue(VD, arg);
1363-
break;
1364-
1365-
case SILArgumentConvention::Direct_Unowned:
1366-
case SILArgumentConvention::Indirect_Out:
1367-
case SILArgumentConvention::Pack_Out:
1368-
llvm_unreachable("should be impossible");
1349+
1350+
} else {
1351+
arg = SGF.B.createOwnedCopyableToMoveOnlyWrapperValue(VD, arg);
13691352
}
13701353
}
13711354

test/SILOptimizer/moveonly_copyable_wrapper_capture.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-swift-frontend -emit-sil -verify %s
2+
// RUN: %target-swift-frontend -enable-sil-opaque-values -sil-verify-all -emit-sil -verify %s
23

34
class Class {}
45
//struct Class : ~Copyable {}

0 commit comments

Comments
 (0)