Skip to content

Commit 60d0dd6

Browse files
committed
Allow InteriorLiveness be run without a dominator tree.
1 parent 3b737ca commit 60d0dd6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/SIL/Utils/OwnershipLiveness.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ struct InteriorLivenessVisitor :
8787
public OwnershipUseVisitor<InteriorLivenessVisitor> {
8888

8989
InteriorLiveness &interiorLiveness;
90+
91+
// If domInfo is nullptr, then InteriorLiveness never assumes dominance. As a
92+
// result it may report extra unenclosedPhis. In that case, any attempt to
93+
// create a new phi would result in an immediately redundant phi.
9094
const DominanceInfo *domInfo = nullptr;
9195

9296
/// handleInnerScopeCallback may add uses to the inner scope, but it may not
@@ -224,10 +228,14 @@ recursivelyVisitInnerGuaranteedPhi(PhiOperand phiOper, bool isReborrow) {
224228
// other enclosing defs do not have an outer adjacent reborrow.
225229
return true;
226230
})) {
231+
// TODO: instead of relying on Dominance, we can reformulate this algorithm
232+
// to detect redundant phis, similar to the SSAUpdater.
233+
//
227234
// At least one enclosing def is ownershipDef. If ownershipDef dominates
228235
// phiValue, then this is consistent with a well-formed linear lifetime, and
229236
// the phi's uses directly contribute to ownershipDef's liveness.
230-
if (domInfo->dominates(interiorLiveness.ownershipDef->getParentBlock(),
237+
if (domInfo &&
238+
domInfo->dominates(interiorLiveness.ownershipDef->getParentBlock(),
231239
phiValue->getParentBlock())) {
232240
if (isReborrow) {
233241
visitInnerBorrow(phiOper.getOperand());

0 commit comments

Comments
 (0)