File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
lib/SILOptimizer/SILCombiner Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -1520,8 +1520,14 @@ SILInstruction *SILCombiner::legacyVisitApplyInst(ApplyInst *AI) {
15201520 return nullptr ;
15211521
15221522 SILValue callee = AI->getCallee ();
1523- if (auto *cee = dyn_cast<ConvertEscapeToNoEscapeInst>(callee)) {
1524- callee = cee->getOperand ();
1523+ for (;;) {
1524+ if (auto *cee = dyn_cast<ConvertEscapeToNoEscapeInst>(callee)) {
1525+ callee = cee->getOperand ();
1526+ } else if (auto *mdi = dyn_cast<MarkDependenceInst>(callee)) {
1527+ callee = mdi->getValue ();
1528+ } else {
1529+ break ;
1530+ }
15251531 }
15261532 if (auto *CFI = dyn_cast<ConvertFunctionInst>(callee))
15271533 return optimizeApplyOfConvertFunctionInst (AI, CFI);
Original file line number Diff line number Diff line change @@ -1172,6 +1172,22 @@ bb0(%0 : $Int):
11721172 return %r : $()
11731173}
11741174
1175+ // CHECK-LABEL: sil [ossa] @test_mark_dependence_of_closure :
1176+ // CHECK-NOT: partial_apply
1177+ // CHECK-LABEL: } // end sil function 'test_mark_dependence_of_closure'
1178+ sil [ossa] @test_mark_dependence_of_closure : $@convention(thin) (Int) -> () {
1179+ bb0(%0 : $Int):
1180+ %3 = function_ref @closure2 : $@convention(thin) (Int) -> ()
1181+ %4 = partial_apply %3(%0) : $@convention(thin) (Int) -> ()
1182+ %5 = convert_function %4 to $@callee_owned () -> ()
1183+ %6 = convert_escape_to_noescape %5 to $@noescape @callee_owned () -> ()
1184+ %7 = mark_dependence %6 on %5
1185+ apply %7() : $@noescape @callee_owned () -> ()
1186+ destroy_value %5
1187+ %r = tuple ()
1188+ return %r : $()
1189+ }
1190+
11751191sil [ossa] @closure2 : $@convention(thin) (Int) -> ()
11761192
11771193sil [ossa] @yield1 : $@yield_once(Float) -> (@yields Float) {
You can’t perform that action at this time.
0 commit comments