@@ -569,13 +569,19 @@ bool SILValueOwnershipChecker::checkUses() {
569
569
// ===----------------------------------------------------------------------===//
570
570
571
571
void SILInstruction::verifyOperandOwnership () const {
572
- #ifndef NDEBUG
573
572
if (DisableOwnershipVerification)
574
573
return ;
575
574
576
575
if (isStaticInitializerInst ())
577
576
return ;
578
577
578
+ #ifdef NDEBUG
579
+ // When compiling without asserts enabled, only verify ownership if
580
+ // -sil-verify-all is set.
581
+ if (!getModule ().getOptions ().VerifyAll )
582
+ return ;
583
+ #endif
584
+
579
585
// If SILOwnership is not enabled, do not perform verification.
580
586
if (!getModule ().getOptions ().VerifySILOwnership )
581
587
return ;
@@ -631,14 +637,27 @@ void SILInstruction::verifyOperandOwnership() const {
631
637
" At this point, we are expected to assert" );
632
638
llvm_unreachable (" triggering standard assertion failure routine" );
633
639
}
634
- #endif
635
640
}
636
641
637
642
void SILValue::verifyOwnership (DeadEndBlocks *deadEndBlocks) const {
638
- #ifndef NDEBUG
639
643
if (DisableOwnershipVerification)
640
644
return ;
641
645
646
+ #ifdef NDEBUG
647
+ // When compiling without asserts enabled, only verify ownership if
648
+ // -sil-verify-all is set.
649
+ if (!getModule ().getOptions ().VerifyAll )
650
+ return ;
651
+ #endif
652
+
653
+ // Make sure that we are not a value of an instruction in a SILGlobalVariable
654
+ // block.
655
+ if (auto *definingInst = getDefiningInstruction ()) {
656
+ if (definingInst->isStaticInitializerInst ()) {
657
+ return ;
658
+ }
659
+ }
660
+
642
661
// Since we do not have SILUndef, we now know that getFunction() should return
643
662
// a real function. Assert in case this assumption is no longer true.
644
663
SILFunction *f = (*this )->getFunction ();
@@ -667,5 +686,4 @@ void SILValue::verifyOwnership(DeadEndBlocks *deadEndBlocks) const {
667
686
liveBlocks)
668
687
.check ();
669
688
}
670
- #endif
671
689
}
0 commit comments