Skip to content

Commit 391762f

Browse files
committed
[sil] Tighten up SIL verification around when checked_cast_br should/shouldn't have failure arguments.
checked_cast_br in ownership SIL funnels through the original value to the failure block as a SILArgument for cleanup purposes. In contrast, when SIL is not in ossa, we do not want the failure bb case to have any arguments since that is the pattern that SILOptimizer passes expect. This commit just formalizes these constraints into the SILVerifier to catch mistakes.
1 parent f1327be commit 391762f

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/SIL/SILVerifier.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3381,20 +3381,17 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
33813381
CBI->getCastType(),
33823382
"success dest block argument of checked_cast_br must match type of "
33833383
"cast");
3384-
require(F.hasOwnership() || CBI->getFailureBB()->args_empty(),
3385-
"failure dest of checked_cast_br in unqualified ownership sil must "
3386-
"take no arguments");
3387-
#if 0
3388-
require(F.hasUnqualifiedOwnership() ||
3389-
CBI->getFailureBB()->args_size() == 1,
3384+
require(!F.hasOwnership() || CBI->getFailureBB()->args_size() == 1,
33903385
"failure dest of checked_cast_br must take one argument in "
33913386
"ownership qualified sil");
3392-
require(F.hasUnqualifiedOwnership() ||
3387+
require(!F.hasOwnership() ||
33933388
CBI->getFailureBB()->args_begin()[0]->getType() ==
33943389
CBI->getOperand()->getType(),
33953390
"failure dest block argument must match type of original type in "
33963391
"ownership qualified sil");
3397-
#endif
3392+
require(F.hasOwnership() || CBI->getFailureBB()->args_empty(),
3393+
"Failure dest of checked_cast_br must not take any argument in "
3394+
"non-ownership qualified sil");
33983395
}
33993396

34003397
void checkCheckedCastValueBranchInst(CheckedCastValueBranchInst *CBI) {

0 commit comments

Comments
 (0)