@@ -126,7 +126,7 @@ static bool isRLEInertInstruction(SILInstruction *Inst) {
126
126
127
127
// / Returns true if the given basic block is reachable from the entry block.
128
128
// /
129
- // / TODO: this is very inefficient, can we make use of the domtree.
129
+ // / TODO: this is very inefficient, can we make use of the domtree.
130
130
static bool isReachable (SILBasicBlock *Block) {
131
131
SmallPtrSet<SILBasicBlock *, 16 > Visited;
132
132
llvm::SmallVector<SILBasicBlock *, 16 > Worklist;
@@ -220,22 +220,22 @@ class RLEContext {
220
220
221
221
// / Go to the predecessors of the given basic block, compute the value
222
222
// / for the given MemLocation.
223
- SILValue computePredecessorCoveringValue (SILBasicBlock *B, MemLocation &L);
223
+ SILValue computePredecessorCoveringValue (SILBasicBlock *B, MemLocation &L);
224
224
225
- // / Return true if all the predecessors of the basic block can have BBArgument.
225
+ // / Return true if all the predecessors of the basic block can have
226
+ // / BBArgument.
226
227
bool withTransistivelyForwardableEdges (SILBasicBlock *BB);
227
228
228
229
// / Given a MemLocation, try to collect all the LoadStoreValues for this
229
230
// / MemLocation in the given basic block. If a LoadStoreValue is a covering
230
231
// / value, collectForwardingValues also create a SILArgument for it. As a
231
- // / a result, collectForwardingValues may invalidate TerminatorInsts for
232
+ // / a result, collectForwardingValues may invalidate TerminatorInsts for
232
233
// / basic blocks.
233
- // /
234
+ // /
234
235
// / UseForwardValOut tells whether to use the ForwardValOut or not. i.e.
235
236
// / when materialize a covering value, we go to each predecessors and
236
237
// / collect forwarding values from their ForwardValOuts.
237
- bool gatherValues (SILBasicBlock *B, MemLocation &L,
238
- MemLocationValueMap &Vs,
238
+ bool gatherValues (SILBasicBlock *B, MemLocation &L, MemLocationValueMap &Vs,
239
239
bool UseForwardValOut);
240
240
241
241
// / Dump all the MemLocations in the MemLocationVault.
@@ -272,7 +272,8 @@ class BBState {
272
272
// /
273
273
// / TODO: can we create a LoadStoreValue vault so that we do not need to keep
274
274
// / them per basic block. This would also give ForwardValIn more symmetry.
275
- // / i.e. MemLocation and LoadStoreValue both represented as bit vector indices.
275
+ // / i.e. MemLocation and LoadStoreValue both represented as bit vector
276
+ // / indices.
276
277
// /
277
278
ValueTableMap ForwardValIn;
278
279
@@ -347,11 +348,11 @@ class BBState {
347
348
ForwardSetOut.resize (bitcnt, reachable);
348
349
}
349
350
350
- // / Returns the ForwardValIn for the current basic block.
351
+ // / Returns the ForwardValIn for the current basic block.
351
352
ValueTableMap &getForwardValIn () { return ForwardValIn; }
352
353
353
354
// / Returns the ForwardValOut for the current basic block.
354
- ValueTableMap &getForwardValOut () { return ForwardValOut; }
355
+ ValueTableMap &getForwardValOut () { return ForwardValOut; }
355
356
356
357
// / Returns the current basic block we are processing.
357
358
SILBasicBlock *getBB () const { return BB; }
@@ -422,7 +423,7 @@ SILValue BBState::computeForwardingValues(RLEContext &Ctx, MemLocation &L,
422
423
if (!Ctx.gatherValues (ParentBB, L, Values, UseForwardValOut))
423
424
return SILValue ();
424
425
425
- // If the InsertPt is the terminator instruction of the basic block, we
426
+ // If the InsertPt is the terminator instruction of the basic block, we
426
427
// *refresh* it as terminator instruction could be deleted as a result
427
428
// of adding new edge values to the terminator instruction.
428
429
if (IsTerminator)
@@ -790,7 +791,7 @@ SILValue RLEContext::computePredecessorCoveringValue(SILBasicBlock *BB,
790
791
//
791
792
// However, if the MemLocation has a concrete value, we know there must
792
793
// be an instruction that generated the concrete value between the current
793
- // instruction and the end of the basic block, we do not update the
794
+ // instruction and the end of the basic block, we do not update the
794
795
// ForwardValOut in this case.
795
796
//
796
797
// NOTE: This is necessary to prevent an infinite loop while materializing
@@ -823,10 +824,9 @@ SILValue RLEContext::computePredecessorCoveringValue(SILBasicBlock *BB,
823
824
for (auto Pred : Preds) {
824
825
BBState &Forwarder = getBBLocState (Pred);
825
826
// Call computeForwardingValues with using ForwardValOut as we are
826
- // computing the MemLocation value at the end of each predecessor.
827
+ // computing the MemLocation value at the end of each predecessor.
827
828
Args[Pred] = Forwarder.computeForwardingValues (*this , L,
828
- Pred->getTerminator (),
829
- true );
829
+ Pred->getTerminator (), true );
830
830
assert (Args[Pred] && " Fail to create a forwarding value" );
831
831
}
832
832
@@ -840,7 +840,6 @@ SILValue RLEContext::computePredecessorCoveringValue(SILBasicBlock *BB,
840
840
return TheForwardingValue;
841
841
}
842
842
843
-
844
843
MemLocation &RLEContext::getMemLocation (const unsigned index) {
845
844
return MemLocationVault[index ];
846
845
}
@@ -869,8 +868,8 @@ bool RLEContext::gatherValues(SILBasicBlock *BB, MemLocation &L,
869
868
// use its ForwardValOut.
870
869
//
871
870
BBState &Forwarder = getBBLocState (BB);
872
- ValueTableMap &OTM = UseForwardValOut ? Forwarder.getForwardValOut () :
873
- Forwarder.getForwardValIn ();
871
+ ValueTableMap &OTM = UseForwardValOut ? Forwarder.getForwardValOut ()
872
+ : Forwarder.getForwardValIn ();
874
873
for (auto &X : Locs) {
875
874
Values[X] = OTM[getMemLocationBit (X)];
876
875
if (!Values[X].isCoveringValue ())
@@ -887,23 +886,23 @@ bool RLEContext::gatherValues(SILBasicBlock *BB, MemLocation &L,
887
886
for (auto &X : CSLocs) {
888
887
SILValue V = computePredecessorCoveringValue (BB, X);
889
888
if (!V)
890
- return false ;
889
+ return false ;
891
890
// We've constructed a concrete value for the covering value. Expand and
892
891
// collect the newly created forwardable values.
893
892
MemLocationList Locs;
894
893
LoadStoreValueList Vals;
895
894
MemLocation::expandWithValues (X, V, &BB->getModule (), Locs, Vals);
896
- for (unsigned i = 0 ; i < Locs.size () ; ++i) {
897
- Values[Locs[i]] = Vals[i];
895
+ for (unsigned i = 0 ; i < Locs.size (); ++i) {
896
+ Values[Locs[i]] = Vals[i];
898
897
assert (Values[Locs[i]].isValid () && " Invalid load store value" );
899
898
}
900
899
}
901
900
902
- // Sanity check to make sure we have valid load store values for each
903
- // MemLocation.
901
+ // Sanity check to make sure we have valid load store values for each
902
+ // MemLocation.
904
903
#ifndef NDEBUG
905
904
for (auto &X : Locs) {
906
- (void ) X;
905
+ (void )X;
907
906
assert (Values[X].isValid () && " Invalid load store value" );
908
907
}
909
908
#endif
0 commit comments