@@ -490,16 +490,24 @@ void MemoryLifetimeVerifier::setBitsOfPredecessor(Bits &getSet, Bits &killSet,
490490
491491 TermInst *term = pred->getTerminator ();
492492 if (auto *tai = dyn_cast<TryApplyInst>(term)) {
493- // @out results of try_apply are only valid in the normal-block, but not in
494- // the throw-block.
495- if (tai->getNormalBB () != block)
496- return ;
497-
498493 FullApplySite FAS (tai);
499- for (Operand &op : tai->getAllOperands ()) {
500- if (FAS.isArgumentOperand (op) &&
501- FAS.getArgumentConvention (op) == SILArgumentConvention::Indirect_Out) {
502- locations.genBits (getSet, killSet, op.get ());
494+
495+ if (block == tai->getNormalBB ()) {
496+ // @out results of try_apply are only valid in the normal-block.
497+ for (Operand &op : tai->getAllOperands ()) {
498+ if (FAS.isArgumentOperand (op) &&
499+ FAS.isIndirectResultOperand (op)) {
500+ locations.genBits (getSet, killSet, op.get ());
501+ }
502+ }
503+ } else {
504+ // @error_indirect results of try_apply are only valid in the error-block.
505+ assert (block == tai->getErrorBB ());
506+ for (Operand &op : tai->getAllOperands ()) {
507+ if (FAS.isArgumentOperand (op) &&
508+ FAS.isIndirectErrorResultOperand (op)) {
509+ locations.genBits (getSet, killSet, op.get ());
510+ }
503511 }
504512 }
505513 } else if (auto *castInst = dyn_cast<CheckedCastAddrBranchInst>(term)) {
0 commit comments