diff --git a/include/swift/SIL/Dominance.h b/include/swift/SIL/Dominance.h index 0bab509af9d..091a9a60ac9 100644 --- a/include/swift/SIL/Dominance.h +++ b/include/swift/SIL/Dominance.h @@ -50,6 +50,11 @@ public: /// Does instruction A properly dominate instruction B? bool properlyDominates(SILInstruction *a, SILInstruction *b); + /// Does instruction A dominate instruction B? + bool dominates(SILInstruction *a, SILInstruction *b) { + return a == b || properlyDominates(a, b); + } + /// Does value A properly dominate instruction B? bool properlyDominates(SILValue a, SILInstruction *b); @@ -72,6 +77,7 @@ public: } using DominatorTreeBase::properlyDominates; + using DominatorTreeBase::dominates; bool isValid(SILFunction *F) const { return getNode(&F->front()) != nullptr; diff --git a/lib/SIL/SILBuilder.cpp b/lib/SIL/SILBuilder.cpp index 43f9a26b804..8dc3d5ba18a 100644 --- a/lib/SIL/SILBuilder.cpp +++ b/lib/SIL/SILBuilder.cpp @@ -417,8 +417,9 @@ void SILBuilder::addOpenedArchetypeOperands(SILInstruction *I) { while (I && I->getNumOperands() == 1 && I->getNumTypeDependentOperands() == 0) { - // All the open instructions are single-value instructions. - auto SVI = dyn_cast(I->getOperand(0)); + // All the open instructions are single-value instructions. Operands may + // be null when code is being transformed. + auto SVI = dyn_cast_or_null(I->getOperand(0)); // Within SimplifyCFG this function may be called for an instruction // within unreachable code. And within an unreachable block it can happen // that defs do not dominate uses (because there is no dominance defined).