Skip to content

Commit fbb1c0f

Browse files
authored
Merge pull request #62181 from nate-chandler/nfc/20221118/1
[SILDebugInfo] Small tweaks.
2 parents 45c3d47 + c4e3f41 commit fbb1c0f

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,8 +2127,14 @@ bool SILParser::parseSILLocation(SILLocation &Loc) {
21272127
if (parseInteger(Column, diag::sil_invalid_column_in_sil_location))
21282128
return true;
21292129

2130-
Loc = RegularLocation(SILLocation::FilenameAndLocation::alloc(Line, Column,
2131-
P.Context.getIdentifier(File).str().data(), SILMod));
2130+
auto fnl = SILLocation::FilenameAndLocation::alloc(Line, Column,
2131+
P.Context.getIdentifier(File).str().data(), SILMod);
2132+
2133+
Loc = RegularLocation(fnl);
2134+
2135+
if (*fnl == *SILLocation::getCompilerGeneratedLoc())
2136+
Loc.markAutoGenerated();
2137+
21322138
return false;
21332139
}
21342140

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ static llvm::cl::opt<bool> SkipConvertEscapeToNoescapeAttributes(
7979
// Allow unit tests to gradually migrate toward -allow-critical-edges=false.
8080
static 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

Comments
 (0)