Skip to content

Commit 0598957

Browse files
authored
Add a useful overload of properlyDominates to PostDominanceInfo (#34666)
1 parent 515dc39 commit 0598957

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

include/swift/SIL/Dominance.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class PostDominanceInfo : public PostDominatorTreeBase {
149149
PostDominanceInfo(SILFunction *F);
150150

151151
bool properlyDominates(SILInstruction *A, SILInstruction *B);
152+
bool properlyDominates(SILValue A, SILInstruction *B);
152153

153154
void verify() const;
154155

lib/SIL/Utils/Dominance.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ properlyDominates(SILInstruction *I1, SILInstruction *I2) {
114114
return true;
115115
}
116116

117+
bool PostDominanceInfo::properlyDominates(SILValue A, SILInstruction *B) {
118+
if (auto *Inst = A->getDefiningInstruction()) {
119+
return properlyDominates(Inst, B);
120+
}
121+
if (auto *Arg = dyn_cast<SILArgument>(A)) {
122+
return dominates(Arg->getParent(), B->getParent());
123+
}
124+
return false;
125+
}
126+
117127
void PostDominanceInfo::verify() const {
118128
// Recompute.
119129
//

0 commit comments

Comments
 (0)