Skip to content

Commit 329f03d

Browse files
authored
Merge pull request swiftlang#35558 from gottesmm/pr-8546814ec14114ba6e9d76c03a8ab15aabc4ad2b
[sil-optimizer] Compile in SIL verifiers when NDEBUG is enabled and enable them only when -sil-verify-all is enabled.
2 parents f7f658c + eb641f0 commit 329f03d

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5560,11 +5560,21 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
55605560
//===----------------------------------------------------------------------===//
55615561

55625562
static bool verificationEnabled(const SILModule &M) {
5563-
#ifdef NDEBUG
5564-
if (!M.getOptions().VerifyAll)
5563+
// If we are asked to never verify, return false early.
5564+
if (M.getOptions().VerifyNone)
55655565
return false;
5566+
5567+
// Otherwise, if verify all is set, we always verify.
5568+
if (M.getOptions().VerifyAll)
5569+
return true;
5570+
5571+
#ifndef NDEBUG
5572+
// Otherwise if we do have asserts enabled, always verify...
5573+
return true;
5574+
#else
5575+
// And if we don't never verify.
5576+
return false;
55665577
#endif
5567-
return !M.getOptions().VerifyNone;
55685578
}
55695579

55705580
/// verify - Run the SIL verifier to make sure that the SILFunction follows
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: not --crash %target-sil-opt -enable-sil-verify-all=true -sil-verify-all=true %s
2+
// RUN: %target-sil-opt -enable-sil-verify-all=false -sil-verify-all=false %s
3+
4+
// We only run this test without asserts.
5+
6+
// UNSUPPORTED: asserts
7+
8+
class Klass {}
9+
10+
sil [ossa] @leaky_code : $@convention(thin) () -> () {
11+
bb0:
12+
%0 = alloc_ref $Klass
13+
%9999 = tuple()
14+
return %9999 : $()
15+
}

0 commit comments

Comments
 (0)