Skip to content

Commit 69e6275

Browse files
committed
Rename RLEBBState to BlockState
1 parent 7dfcd4e commit 69e6275

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

lib/SILPasses/Scalar/RedundantLoadElimination.cpp

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ namespace {
162162
class RLEContext;
163163
/// State of the load store in one basic block which allows for forwarding from
164164
/// loads, stores -> loads
165-
class RLEBBState {
165+
class BlockState {
166166
/// The basic block that we are optimizing.
167167
SILBasicBlock *BB;
168168

@@ -199,7 +199,7 @@ class RLEBBState {
199199
}
200200

201201
/// Merge in the state of an individual predecessor.
202-
void mergePredecessorState(RLEBBState &OtherState);
202+
void mergePredecessorState(BlockState &OtherState);
203203

204204
/// MemLocation read has been extracted, expanded and mapped to the bit
205205
/// position in the bitvector. process it using the bit position.
@@ -229,7 +229,7 @@ class RLEBBState {
229229
bool isTrackingMemLocation(unsigned bit);
230230

231231
public:
232-
RLEBBState() = default;
232+
BlockState() = default;
233233

234234
void init(SILBasicBlock *NewBB, unsigned bitcnt, bool reachable) {
235235
BB = NewBB;
@@ -307,7 +307,7 @@ class RLEContext {
307307
PostOrderFunctionInfo::reverse_range ReversePostOrder;
308308

309309
/// Keeps all the locations for the current function. The BitVector in each
310-
/// RLEBBState is then laid on top of it to keep track of which MemLocation
310+
/// BlockState is then laid on top of it to keep track of which MemLocation
311311
/// has a downward available value.
312312
std::vector<MemLocation> MemLocationVault;
313313

@@ -318,8 +318,8 @@ class RLEContext {
318318
/// Use for fast lookup.
319319
llvm::DenseMap<MemLocation, unsigned> LocToBitIndex;
320320

321-
/// A map from each BasicBlock to its RLEBBState.
322-
llvm::SmallDenseMap<SILBasicBlock *, RLEBBState, 4> BBToLocState;
321+
/// A map from each BasicBlock to its BlockState.
322+
llvm::SmallDenseMap<SILBasicBlock *, BlockState, 4> BBToLocState;
323323

324324
/// A map for each basic block and whether its predecessors have forwardable
325325
/// edges.
@@ -341,8 +341,8 @@ class RLEContext {
341341
/// Returns the TypeExpansionCache we will use during expanding MemLocations.
342342
TypeExpansionMap &getTypeExpansionCache() { return TypeExpansionCache; }
343343

344-
/// Return the RLEBBState for the basic block this basic block belongs to.
345-
RLEBBState &getBBLocState(SILBasicBlock *B) { return BBToLocState[B]; }
344+
/// Return the BlockState for the basic block this basic block belongs to.
345+
BlockState &getBlockState(SILBasicBlock *B) { return BBToLocState[B]; }
346346

347347
/// Get the bit representing the MemLocation in the MemLocationVault.
348348
unsigned getMemLocationBit(const MemLocation &L);
@@ -373,30 +373,30 @@ class RLEContext {
373373

374374
} // end anonymous namespace
375375

376-
bool RLEBBState::isTrackingMemLocation(unsigned bit) {
376+
bool BlockState::isTrackingMemLocation(unsigned bit) {
377377
return ForwardSetIn.test(bit);
378378
}
379379

380-
void RLEBBState::stopTrackingMemLocation(unsigned bit) {
380+
void BlockState::stopTrackingMemLocation(unsigned bit) {
381381
ForwardSetIn.reset(bit);
382382
ForwardValIn.erase(bit);
383383
}
384384

385-
void RLEBBState::clearMemLocations() {
385+
void BlockState::clearMemLocations() {
386386
ForwardSetIn.reset();
387387
ForwardValIn.clear();
388388
}
389389

390-
void RLEBBState::startTrackingMemLocation(unsigned bit, LoadStoreValue Val) {
390+
void BlockState::startTrackingMemLocation(unsigned bit, LoadStoreValue Val) {
391391
ForwardSetIn.set(bit);
392392
ForwardValIn[bit] = Val;
393393
}
394394

395-
void RLEBBState::updateTrackedMemLocation(unsigned bit, LoadStoreValue Val) {
395+
void BlockState::updateTrackedMemLocation(unsigned bit, LoadStoreValue Val) {
396396
ForwardValIn[bit] = Val;
397397
}
398398

399-
SILValue RLEBBState::computeForwardingValues(RLEContext &Ctx, MemLocation &L,
399+
SILValue BlockState::computeForwardingValues(RLEContext &Ctx, MemLocation &L,
400400
SILInstruction *InsertPt,
401401
bool UseForwardValOut) {
402402
SILBasicBlock *ParentBB = InsertPt->getParent();
@@ -426,7 +426,7 @@ SILValue RLEBBState::computeForwardingValues(RLEContext &Ctx, MemLocation &L,
426426
return TheForwardingValue;
427427
}
428428

429-
bool RLEBBState::setupRLE(RLEContext &Ctx, SILInstruction *I, SILValue Mem) {
429+
bool BlockState::setupRLE(RLEContext &Ctx, SILInstruction *I, SILValue Mem) {
430430
// Try to construct a SILValue for the current MemLocation.
431431
//
432432
// Collect the locations and their corresponding values into a map.
@@ -468,7 +468,7 @@ bool RLEBBState::setupRLE(RLEContext &Ctx, SILInstruction *I, SILValue Mem) {
468468
return true;
469469
}
470470

471-
void RLEBBState::updateForwardSetForRead(RLEContext &Ctx, unsigned bit,
471+
void BlockState::updateForwardSetForRead(RLEContext &Ctx, unsigned bit,
472472
LoadStoreValue Val) {
473473
// If there is already an available value for this location, use
474474
// the existing value.
@@ -479,7 +479,7 @@ void RLEBBState::updateForwardSetForRead(RLEContext &Ctx, unsigned bit,
479479
startTrackingMemLocation(bit, Val);
480480
}
481481

482-
void RLEBBState::updateForwardSetForWrite(RLEContext &Ctx, unsigned bit,
482+
void BlockState::updateForwardSetForWrite(RLEContext &Ctx, unsigned bit,
483483
LoadStoreValue Val) {
484484
// This is a store. Invalidate any Memlocation that this location may
485485
// alias, as their value can no longer be forwarded.
@@ -498,7 +498,7 @@ void RLEBBState::updateForwardSetForWrite(RLEContext &Ctx, unsigned bit,
498498
startTrackingMemLocation(bit, Val);
499499
}
500500

501-
void RLEBBState::processWrite(RLEContext &Ctx, SILInstruction *I, SILValue Mem,
501+
void BlockState::processWrite(RLEContext &Ctx, SILInstruction *I, SILValue Mem,
502502
SILValue Val) {
503503
// Initialize the MemLocation.
504504
MemLocation L(Mem);
@@ -520,7 +520,7 @@ void RLEBBState::processWrite(RLEContext &Ctx, SILInstruction *I, SILValue Mem,
520520
}
521521
}
522522

523-
void RLEBBState::processRead(RLEContext &Ctx, SILInstruction *I, SILValue Mem,
523+
void BlockState::processRead(RLEContext &Ctx, SILInstruction *I, SILValue Mem,
524524
SILValue Val, bool PF) {
525525
// Initialize the MemLocation.
526526
MemLocation L(Mem);
@@ -560,15 +560,15 @@ void RLEBBState::processRead(RLEContext &Ctx, SILInstruction *I, SILValue Mem,
560560
setupRLE(Ctx, I, Mem);
561561
}
562562

563-
void RLEBBState::processStoreInst(RLEContext &Ctx, StoreInst *SI) {
563+
void BlockState::processStoreInst(RLEContext &Ctx, StoreInst *SI) {
564564
processWrite(Ctx, SI, SI->getDest(), SI->getSrc());
565565
}
566566

567-
void RLEBBState::processLoadInst(RLEContext &Ctx, LoadInst *LI, bool PF) {
567+
void BlockState::processLoadInst(RLEContext &Ctx, LoadInst *LI, bool PF) {
568568
processRead(Ctx, LI, LI->getOperand(), SILValue(LI), PF);
569569
}
570570

571-
void RLEBBState::processUnknownWriteInst(RLEContext &Ctx, SILInstruction *I) {
571+
void BlockState::processUnknownWriteInst(RLEContext &Ctx, SILInstruction *I) {
572572
auto *AA = Ctx.getAA();
573573
for (unsigned i = 0; i < ForwardSetIn.size(); ++i) {
574574
if (!isTrackingMemLocation(i))
@@ -586,7 +586,7 @@ void RLEBBState::processUnknownWriteInst(RLEContext &Ctx, SILInstruction *I) {
586586
}
587587

588588
/// Promote stored values to loads and merge duplicated loads.
589-
bool RLEBBState::optimize(RLEContext &Ctx, bool PF) {
589+
bool BlockState::optimize(RLEContext &Ctx, bool PF) {
590590
for (auto &II : *BB) {
591591
SILInstruction *Inst = &II;
592592
DEBUG(llvm::dbgs() << " Visiting: " << *Inst);
@@ -633,14 +633,14 @@ bool RLEBBState::optimize(RLEContext &Ctx, bool PF) {
633633
return updateForwardSetOut();
634634
}
635635

636-
void RLEBBState::mergePredecessorState(RLEBBState &OtherState) {
636+
void BlockState::mergePredecessorState(BlockState &OtherState) {
637637
// Merge in the predecessor state.
638638
llvm::SmallVector<unsigned, 8> LocDeleteList;
639639
for (unsigned i = 0; i < ForwardSetIn.size(); ++i) {
640640
if (OtherState.ForwardSetOut[i]) {
641641
// There are multiple values from multiple predecessors, set this as
642642
// a covering value. We do not need to track the value itself, as we
643-
// can always go to the predecessors RLEBBState to find it.
643+
// can always go to the predecessors BlockState to find it.
644644
ForwardValIn[i].setCoveringValue();
645645
continue;
646646
}
@@ -649,7 +649,7 @@ void RLEBBState::mergePredecessorState(RLEBBState &OtherState) {
649649
}
650650
}
651651

652-
void RLEBBState::mergePredecessorStates(RLEContext &Ctx) {
652+
void BlockState::mergePredecessorStates(RLEContext &Ctx) {
653653
// Clear the state if the basic block has no predecessor.
654654
if (BB->getPreds().begin() == BB->getPreds().end()) {
655655
clearMemLocations();
@@ -661,9 +661,9 @@ void RLEBBState::mergePredecessorStates(RLEContext &Ctx) {
661661
bool HasAtLeastOnePred = false;
662662
// For each predecessor of BB...
663663
for (auto Pred : BB->getPreds()) {
664-
RLEBBState &Other = Ctx.getBBLocState(Pred);
664+
BlockState &Other = Ctx.getBlockState(Pred);
665665

666-
// If we have not had at least one predecessor, initialize RLEBBState
666+
// If we have not had at least one predecessor, initialize BlockState
667667
// with the state of the initial predecessor.
668668
// If BB is also a predecessor of itself, we should not initialize.
669669
if (!HasAtLeastOnePred) {
@@ -699,7 +699,7 @@ RLEContext::RLEContext(SILFunction *F, AliasAnalysis *AA,
699699
// know all the locations accessed in this function, we can resize the bit
700700
// vector to the appropriate size.
701701
for (auto &B : *F) {
702-
BBToLocState[&B] = RLEBBState();
702+
BBToLocState[&B] = BlockState();
703703
// We set the initial state of unreachable block to 0, as we do not have
704704
// a value for the location.
705705
//
@@ -765,7 +765,7 @@ SILValue RLEContext::computePredecessorCoveringValue(SILBasicBlock *BB,
765765
// At this point, we know this MemLocation has available value and we also
766766
// know we can forward a SILValue from every predecesor. It is safe to
767767
// insert the basic block argument.
768-
RLEBBState &Forwarder = getBBLocState(BB);
768+
BlockState &Forwarder = getBlockState(BB);
769769
SILValue TheForwardingValue = BB->createBBArg(L.getType());
770770

771771
// For the given MemLocation, we just created a concrete value at the
@@ -810,7 +810,7 @@ SILValue RLEContext::computePredecessorCoveringValue(SILBasicBlock *BB,
810810

811811
llvm::DenseMap<SILBasicBlock *, SILValue> Args;
812812
for (auto Pred : Preds) {
813-
RLEBBState &Forwarder = getBBLocState(Pred);
813+
BlockState &Forwarder = getBlockState(Pred);
814814
// Call computeForwardingValues with using ForwardValOut as we are
815815
// computing the MemLocation value at the end of each predecessor.
816816
Args[Pred] = Forwarder.computeForwardingValues(*this, L,
@@ -834,7 +834,7 @@ MemLocation &RLEContext::getMemLocation(const unsigned index) {
834834

835835
unsigned RLEContext::getMemLocationBit(const MemLocation &Loc) {
836836
// Return the bit position of the given Loc in the MemLocationVault. The bit
837-
// position is then used to set/reset the bitvector kept by each RLEBBState.
837+
// position is then used to set/reset the bitvector kept by each BlockState.
838838
//
839839
// We should have the location populated by the enumerateMemLocation at this
840840
// point.
@@ -855,7 +855,7 @@ bool RLEContext::gatherValues(SILBasicBlock *BB, MemLocation &L,
855855
// If we are collecting values at the end of the basic block, we can
856856
// use its ForwardValOut.
857857
//
858-
RLEBBState &Forwarder = getBBLocState(BB);
858+
BlockState &Forwarder = getBlockState(BB);
859859
ValueTableMap &OTM = UseForwardValOut ? Forwarder.getForwardValOut()
860860
: Forwarder.getForwardValIn();
861861
for (auto &X : Locs) {
@@ -905,9 +905,9 @@ bool RLEContext::run() {
905905
do {
906906
ForwardSetChanged = false;
907907
for (SILBasicBlock *BB : ReversePostOrder) {
908-
RLEBBState &Forwarder = getBBLocState(BB);
908+
BlockState &Forwarder = getBlockState(BB);
909909

910-
// Merge the predecessors. After merging, RLEBBState now contains
910+
// Merge the predecessors. After merging, BlockState now contains
911911
// lists of available MemLocations and their values that reach the
912912
// beginning of the basic block along all paths.
913913
Forwarder.mergePredecessorStates(*this);

0 commit comments

Comments
 (0)