@@ -84,8 +84,7 @@ class LiveRange {
84
84
// / Semantically this implies that a value is never passed off as +1 to memory
85
85
// / or another function implying it can be used everywhere at +0.
86
86
HasConsumingUse_t
87
- hasConsumingUse (FrozenMultiMap<SILPhiArgument *, OwnedValueIntroducer>
88
- *phiToIncomingValueMultiMap = nullptr ) const ;
87
+ hasUnknownConsumingUse (bool assumingFixedPoint = false ) const ;
89
88
90
89
ArrayRef<Operand *> getDestroyingUses () const { return destroyingUses; }
91
90
@@ -440,9 +439,8 @@ void LiveRange::convertArgToGuaranteed(DeadEndBlocks &deadEndBlocks,
440
439
convertOwnedGeneralForwardingUsesToGuaranteed ();
441
440
}
442
441
443
- LiveRange::HasConsumingUse_t LiveRange::hasConsumingUse (
444
- FrozenMultiMap<SILPhiArgument *, OwnedValueIntroducer>
445
- *phiToIncomingValueMultiMap) const {
442
+ LiveRange::HasConsumingUse_t
443
+ LiveRange::hasUnknownConsumingUse (bool assumingAtFixPoint) const {
446
444
// First do a quick check if we have /any/ unknown consuming
447
445
// uses. If we do not have any, return false early.
448
446
if (unknownConsumingUses.empty ()) {
@@ -451,7 +449,7 @@ LiveRange::HasConsumingUse_t LiveRange::hasConsumingUse(
451
449
452
450
// Ok, we do have some unknown consuming uses. If we aren't asked to
453
451
// update phiToIncomingValueMultiMap, then just return true quickly.
454
- if (!phiToIncomingValueMultiMap ) {
452
+ if (!assumingAtFixPoint ) {
455
453
return HasConsumingUse_t::Yes;
456
454
}
457
455
@@ -832,7 +830,6 @@ static bool canEliminatePhi(
832
830
if (!introducer.isConvertableToGuaranteed ()) {
833
831
return false ;
834
832
}
835
-
836
833
// If this linear search is too slow, we can change the
837
834
// multimap to sort the mapped to list by pointer
838
835
// instead of insertion order. In such a case, we could
@@ -874,17 +871,17 @@ bool SemanticARCOptVisitor::performPostPeepholeOwnedArgElimination() {
874
871
// First compute the LiveRange for our phi argument. For simplicity, we only
875
872
// handle cases now where our phi argument does not have any phi unknown
876
873
// consumers.
877
- SILPhiArgument *phiArg = pair.first ;
878
- LiveRange phiArgLiveRange (phiArg );
879
- if (bool (phiArgLiveRange. hasConsumingUse ())) {
874
+ SILPhiArgument *phi = pair.first ;
875
+ LiveRange phiLiveRange (phi );
876
+ if (bool (phiLiveRange. hasUnknownConsumingUse ())) {
880
877
continue ;
881
878
}
882
879
883
880
// Ok, we know that our phi argument /could/ be converted to guaranteed if
884
881
// our incoming values are able to be converted to guaranteed. Now for each
885
882
// incoming value, compute the incoming values ownership roots and see if
886
883
// all of the ownership roots are in our owned incoming value array.
887
- if (!phiArg ->getIncomingPhiOperands (incomingValueOperandList)) {
884
+ if (!phi ->getIncomingPhiOperands (incomingValueOperandList)) {
888
885
continue ;
889
886
}
890
887
@@ -907,7 +904,7 @@ bool SemanticARCOptVisitor::performPostPeepholeOwnedArgElimination() {
907
904
for (Operand *incomingValueOperand : incomingValueOperandList) {
908
905
originalIncomingValues.push_back (incomingValueOperand->get ());
909
906
SILType type = incomingValueOperand->get ()->getType ();
910
- auto *undef = SILUndef::get (type, *phiArg ->getFunction ());
907
+ auto *undef = SILUndef::get (type, *phi ->getFunction ());
911
908
incomingValueOperand->set (undef);
912
909
}
913
910
@@ -960,7 +957,7 @@ bool SemanticARCOptVisitor::performPostPeepholeOwnedArgElimination() {
960
957
}
961
958
962
959
// Then convert the phi's live range to be guaranteed.
963
- std::move (phiArgLiveRange )
960
+ std::move (phiLiveRange )
964
961
.convertArgToGuaranteed (getDeadEndBlocks (), lifetimeFrontier,
965
962
getCallbacks ());
966
963
@@ -984,7 +981,7 @@ bool SemanticARCOptVisitor::performPostPeepholeOwnedArgElimination() {
984
981
985
982
madeChange = true ;
986
983
if (VerifyAfterTransform) {
987
- phiArg ->getFunction ()->verify ();
984
+ phi ->getFunction ()->verify ();
988
985
}
989
986
}
990
987
@@ -1179,9 +1176,9 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(CopyValueInst
1179
1176
// forwarding or a user that truly represents a necessary consume of the value
1180
1177
// (e.x. storing into memory).
1181
1178
LiveRange lr (cvi);
1182
- auto hasConsumingUseState =
1183
- lr.hasConsumingUse (getPhiToIncomingValueMultiMap ());
1184
- if (hasConsumingUseState == LiveRange::HasConsumingUse_t::Yes) {
1179
+ auto hasUnknownConsumingUseState =
1180
+ lr.hasUnknownConsumingUse (getPhiToIncomingValueMultiMap ());
1181
+ if (hasUnknownConsumingUseState == LiveRange::HasConsumingUse_t::Yes) {
1185
1182
return false ;
1186
1183
}
1187
1184
@@ -1290,7 +1287,8 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(CopyValueInst
1290
1287
// was consumed, the hasConsumedUse code updated phiToIncomingValueMultiMap
1291
1288
// for us before returning its prognosis. After we reach a fixed point, we
1292
1289
// will try to eliminate this value then.
1293
- if (hasConsumingUseState == LiveRange::HasConsumingUse_t::YesButAllPhiArgs) {
1290
+ if (hasUnknownConsumingUseState ==
1291
+ LiveRange::HasConsumingUse_t::YesButAllPhiArgs) {
1294
1292
auto *op = lr.getSingleUnknownConsumingUse ();
1295
1293
assert (op);
1296
1294
unsigned opNum = op->getOperandNumber ();
@@ -1306,7 +1304,7 @@ bool SemanticARCOptVisitor::performGuaranteedCopyValueOptimization(CopyValueInst
1306
1304
1307
1305
auto *arg = succBlock->getSILPhiArguments ()[opNum];
1308
1306
LiveRange phiArgLR (arg);
1309
- if (bool (phiArgLR.hasConsumingUse ())) {
1307
+ if (bool (phiArgLR.hasUnknownConsumingUse ())) {
1310
1308
return false ;
1311
1309
}
1312
1310
@@ -1788,7 +1786,7 @@ bool SemanticARCOptVisitor::visitLoadInst(LoadInst *li) {
1788
1786
// -> load_borrow if we can put a copy_value on a cold path and thus
1789
1787
// eliminate RR traffic on a hot path.
1790
1788
LiveRange lr (li);
1791
- if (bool (lr.hasConsumingUse ()))
1789
+ if (bool (lr.hasUnknownConsumingUse ()))
1792
1790
return false ;
1793
1791
1794
1792
// Then check if our address is ever written to. If it is, then we cannot use
0 commit comments