File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -253,8 +253,12 @@ static void fixupReferenceCounts(
253
253
}
254
254
255
255
static SILValue cleanupLoadedCalleeValue (SILValue calleeValue, LoadInst *li) {
256
- auto *pbi = cast<ProjectBoxInst>(li->getOperand ());
257
- auto *abi = cast<AllocBoxInst>(pbi->getOperand ());
256
+ auto *pbi = dyn_cast<ProjectBoxInst>(li->getOperand ());
257
+ if (!pbi)
258
+ return SILValue ();
259
+ auto *abi = dyn_cast<AllocBoxInst>(pbi->getOperand ());
260
+ if (!abi)
261
+ return SILValue ();
258
262
259
263
// The load instruction must have no more uses or a single destroy left to
260
264
// erase it.
Original file line number Diff line number Diff line change @@ -1401,3 +1401,30 @@ bb6:
1401
1401
%tuple = tuple()
1402
1402
return %tuple : $()
1403
1403
}
1404
+
1405
+ sil [transparent] @escaping_thunk : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> () {
1406
+ bb0(%1 : $@callee_guaranteed () -> ()):
1407
+ %9999 = tuple()
1408
+ return %9999 : $()
1409
+ }
1410
+
1411
+ // Make sure that we do not crash here.
1412
+ //
1413
+ // CHECK-LABEL: sil @partial_apply_stack_failure : $@convention(thin) (@callee_guaranteed () -> ()) -> () {
1414
+ // CHECK: } // end sil function 'partial_apply_stack_failure'
1415
+ sil @partial_apply_stack_failure : $@convention(thin) (@callee_guaranteed () -> ()) -> () {
1416
+ bb0(%0 : $@callee_guaranteed () -> ()):
1417
+ %1 = alloc_stack $@callee_guaranteed () -> ()
1418
+ store %0 to %1 : $*@callee_guaranteed () -> ()
1419
+ %2 = load %1 : $*@callee_guaranteed () -> ()
1420
+ strong_retain %2 : $@callee_guaranteed () -> ()
1421
+ %thunk = function_ref @escaping_thunk : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
1422
+ %2a = partial_apply [callee_guaranteed] [on_stack] %thunk(%2) : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
1423
+ %2b = mark_dependence %2a : $@noescape @callee_guaranteed () -> () on %2 : $@callee_guaranteed () -> ()
1424
+ apply %2b() : $@noescape @callee_guaranteed () -> ()
1425
+ dealloc_stack %2a : $@noescape @callee_guaranteed () -> ()
1426
+ destroy_addr %1 : $*@callee_guaranteed () -> ()
1427
+ dealloc_stack %1 : $*@callee_guaranteed () -> ()
1428
+ %9999 = tuple()
1429
+ return %9999 : $()
1430
+ }
You can’t perform that action at this time.
0 commit comments