Skip to content

Commit 861216c

Browse files
committed
Add release diagnostics for partial_apply [on_stack] uses.
1 parent a4070e6 commit 861216c

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

lib/SIL/IR/SILInstruction.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,8 +1788,23 @@ static bool visitRecursivelyLifetimeEndingUses(
17881788

17891789
// There shouldn't be any dead-end consumptions of a nonescaping
17901790
// partial_apply that don't forward it along, aside from destroy_value.
1791-
assert(use->getUser()->hasResults()
1792-
&& use->getUser()->getNumResults() == 1);
1791+
//
1792+
// On-stack partial_apply cannot be cloned, so it should never be used by a
1793+
// BranchInst.
1794+
//
1795+
// This is a fatal error because it performs SIL verification that is not
1796+
// separately checked in the verifier. It is the only check that verifies
1797+
// the structural requirements of on-stack partial_apply uses.
1798+
auto *user = use->getUser();
1799+
if (user->getNumResults() != 1) {
1800+
llvm::errs() << "partial_apply [on_stack] use:\n";
1801+
user->printInContext(llvm::errs());
1802+
if (isa<BranchInst>(user)) {
1803+
llvm::report_fatal_error("partial_apply [on_stack] cannot be cloned");
1804+
}
1805+
llvm::report_fatal_error("partial_apply [on_stack] must be directly "
1806+
"forwarded to a destroy_value");
1807+
}
17931808
if (!visitRecursivelyLifetimeEndingUses(use->getUser()->getResult(0),
17941809
noUsers, func)) {
17951810
return false;

0 commit comments

Comments
 (0)