@@ -79,6 +79,7 @@ static llvm::cl::opt<bool> SkipConvertEscapeToNoescapeAttributes(
7979// Allow unit tests to gradually migrate toward -allow-critical-edges=false.
8080static llvm::cl::opt<bool > AllowCriticalEdges (" allow-critical-edges" ,
8181 llvm::cl::init (true ));
82+ extern llvm::cl::opt<bool > SILPrintDebugInfo;
8283
8384// The verifier is basically all assertions, so don't compile it with NDEBUG to
8485// prevent release builds from triggering spurious unused variable warnings.
@@ -5801,6 +5802,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
58015802 return ;
58025803
58035804 const SILDebugScope *LastSeenScope = nullptr ;
5805+ SILInstruction *LastSeenScopeInst = nullptr ;
58045806 for (SILInstruction &SI : *BB) {
58055807 if (SI.isMetaInstruction ())
58065808 continue ;
@@ -5814,21 +5816,20 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
58145816 if (!AlreadySeenScopes.count (DS)) {
58155817 AlreadySeenScopes.insert (DS);
58165818 LastSeenScope = DS;
5819+ LastSeenScopeInst = &SI;
58175820 continue ;
58185821 }
58195822
58205823 // Otherwise, we're allowed to re-enter a scope only if
58215824 // the scope is an ancestor of the scope we're currently leaving.
58225825 auto isAncestorScope = [](const SILDebugScope *Cur,
58235826 const SILDebugScope *Previous) {
5827+ assert (Cur && " null current scope queried" );
5828+ assert (Previous && " null previous scope queried" );
58245829 const SILDebugScope *Tmp = Previous;
5825- assert (Tmp && " scope can't be null" );
58265830 while (Tmp) {
5827- PointerUnion<const SILDebugScope *, SILFunction *> Parent =
5828- Tmp->Parent ;
5831+ auto Parent = Tmp->Parent ;
58295832 auto *ParentScope = Parent.dyn_cast <const SILDebugScope *>();
5830- if (!ParentScope)
5831- break ;
58325833 if (ParentScope == Cur)
58335834 return true ;
58345835 Tmp = ParentScope;
@@ -5838,13 +5839,24 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
58385839
58395840 if (isAncestorScope (DS, LastSeenScope)) {
58405841 LastSeenScope = DS;
5842+ LastSeenScopeInst = &SI;
58415843 continue ;
58425844 }
58435845 if (DS != LastSeenScope) {
5844- LLVM_DEBUG (llvm::dbgs () << " Broken instruction!\n " ; SI.dump ());
5845- LLVM_DEBUG (llvm::dbgs () << " Please report a bug on bugs.swift.org\n " );
5846- LLVM_DEBUG (llvm::dbgs () <<
5847- " Pass -Xllvm -verify-di-holes=false to disable the verification\n " );
5846+ llvm::errs () << " Broken instruction!\n " ;
5847+ SI.dump ();
5848+ llvm::errs () << " in scope\n " ;
5849+ DS->print (SI.getFunction ()->getModule ());
5850+ llvm::errs () << " Previous, non-contiguous scope set by" ;
5851+ LastSeenScopeInst->dump ();
5852+ llvm::errs () << " in scope\n " ;
5853+ LastSeenScope->print (SI.getFunction ()->getModule ());
5854+ llvm::errs () << " Please report a bug on bugs.swift.org\n " ;
5855+ llvm::errs () <<
5856+ " Pass -Xllvm -verify-di-holes=false to disable the verification\n " ;
5857+ // Turn on debug info printing so that the log actually shows the bad
5858+ // scopes.
5859+ SILPrintDebugInfo.setValue (true );
58485860 require (
58495861 DS == LastSeenScope,
58505862 " Basic block contains a non-contiguous lexical scope at -Onone" );
0 commit comments