Skip to content

Commit 98992df

Browse files
committed
[SILVerifier] Add a flag to exit instead of aborting on failure.
This matches what LLVM does, and makes testing/fuzzing easier. It's also slightly more friendly in case the user violates an assumption. It can't be turned on by default (yet) because it's important to crash on verification failures, when running swiftc in a debugger.
1 parent abb6156 commit 98992df

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/SIL/SILVerifier.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ static llvm::cl::opt<bool> SkipUnreachableMustBeLastErrors(
5050
"verify-skip-unreachable-must-be-last",
5151
llvm::cl::init(false));
5252

53+
// This flag controls the default behaviour when hitting a verification
54+
// failure (abort/exit).
55+
static llvm::cl::opt<bool> AbortOnFailure(
56+
"verify-abort-on-failure",
57+
llvm::cl::init(true));
58+
5359
// The verifier is basically all assertions, so don't compile it with NDEBUG to
5460
// prevent release builds from triggering spurious unused variable warnings.
5561

@@ -139,7 +145,12 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
139145
F.print(llvm::dbgs());
140146
}
141147

142-
abort();
148+
// We abort by default because we want to always crash in
149+
// the debugger.
150+
if (AbortOnFailure)
151+
abort();
152+
else
153+
exit(1);
143154
}
144155
#define require(condition, complaint) \
145156
_require(bool(condition), complaint ": " #condition)

0 commit comments

Comments
 (0)