Skip to content

Commit b0e947b

Browse files
committed
[ownership] Emit a PrettyStackTrace msg telling to re-run with -sil-verify-all if we hit a verifier error before ownership lowering.
We have been getting a bunch of different bugs reported that were initially identified as being caused by the ownership model eliminator (due to this verification failure), but that turned out in reality to be a different failure. To ease triaging, this commit puts in a pretty stack trace msg that tells the person doing the triaging to re-run with -sil-verify-all enabled to track down the actual pass that introduces the verification failure.
1 parent 3afbe31 commit b0e947b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lib/SILOptimizer/Transforms/OwnershipModelEliminator.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,25 @@ struct OwnershipModelEliminator : SILModuleTransform {
383383
continue;
384384

385385
// Verify here to make sure ownership is correct before we strip.
386-
F.verify();
386+
{
387+
// Add a pretty stack trace entry to tell users who see a verification
388+
// failure triggered by this verification check that they need to re-run
389+
// with -sil-verify-all to actually find the pass that introduced the
390+
// verification error.
391+
//
392+
// DISCUSSION: This occurs due to the crash from the verification
393+
// failure happening in the pass itself. This causes us to dump the
394+
// SILFunction and emit a msg that this pass (OME) is the culprit. This
395+
// is generally correct for most passes, but not for OME since we are
396+
// verifying before we have even modified the function to ensure that
397+
// all ownership invariants have been respected before we lower
398+
// ownership from the function.
399+
llvm::PrettyStackTraceString silVerifyAllMsgOnFailure(
400+
"Found verification error when verifying before lowering "
401+
"ownership. Please re-run with -sil-verify-all to identify the "
402+
"actual pass that introduced the verification error.");
403+
F.verify();
404+
}
387405

388406
if (stripOwnership(F)) {
389407
auto InvalidKind =

0 commit comments

Comments
 (0)