Skip to content

Commit 21701ac

Browse files
Merge pull request #64584 from apple/revert-64494-dihole-assertion
Revert "Add a verify-di-hole assertion to SILBuilder."
2 parents af5d611 + 4ea51cf commit 21701ac

File tree

7 files changed

+23
-78
lines changed

7 files changed

+23
-78
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,6 @@ class SILBuilder {
106106
/// are not auto-inserted.
107107
SILBasicBlock *BB;
108108
SILBasicBlock::iterator InsertPt;
109-
#ifndef NDEBUG
110-
/// Used in the di-hole verifier assertion.
111-
/// \{
112-
protected:
113-
bool EnableDIHoleVerification = false;
114-
115-
private:
116-
const SILDebugScope *PrevDebugScope = nullptr;
117-
/// \}
118-
#endif
119109
const SILDebugScope *CurDebugScope = nullptr;
120110
Optional<SILLocation> CurDebugLocOverride = None;
121111

@@ -125,8 +115,7 @@ class SILBuilder {
125115

126116
SILBuilder(SILFunction &F, SmallVectorImpl<SILInstruction *> *InsertedInstrs)
127117
: TempContext(F.getModule(), InsertedInstrs), C(TempContext), F(&F),
128-
BB(nullptr) {
129-
}
118+
BB(nullptr) {}
130119

131120
explicit SILBuilder(SILInstruction *I,
132121
SmallVectorImpl<SILInstruction *> *InsertedInstrs = 0)
@@ -233,7 +222,7 @@ class SILBuilder {
233222
return getModule().Types.getTypeLowering(T, expansion);
234223
}
235224

236-
void setCurrentDebugScope(const SILDebugScope *DS);
225+
void setCurrentDebugScope(const SILDebugScope *DS) { CurDebugScope = DS; }
237226
const SILDebugScope *getCurrentDebugScope() const { return CurDebugScope; }
238227

239228
/// Apply a debug location override. If loc is None, the current override is
@@ -290,18 +279,10 @@ class SILBuilder {
290279

291280
/// clearInsertionPoint - Clear the insertion point: created instructions will
292281
/// not be inserted into a block.
293-
void clearInsertionPoint() {
294-
#ifndef NDEBUG
295-
PrevDebugScope = nullptr;
296-
#endif
297-
BB = nullptr;
298-
}
282+
void clearInsertionPoint() { BB = nullptr; }
299283

300284
/// setInsertionPoint - Set the insertion point.
301285
void setInsertionPoint(SILBasicBlock *BB, SILBasicBlock::iterator insertPt) {
302-
#ifndef NDEBUG
303-
PrevDebugScope = nullptr;
304-
#endif
305286
this->BB = BB;
306287
this->InsertPt = insertPt;
307288
assert(insertPt == BB->end() || insertPt->getParent() == BB);

include/swift/SIL/SILDebugScope.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ class SILDebugScope : public SILAllocated<SILDebugScope> {
6666
/// into.
6767
SILFunction *getParentFunction() const;
6868

69-
/// Determine whether other is an (indirect) parent of this scope.
70-
bool isAncestor(const SILDebugScope *other) const;
71-
7269
/// If this is a debug scope associated with an inlined call site, return the
7370
/// SILLocation associated with the call site resulting from the final
7471
/// inlining.

lib/SIL/IR/SILBuilder.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,6 @@ SILBuilder::SILBuilder(SILGlobalVariable *GlobVar,
2828
setInsertionPoint(&GlobVar->StaticInitializerBlock);
2929
}
3030

31-
void SILBuilder::setCurrentDebugScope(const SILDebugScope *DS) {
32-
#ifndef NDEBUG
33-
if (EnableDIHoleVerification && DS != CurDebugScope) {
34-
// Detect a situation where:
35-
// PrevDebugScope = sil_scope(parent: CurDebugScope)
36-
// CurDebugScope = sil_scope(parent:)
37-
// DS = PrevDebugScope
38-
if (DS && DS == PrevDebugScope)
39-
assert(!CurDebugScope->isAncestor(PrevDebugScope) &&
40-
"attempting to re-enter scope within same basic block");
41-
PrevDebugScope = CurDebugScope;
42-
}
43-
#endif
44-
CurDebugScope = DS;
45-
}
46-
4731
IntegerLiteralInst *SILBuilder::createIntegerLiteral(IntegerLiteralExpr *E) {
4832
return insert(IntegerLiteralInst::create(E, getSILDebugLocation(E),
4933
getModule()));
@@ -257,9 +241,6 @@ void SILBuilder::emitBlock(SILBasicBlock *BB, SILLocation BranchLoc) {
257241
/// instruction) then split the block at that instruction and return the
258242
/// continuation block.
259243
SILBasicBlock *SILBuilder::splitBlockForFallthrough() {
260-
#ifndef NDEBUG
261-
PrevDebugScope = nullptr;
262-
#endif
263244
// If we are concatenating, just create and return a new block.
264245
if (insertingAtEndOfBlock()) {
265246
return getFunction().createBasicBlockAfter(BB);

lib/SIL/IR/SILDebugScope.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,6 @@ SILDebugScope::SILDebugScope(SILLocation Loc, SILFunction *SILFn,
3737
SILDebugScope::SILDebugScope(SILLocation Loc)
3838
: Loc(Loc), InlinedCallSite(nullptr) {}
3939

40-
bool SILDebugScope::isAncestor(const SILDebugScope *other) const {
41-
while (other) {
42-
auto Parent = other->Parent;
43-
auto *ParentScope = Parent.dyn_cast<const SILDebugScope *>();
44-
if (ParentScope == this)
45-
return true;
46-
other = ParentScope;
47-
}
48-
return false;
49-
}
50-
5140
SILFunction *SILDebugScope::getInlinedFunction() const {
5241
if (Parent.isNull())
5342
return nullptr;

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6272,7 +6272,22 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
62726272

62736273
// Otherwise, we're allowed to re-enter a scope only if
62746274
// the scope is an ancestor of the scope we're currently leaving.
6275-
if (DS->isAncestor(LastSeenScope)) {
6275+
auto isAncestorScope = [](const SILDebugScope *Cur,
6276+
const SILDebugScope *Previous) {
6277+
assert(Cur && "null current scope queried");
6278+
assert(Previous && "null previous scope queried");
6279+
const SILDebugScope *Tmp = Previous;
6280+
while (Tmp) {
6281+
auto Parent = Tmp->Parent;
6282+
auto *ParentScope = Parent.dyn_cast<const SILDebugScope *>();
6283+
if (ParentScope == Cur)
6284+
return true;
6285+
Tmp = ParentScope;
6286+
}
6287+
return false;
6288+
};
6289+
6290+
if (isAncestorScope(DS, LastSeenScope)) {
62766291
LastSeenScope = DS;
62776292
LastSeenScopeInst = &SI;
62786293
continue;

lib/SILGen/SILGenBuilder.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
//===--- SILGenBuilder.cpp ------------------------------------------------===//
42
//
53
// This source file is part of the Swift.org open source project
@@ -38,27 +36,15 @@ SILGenModule &SILGenBuilder::getSILGenModule() const { return SGF.SGM; }
3836
//===----------------------------------------------------------------------===//
3937

4038
SILGenBuilder::SILGenBuilder(SILGenFunction &SGF)
41-
: SILBuilder(SGF.F), SGF(SGF) {
42-
#ifndef NDEBUG
43-
EnableDIHoleVerification = true;
44-
#endif
45-
}
39+
: SILBuilder(SGF.F), SGF(SGF) {}
4640

4741
SILGenBuilder::SILGenBuilder(SILGenFunction &SGF, SILBasicBlock *insertBB,
4842
SmallVectorImpl<SILInstruction *> *insertedInsts)
49-
: SILBuilder(insertBB, insertedInsts), SGF(SGF) {
50-
#ifndef NDEBUG
51-
EnableDIHoleVerification = true;
52-
#endif
53-
}
43+
: SILBuilder(insertBB, insertedInsts), SGF(SGF) {}
5444

5545
SILGenBuilder::SILGenBuilder(SILGenFunction &SGF, SILBasicBlock *insertBB,
5646
SILBasicBlock::iterator insertInst)
57-
: SILBuilder(insertBB, insertInst), SGF(SGF) {
58-
#ifndef NDEBUG
59-
EnableDIHoleVerification = true;
60-
#endif
61-
}
47+
: SILBuilder(insertBB, insertInst), SGF(SGF) {}
6248

6349
//===----------------------------------------------------------------------===//
6450
// Managed Value APIs

lib/SILGen/SILGenBuilder.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@ class SILGenBuilder : public SILBuilder {
5555
SILGenBuilder(SILGenBuilder &builder, SILBasicBlock *insertBB)
5656
: SILBuilder(insertBB, builder.getCurrentDebugScope(),
5757
builder.getBuilderContext()),
58-
SGF(builder.SGF) {
59-
#ifndef NDEBUG
60-
EnableDIHoleVerification = true;
61-
#endif
62-
}
58+
SGF(builder.SGF) {}
6359

6460
SILGenModule &getSILGenModule() const;
6561
SILGenFunction &getSILGenFunction() const { return SGF; }

0 commit comments

Comments
 (0)