@@ -802,15 +802,24 @@ bool SILValueOwnershipChecker::checkUses() {
802
802
return true ;
803
803
}
804
804
805
+ bool disableOwnershipVerification (const SILModule &mod) {
806
+ if (DisableOwnershipVerification)
807
+ return true ;
808
+ if (mod.getASTContext ().blockListConfig .hasBlockListAction (
809
+ mod.getSwiftModule ()->getRealName ().str (),
810
+ BlockListKeyKind::ModuleName,
811
+ BlockListAction::ShouldDisableOwnershipVerification)) {
812
+ return true ;
813
+ }
814
+ return false ;
815
+ }
816
+
805
817
// ===----------------------------------------------------------------------===//
806
818
// Top Level Entrypoints
807
819
// ===----------------------------------------------------------------------===//
808
820
809
821
void SILInstruction::verifyOperandOwnership (
810
822
SILModuleConventions *silConv) const {
811
- if (DisableOwnershipVerification)
812
- return ;
813
-
814
823
if (isStaticInitializerInst ())
815
824
return ;
816
825
@@ -831,11 +840,13 @@ void SILInstruction::verifyOperandOwnership(
831
840
!getFunction ()->shouldVerifyOwnership ())
832
841
return ;
833
842
843
+ if (disableOwnershipVerification (getModule ()))
844
+ return ;
845
+
834
846
// If we are testing the verifier, bail so we only print errors once when
835
847
// performing a full verification, instead of additionally in the SILBuilder.
836
848
if (IsSILOwnershipVerifierTestingEnabled)
837
849
return ;
838
-
839
850
// If this is a terminator instruction, do not verify in SILBuilder. This is
840
851
// because when building a new function, one must create the destination block
841
852
// first which is an unnatural pattern and pretty brittle.
@@ -903,9 +914,6 @@ verifySILValueHelper(const SILFunction *f, SILValue value,
903
914
}
904
915
905
916
void SILValue::verifyOwnership (DeadEndBlocks *deadEndBlocks) const {
906
- if (DisableOwnershipVerification)
907
- return ;
908
-
909
917
// Do not validate SILUndef values.
910
918
if (isa<SILUndef>(*this ))
911
919
return ;
@@ -931,18 +939,21 @@ void SILValue::verifyOwnership(DeadEndBlocks *deadEndBlocks) const {
931
939
}
932
940
}
933
941
942
+ // Since we do not have SILUndef, we now know that getFunction() should return
943
+ // a real function. Assert in case this assumption is no longer true.
944
+ auto *f = (*this )->getFunction ();
945
+ assert (f && " Instructions and arguments should have a function" );
946
+
947
+ if (disableOwnershipVerification (f->getModule ()))
948
+ return ;
949
+
934
950
// If we are testing the verifier, bail so we only print errors once when
935
951
// performing a full verification a function at a time by the
936
952
// OwnershipVerifierStateDumper pass, instead of additionally in the
937
953
// SILBuilder and in the actual SIL verifier that may be run by sil-opt.
938
954
if (IsSILOwnershipVerifierTestingEnabled)
939
955
return ;
940
956
941
- // Since we do not have SILUndef, we now know that getFunction() should return
942
- // a real function. Assert in case this assumption is no longer true.
943
- auto *f = (*this )->getFunction ();
944
- assert (f && " Instructions and arguments should have a function" );
945
-
946
957
using BehaviorKind = LinearLifetimeChecker::ErrorBehaviorKind;
947
958
LinearLifetimeChecker::ErrorBuilder errorBuilder (
948
959
*f, BehaviorKind::PrintMessageAndAssert);
@@ -952,7 +963,7 @@ void SILValue::verifyOwnership(DeadEndBlocks *deadEndBlocks) const {
952
963
}
953
964
954
965
void SILModule::verifyOwnership () const {
955
- if (DisableOwnershipVerification )
966
+ if (disableOwnershipVerification (* this ) )
956
967
return ;
957
968
958
969
#ifdef NDEBUG
@@ -973,8 +984,6 @@ void SILModule::verifyOwnership() const {
973
984
}
974
985
975
986
void SILFunction::verifyOwnership (DeadEndBlocks *deadEndBlocks) const {
976
- if (DisableOwnershipVerification)
977
- return ;
978
987
if (!getModule ().getOptions ().VerifySILOwnership )
979
988
return ;
980
989
@@ -996,6 +1005,9 @@ void SILFunction::verifyOwnership(DeadEndBlocks *deadEndBlocks) const {
996
1005
if (!hasOwnership () || !shouldVerifyOwnership ())
997
1006
return ;
998
1007
1008
+ if (disableOwnershipVerification (getModule ()))
1009
+ return ;
1010
+
999
1011
using BehaviorKind = LinearLifetimeChecker::ErrorBehaviorKind;
1000
1012
unsigned errorCounter = 0 ;
1001
1013
std::optional<LinearLifetimeChecker::ErrorBuilder> errorBuilder;
0 commit comments