Skip to content

Commit c895a9b

Browse files
committed
Add a flag to disable copy elimination of captures in ClosureLifetimeFixup
1 parent 98074a8 commit c895a9b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/SILOptimizer/Mandatory/ClosureLifetimeFixup.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ llvm::cl::opt<bool> DisableConvertEscapeToNoEscapeSwitchEnumPeephole(
4141
"Disable the convert_escape_to_noescape switch enum peephole. "),
4242
llvm::cl::Hidden);
4343

44+
llvm::cl::opt<bool> DisableCopyEliminationOfCopyableCapture(
45+
"sil-disable-copy-elimination-of-copyable-closure-capture",
46+
llvm::cl::init(false),
47+
llvm::cl::desc("Don't eliminate copy_addr of Copyable closure captures "
48+
"inserted by SILGen"));
49+
4450
using namespace swift;
4551

4652
/// Given an optional diamond, return the bottom of the diamond.
@@ -761,6 +767,13 @@ static SILValue tryRewriteToPartialApplyStack(
761767
continue;
762768
}
763769

770+
if (DisableCopyEliminationOfCopyableCapture) {
771+
if (!copy->getType().isMoveOnly()) {
772+
LLVM_DEBUG(llvm::dbgs() << "-- not move-only\n");
773+
continue;
774+
}
775+
}
776+
764777
// Is the capture a borrow?
765778

766779
auto paramIndex = i + appliedArgStartIdx;

test/SILOptimizer/closure-lifetime-fixup-debuginfo.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-sil-opt -enable-sil-verify-all -closure-lifetime-fixup -emit-verbose-sil %s | %FileCheck %s
1+
// RUN: %target-sil-opt -enable-sil-verify-all -closure-lifetime-fixup -emit-verbose-sil -sil-disable-copy-elimination-of-copyable-closure-capture=true %s | %FileCheck %s
22

33
import Builtin
44
import Swift

0 commit comments

Comments
 (0)