Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/swift/SIL/PrunedLiveness.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ class PrunedLiveBlocks {
SmallVectorImpl<SILBasicBlock *> *discoveredBlocks = nullptr;

/// Only a clean bitfield can be initialized.
SWIFT_ASSERT_ONLY_DECL(bool cleanFlag = true);
bool cleanFlag = true;

/// Once the first def has been initialized, uses can be added.
SWIFT_ASSERT_ONLY_DECL(bool initializedFlag = false);
bool initializedFlag = false;

public:
PrunedLiveBlocks(SILFunction *function,
Expand Down
25 changes: 3 additions & 22 deletions include/swift/SIL/SILBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,6 @@ class SILBuilder {
/// are not auto-inserted.
SILBasicBlock *BB;
SILBasicBlock::iterator InsertPt;
#ifndef NDEBUG
/// Used in the di-hole verifier assertion.
/// \{
protected:
bool EnableDIHoleVerification = false;

private:
const SILDebugScope *PrevDebugScope = nullptr;
/// \}
#endif
const SILDebugScope *CurDebugScope = nullptr;
Optional<SILLocation> CurDebugLocOverride = None;

Expand All @@ -125,8 +115,7 @@ class SILBuilder {

SILBuilder(SILFunction &F, SmallVectorImpl<SILInstruction *> *InsertedInstrs)
: TempContext(F.getModule(), InsertedInstrs), C(TempContext), F(&F),
BB(nullptr) {
}
BB(nullptr) {}

explicit SILBuilder(SILInstruction *I,
SmallVectorImpl<SILInstruction *> *InsertedInstrs = 0)
Expand Down Expand Up @@ -233,7 +222,7 @@ class SILBuilder {
return getModule().Types.getTypeLowering(T, expansion);
}

void setCurrentDebugScope(const SILDebugScope *DS);
void setCurrentDebugScope(const SILDebugScope *DS) { CurDebugScope = DS; }
const SILDebugScope *getCurrentDebugScope() const { return CurDebugScope; }

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

/// clearInsertionPoint - Clear the insertion point: created instructions will
/// not be inserted into a block.
void clearInsertionPoint() {
#ifndef NDEBUG
PrevDebugScope = nullptr;
#endif
BB = nullptr;
}
void clearInsertionPoint() { BB = nullptr; }

/// setInsertionPoint - Set the insertion point.
void setInsertionPoint(SILBasicBlock *BB, SILBasicBlock::iterator insertPt) {
#ifndef NDEBUG
PrevDebugScope = nullptr;
#endif
this->BB = BB;
this->InsertPt = insertPt;
assert(insertPt == BB->end() || insertPt->getParent() == BB);
Expand Down
3 changes: 0 additions & 3 deletions include/swift/SIL/SILDebugScope.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ class SILDebugScope : public SILAllocated<SILDebugScope> {
/// into.
SILFunction *getParentFunction() const;

/// Determine whether other is an (indirect) parent of this scope.
bool isAncestor(const SILDebugScope *other) const;

/// If this is a debug scope associated with an inlined call site, return the
/// SILLocation associated with the call site resulting from the final
/// inlining.
Expand Down
19 changes: 0 additions & 19 deletions lib/SIL/IR/SILBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,6 @@ SILBuilder::SILBuilder(SILGlobalVariable *GlobVar,
setInsertionPoint(&GlobVar->StaticInitializerBlock);
}

void SILBuilder::setCurrentDebugScope(const SILDebugScope *DS) {
#ifndef NDEBUG
if (EnableDIHoleVerification && DS != CurDebugScope) {
// Detect a situation where:
// PrevDebugScope = sil_scope(parent: CurDebugScope)
// CurDebugScope = sil_scope(parent:)
// DS = PrevDebugScope
if (DS && DS == PrevDebugScope)
assert(!CurDebugScope->isAncestor(PrevDebugScope) &&
"attempting to re-enter scope within same basic block");
PrevDebugScope = CurDebugScope;
}
#endif
CurDebugScope = DS;
}

IntegerLiteralInst *SILBuilder::createIntegerLiteral(IntegerLiteralExpr *E) {
return insert(IntegerLiteralInst::create(E, getSILDebugLocation(E),
getModule()));
Expand Down Expand Up @@ -257,9 +241,6 @@ void SILBuilder::emitBlock(SILBasicBlock *BB, SILLocation BranchLoc) {
/// instruction) then split the block at that instruction and return the
/// continuation block.
SILBasicBlock *SILBuilder::splitBlockForFallthrough() {
#ifndef NDEBUG
PrevDebugScope = nullptr;
#endif
// If we are concatenating, just create and return a new block.
if (insertingAtEndOfBlock()) {
return getFunction().createBasicBlockAfter(BB);
Expand Down
11 changes: 0 additions & 11 deletions lib/SIL/IR/SILDebugScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@ SILDebugScope::SILDebugScope(SILLocation Loc, SILFunction *SILFn,
SILDebugScope::SILDebugScope(SILLocation Loc)
: Loc(Loc), InlinedCallSite(nullptr) {}

bool SILDebugScope::isAncestor(const SILDebugScope *other) const {
while (other) {
auto Parent = other->Parent;
auto *ParentScope = Parent.dyn_cast<const SILDebugScope *>();
if (ParentScope == this)
return true;
other = ParentScope;
}
return false;
}

SILFunction *SILDebugScope::getInlinedFunction() const {
if (Parent.isNull())
return nullptr;
Expand Down
17 changes: 16 additions & 1 deletion lib/SIL/Verifier/SILVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6272,7 +6272,22 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {

// Otherwise, we're allowed to re-enter a scope only if
// the scope is an ancestor of the scope we're currently leaving.
if (DS->isAncestor(LastSeenScope)) {
auto isAncestorScope = [](const SILDebugScope *Cur,
const SILDebugScope *Previous) {
assert(Cur && "null current scope queried");
assert(Previous && "null previous scope queried");
const SILDebugScope *Tmp = Previous;
while (Tmp) {
auto Parent = Tmp->Parent;
auto *ParentScope = Parent.dyn_cast<const SILDebugScope *>();
if (ParentScope == Cur)
return true;
Tmp = ParentScope;
}
return false;
};

if (isAncestorScope(DS, LastSeenScope)) {
LastSeenScope = DS;
LastSeenScopeInst = &SI;
continue;
Expand Down
20 changes: 3 additions & 17 deletions lib/SILGen/SILGenBuilder.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


//===--- SILGenBuilder.cpp ------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
Expand Down Expand Up @@ -38,27 +36,15 @@ SILGenModule &SILGenBuilder::getSILGenModule() const { return SGF.SGM; }
//===----------------------------------------------------------------------===//

SILGenBuilder::SILGenBuilder(SILGenFunction &SGF)
: SILBuilder(SGF.F), SGF(SGF) {
#ifndef NDEBUG
EnableDIHoleVerification = true;
#endif
}
: SILBuilder(SGF.F), SGF(SGF) {}

SILGenBuilder::SILGenBuilder(SILGenFunction &SGF, SILBasicBlock *insertBB,
SmallVectorImpl<SILInstruction *> *insertedInsts)
: SILBuilder(insertBB, insertedInsts), SGF(SGF) {
#ifndef NDEBUG
EnableDIHoleVerification = true;
#endif
}
: SILBuilder(insertBB, insertedInsts), SGF(SGF) {}

SILGenBuilder::SILGenBuilder(SILGenFunction &SGF, SILBasicBlock *insertBB,
SILBasicBlock::iterator insertInst)
: SILBuilder(insertBB, insertInst), SGF(SGF) {
#ifndef NDEBUG
EnableDIHoleVerification = true;
#endif
}
: SILBuilder(insertBB, insertInst), SGF(SGF) {}

//===----------------------------------------------------------------------===//
// Managed Value APIs
Expand Down
6 changes: 1 addition & 5 deletions lib/SILGen/SILGenBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ class SILGenBuilder : public SILBuilder {
SILGenBuilder(SILGenBuilder &builder, SILBasicBlock *insertBB)
: SILBuilder(insertBB, builder.getCurrentDebugScope(),
builder.getBuilderContext()),
SGF(builder.SGF) {
#ifndef NDEBUG
EnableDIHoleVerification = true;
#endif
}
SGF(builder.SGF) {}

SILGenModule &getSILGenModule() const;
SILGenFunction &getSILGenFunction() const { return SGF; }
Expand Down