@@ -5232,33 +5232,37 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
5232
5232
// Out of Line Verifier Run Functions
5233
5233
// ===----------------------------------------------------------------------===//
5234
5234
5235
+ static bool verificationEnabled (const SILModule &M) {
5236
+ #ifdef NDEBUG
5237
+ if (!M.getOptions ().VerifyAll )
5238
+ return false ;
5239
+ #endif
5240
+ return !M.getOptions ().VerifyNone ;
5241
+ }
5242
+
5235
5243
// / verify - Run the SIL verifier to make sure that the SILFunction follows
5236
5244
// / invariants.
5237
5245
void SILFunction::verify (bool SingleFunction) const {
5238
- #ifdef NDEBUG
5239
- if (!getModule ().getOptions ().VerifyAll )
5246
+ if (!verificationEnabled (getModule ()))
5240
5247
return ;
5241
- # endif
5248
+
5242
5249
// Please put all checks in visitSILFunction in SILVerifier, not here. This
5243
5250
// ensures that the pretty stack trace in the verifier is included with the
5244
5251
// back trace when the verifier crashes.
5245
5252
SILVerifier (*this , SingleFunction).verify ();
5246
5253
}
5247
5254
5248
5255
void SILFunction::verifyCriticalEdges () const {
5249
- #ifdef NDEBUG
5250
- if (!getModule ().getOptions ().VerifyAll )
5256
+ if (!verificationEnabled (getModule ()))
5251
5257
return ;
5252
- # endif
5258
+
5253
5259
SILVerifier (*this , /* SingleFunction=*/ true ).verifyBranches (this );
5254
5260
}
5255
5261
5256
5262
// / Verify that a property descriptor follows invariants.
5257
5263
void SILProperty::verify (const SILModule &M) const {
5258
- #ifdef NDEBUG
5259
- if (!M.getOptions ().VerifyAll )
5264
+ if (!verificationEnabled (M))
5260
5265
return ;
5261
- #endif
5262
5266
5263
5267
auto *decl = getDecl ();
5264
5268
auto *dc = decl->getInnermostDeclContext ();
@@ -5310,10 +5314,9 @@ void SILProperty::verify(const SILModule &M) const {
5310
5314
5311
5315
// / Verify that a vtable follows invariants.
5312
5316
void SILVTable::verify (const SILModule &M) const {
5313
- #ifdef NDEBUG
5314
- if (!M.getOptions ().VerifyAll )
5317
+ if (!verificationEnabled (M))
5315
5318
return ;
5316
- # endif
5319
+
5317
5320
for (auto &entry : getEntries ()) {
5318
5321
// All vtable entries must be decls in a class context.
5319
5322
assert (entry.Method .hasDecl () && " vtable entry is not a decl" );
@@ -5361,10 +5364,9 @@ void SILVTable::verify(const SILModule &M) const {
5361
5364
5362
5365
// / Verify that a witness table follows invariants.
5363
5366
void SILWitnessTable::verify (const SILModule &M) const {
5364
- #ifdef NDEBUG
5365
- if (!M.getOptions ().VerifyAll )
5367
+ if (!verificationEnabled (M))
5366
5368
return ;
5367
- # endif
5369
+
5368
5370
if (isDeclaration ())
5369
5371
assert (getEntries ().empty () &&
5370
5372
" A witness table declaration should not have any entries." );
@@ -5414,10 +5416,9 @@ void SILDefaultWitnessTable::verify(const SILModule &M) const {
5414
5416
5415
5417
// / Verify that a global variable follows invariants.
5416
5418
void SILGlobalVariable::verify () const {
5417
- #ifdef NDEBUG
5418
- if (!getModule ().getOptions ().VerifyAll )
5419
+ if (!verificationEnabled (getModule ()))
5419
5420
return ;
5420
- # endif
5421
+
5421
5422
assert (getLoweredType ().isObject ()
5422
5423
&& " global variable cannot have address type" );
5423
5424
@@ -5439,10 +5440,9 @@ void SILGlobalVariable::verify() const {
5439
5440
5440
5441
// / Verify the module.
5441
5442
void SILModule::verify () const {
5442
- #ifdef NDEBUG
5443
- if (!getOptions ().VerifyAll )
5443
+ if (!verificationEnabled (*this ))
5444
5444
return ;
5445
- # endif
5445
+
5446
5446
// Uniquing set to catch symbol name collisions.
5447
5447
llvm::DenseSet<StringRef> symbolNames;
5448
5448
0 commit comments