@@ -79,6 +79,7 @@ static llvm::cl::opt<bool> SkipConvertEscapeToNoescapeAttributes(
79
79
// Allow unit tests to gradually migrate toward -allow-critical-edges=false.
80
80
static llvm::cl::opt<bool > AllowCriticalEdges (" allow-critical-edges" ,
81
81
llvm::cl::init (true ));
82
+ extern llvm::cl::opt<bool > SILPrintDebugInfo;
82
83
83
84
// The verifier is basically all assertions, so don't compile it with NDEBUG to
84
85
// prevent release builds from triggering spurious unused variable warnings.
@@ -5801,6 +5802,7 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
5801
5802
return ;
5802
5803
5803
5804
const SILDebugScope *LastSeenScope = nullptr ;
5805
+ SILInstruction *LastSeenScopeInst = nullptr ;
5804
5806
for (SILInstruction &SI : *BB) {
5805
5807
if (SI.isMetaInstruction ())
5806
5808
continue ;
@@ -5814,21 +5816,20 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
5814
5816
if (!AlreadySeenScopes.count (DS)) {
5815
5817
AlreadySeenScopes.insert (DS);
5816
5818
LastSeenScope = DS;
5819
+ LastSeenScopeInst = &SI;
5817
5820
continue ;
5818
5821
}
5819
5822
5820
5823
// Otherwise, we're allowed to re-enter a scope only if
5821
5824
// the scope is an ancestor of the scope we're currently leaving.
5822
5825
auto isAncestorScope = [](const SILDebugScope *Cur,
5823
5826
const SILDebugScope *Previous) {
5827
+ assert (Cur && " null current scope queried" );
5828
+ assert (Previous && " null previous scope queried" );
5824
5829
const SILDebugScope *Tmp = Previous;
5825
- assert (Tmp && " scope can't be null" );
5826
5830
while (Tmp) {
5827
- PointerUnion<const SILDebugScope *, SILFunction *> Parent =
5828
- Tmp->Parent ;
5831
+ auto Parent = Tmp->Parent ;
5829
5832
auto *ParentScope = Parent.dyn_cast <const SILDebugScope *>();
5830
- if (!ParentScope)
5831
- break ;
5832
5833
if (ParentScope == Cur)
5833
5834
return true ;
5834
5835
Tmp = ParentScope;
@@ -5838,13 +5839,24 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
5838
5839
5839
5840
if (isAncestorScope (DS, LastSeenScope)) {
5840
5841
LastSeenScope = DS;
5842
+ LastSeenScopeInst = &SI;
5841
5843
continue ;
5842
5844
}
5843
5845
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 );
5848
5860
require (
5849
5861
DS == LastSeenScope,
5850
5862
" Basic block contains a non-contiguous lexical scope at -Onone" );
0 commit comments