@@ -1022,8 +1022,11 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
1022
1022
assert (F && " Expected value base with parent function" );
1023
1023
// If we do not have qualified ownership, then do not verify value base
1024
1024
// ownership.
1025
- if (!F->hasOwnership ())
1025
+ if (!F->hasOwnership ()) {
1026
+ require (SILValue (V).getOwnershipKind () == OwnershipKind::None,
1027
+ " Once ownership is gone, all values should have none ownership" );
1026
1028
return ;
1029
+ }
1027
1030
SILValue (V).verifyOwnership (&DEBlocks);
1028
1031
}
1029
1032
@@ -1100,14 +1103,36 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
1100
1103
" instruction's operand's owner isn't the instruction" );
1101
1104
require (isInValueUses (&operand), " operand value isn't used by operand" );
1102
1105
1103
- if (I-> isTypeDependentOperand ( operand)) {
1106
+ if (operand. isTypeDependent ( )) {
1104
1107
require (isa<SILInstruction>(I),
1105
1108
" opened archetype operand should refer to a SILInstruction" );
1106
1109
}
1107
1110
1108
1111
// Make sure that if operand is generic that its primary archetypes match
1109
1112
// the function context.
1110
1113
checkLegalType (I->getFunction (), operand.get (), I);
1114
+
1115
+ // If we are not in OSSA, our operand constraint should be invalid for a
1116
+ // type dependent operand (that is Optional::None) and if we have a non
1117
+ // type dependent operand then we should have a constraint of
1118
+ // OwnershipKind::Any, UseLifetimeConstraint::NonLifetimeEnding.
1119
+ if (!I->getFunction ()->hasOwnership ()) {
1120
+ if (operand.isTypeDependent ()) {
1121
+ require (
1122
+ !operand.getOwnershipConstraint (),
1123
+ " Non Optional::None constraint for a type dependent operand?!" );
1124
+ } else {
1125
+ auto constraint = operand.getOwnershipConstraint ();
1126
+ require (constraint.hasValue (),
1127
+ " All non-type dependent operands must have a "
1128
+ " non-Optional::None constraint?!" );
1129
+ require (constraint->getPreferredKind () == OwnershipKind::Any &&
1130
+ constraint->getLifetimeConstraint () ==
1131
+ UseLifetimeConstraint::NonLifetimeEnding,
1132
+ " In non-ossa all non-type dependent operands must have a "
1133
+ " constraint of Any, NonLifetimeEnding" );
1134
+ }
1135
+ }
1111
1136
}
1112
1137
1113
1138
// TODO: There should be a use of an opened archetype inside the instruction for
0 commit comments