Skip to content

Commit 790448f

Browse files
committed
[RLE-DSE] Run clang-format on RLE and DSE files. NFC
1 parent 4c12a12 commit 790448f

File tree

2 files changed

+40
-38
lines changed

2 files changed

+40
-38
lines changed

lib/SILPasses/Scalar/DeadStoreElimination.cpp

+17-14
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ constexpr unsigned MaxPartialDeadStoreCountLimit = 1;
124124
/// initialized to the intersection of WriteSetIns of all successors of the
125125
/// basic block.
126126
///
127-
/// Initially WriteSetIn is set to true. After the basic block is processed, if its
127+
/// Initially WriteSetIn is set to true. After the basic block is processed, if
128+
/// its
128129
/// WriteSetOut is different from WriteSetIn, WriteSetIn is initialized to the
129130
/// value of WriteSetOut and the data flow is rerun.
130131
///
@@ -196,7 +197,7 @@ class BBState {
196197
//
197198
WriteSetIn.resize(MemLocationCount, true);
198199
WriteSetOut.resize(MemLocationCount, false);
199-
200+
200201
// GenSet and KillSet initially empty.
201202
BBGenSet.resize(MemLocationCount, false);
202203
BBKillSet.resize(MemLocationCount, false);
@@ -260,7 +261,7 @@ class DSEContext {
260261
llvm::BumpPtrAllocator BPA;
261262

262263
/// Map every basic block to its location state.
263-
llvm::DenseMap<SILBasicBlock *, BBState*> BBToLocState;
264+
llvm::DenseMap<SILBasicBlock *, BBState *> BBToLocState;
264265

265266
/// Keeps the actual BBStates.
266267
std::vector<BBState> BBStates;
@@ -362,6 +363,7 @@ class DSEContext {
362363
/// projection path.
363364
SILValue createExtract(SILValue Base, Optional<ProjectionPath> &Path,
364365
SILInstruction *Inst, bool IsValExtract);
366+
365367
public:
366368
/// Constructor.
367369
DSEContext(SILFunction *F, SILModule *M, SILPassManager *PM,
@@ -457,7 +459,7 @@ void DSEContext::mergeSuccessorStates(SILBasicBlock *BB) {
457459
continue;
458460
C->startTrackingMemLocation(i);
459461
}
460-
return;
462+
return;
461463
}
462464

463465
// Use the first successor as the base condition.
@@ -483,7 +485,7 @@ void DSEContext::invalidateMemLocationBase(SILInstruction *I,
483485
}
484486
return;
485487
}
486-
488+
487489
for (unsigned i = 0; i < S->MemLocationCount; ++i) {
488490
if (!S->WriteSetOut.test(i))
489491
continue;
@@ -585,7 +587,7 @@ void DSEContext::processRead(SILInstruction *I, BBState *S, SILValue Mem,
585587
// Make sure that the MemLocation getType() returns the same type as the
586588
// loaded type.
587589
if (auto *LI = dyn_cast<LoadInst>(I)) {
588-
(void) LI;
590+
(void)LI;
589591
assert(LI->getOperand().getType().getObjectType() == L.getType() &&
590592
"MemLocation returns different type");
591593
}
@@ -602,7 +604,7 @@ void DSEContext::processRead(SILInstruction *I, BBState *S, SILValue Mem,
602604
} else {
603605
for (auto &E : Locs) {
604606
// This is the last iteration, compute WriteSetOut and perform the dead
605-
// store elimination.
607+
// store elimination.
606608
updateWriteSetForRead(I, S, getMemLocationBit(E));
607609
}
608610
}
@@ -634,8 +636,8 @@ void DSEContext::processWrite(SILInstruction *I, BBState *S, SILValue Val,
634636
// Make sure that the MemLocation getType() returns the same type as the
635637
// stored type.
636638
if (auto *SI = dyn_cast<StoreInst>(I)) {
637-
(void) SI;
638-
assert(SI->getDest().getType().getObjectType() == L.getType() &&
639+
(void)SI;
640+
assert(SI->getDest().getType().getObjectType() == L.getType() &&
639641
"MemLocation returns different type");
640642
}
641643

@@ -647,14 +649,14 @@ void DSEContext::processWrite(SILInstruction *I, BBState *S, SILValue Val,
647649
llvm::BitVector V(Locs.size());
648650
if (BuildGenKillSet) {
649651
for (auto &E : Locs) {
650-
// Only building the gen and kill sets here.
651-
updateGenKillSetForWrite(I, S, getMemLocationBit(E));
652+
// Only building the gen and kill sets here.
653+
updateGenKillSetForWrite(I, S, getMemLocationBit(E));
652654
}
653655
} else {
654656
unsigned idx = 0;
655657
for (auto &E : Locs) {
656658
// This is the last iteration, compute WriteSetOut and perform the dead
657-
// store elimination.
659+
// store elimination.
658660
if (updateWriteSetForWrite(I, S, getMemLocationBit(E)))
659661
V.set(idx);
660662
Dead &= V.test(idx);
@@ -834,7 +836,8 @@ void DSEContext::run() {
834836
// vector to the approproate size.
835837
//
836838
// DenseMap has a minimum size of 64, while many functions do not have over
837-
// 64 basic blocks. Therefore, allocate the BBState in a vector and use pointer
839+
// 64 basic blocks. Therefore, allocate the BBState in a vector and use
840+
// pointer
838841
// in BBToLocState to access them.
839842
for (auto &B : *F) {
840843
BBStates.push_back(BBState(&B));
@@ -860,7 +863,7 @@ void DSEContext::run() {
860863
WorkList.push_back(B);
861864
}
862865

863-
while(!WorkList.empty()) {
866+
while (!WorkList.empty()) {
864867
SILBasicBlock *BB = WorkList.pop_back_val();
865868
if (processBasicBlockWithGenKillSet(BB)) {
866869
for (auto X : BB->getPreds())

lib/SILPasses/Scalar/RedundantLoadElimination.cpp

+23-24
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static bool isRLEInertInstruction(SILInstruction *Inst) {
126126

127127
/// Returns true if the given basic block is reachable from the entry block.
128128
///
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.
130130
static bool isReachable(SILBasicBlock *Block) {
131131
SmallPtrSet<SILBasicBlock *, 16> Visited;
132132
llvm::SmallVector<SILBasicBlock *, 16> Worklist;
@@ -220,22 +220,22 @@ class RLEContext {
220220

221221
/// Go to the predecessors of the given basic block, compute the value
222222
/// for the given MemLocation.
223-
SILValue computePredecessorCoveringValue(SILBasicBlock *B, MemLocation &L);
223+
SILValue computePredecessorCoveringValue(SILBasicBlock *B, MemLocation &L);
224224

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.
226227
bool withTransistivelyForwardableEdges(SILBasicBlock *BB);
227228

228229
/// Given a MemLocation, try to collect all the LoadStoreValues for this
229230
/// MemLocation in the given basic block. If a LoadStoreValue is a covering
230231
/// 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
232233
/// basic blocks.
233-
///
234+
///
234235
/// UseForwardValOut tells whether to use the ForwardValOut or not. i.e.
235236
/// when materialize a covering value, we go to each predecessors and
236237
/// 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,
239239
bool UseForwardValOut);
240240

241241
/// Dump all the MemLocations in the MemLocationVault.
@@ -272,7 +272,8 @@ class BBState {
272272
///
273273
/// TODO: can we create a LoadStoreValue vault so that we do not need to keep
274274
/// 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.
276277
///
277278
ValueTableMap ForwardValIn;
278279

@@ -347,11 +348,11 @@ class BBState {
347348
ForwardSetOut.resize(bitcnt, reachable);
348349
}
349350

350-
/// Returns the ForwardValIn for the current basic block.
351+
/// Returns the ForwardValIn for the current basic block.
351352
ValueTableMap &getForwardValIn() { return ForwardValIn; }
352353

353354
/// Returns the ForwardValOut for the current basic block.
354-
ValueTableMap &getForwardValOut() { return ForwardValOut; }
355+
ValueTableMap &getForwardValOut() { return ForwardValOut; }
355356

356357
/// Returns the current basic block we are processing.
357358
SILBasicBlock *getBB() const { return BB; }
@@ -422,7 +423,7 @@ SILValue BBState::computeForwardingValues(RLEContext &Ctx, MemLocation &L,
422423
if (!Ctx.gatherValues(ParentBB, L, Values, UseForwardValOut))
423424
return SILValue();
424425

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
426427
// *refresh* it as terminator instruction could be deleted as a result
427428
// of adding new edge values to the terminator instruction.
428429
if (IsTerminator)
@@ -790,7 +791,7 @@ SILValue RLEContext::computePredecessorCoveringValue(SILBasicBlock *BB,
790791
//
791792
// However, if the MemLocation has a concrete value, we know there must
792793
// 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
794795
// ForwardValOut in this case.
795796
//
796797
// NOTE: This is necessary to prevent an infinite loop while materializing
@@ -823,10 +824,9 @@ SILValue RLEContext::computePredecessorCoveringValue(SILBasicBlock *BB,
823824
for (auto Pred : Preds) {
824825
BBState &Forwarder = getBBLocState(Pred);
825826
// 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.
827828
Args[Pred] = Forwarder.computeForwardingValues(*this, L,
828-
Pred->getTerminator(),
829-
true);
829+
Pred->getTerminator(), true);
830830
assert(Args[Pred] && "Fail to create a forwarding value");
831831
}
832832

@@ -840,7 +840,6 @@ SILValue RLEContext::computePredecessorCoveringValue(SILBasicBlock *BB,
840840
return TheForwardingValue;
841841
}
842842

843-
844843
MemLocation &RLEContext::getMemLocation(const unsigned index) {
845844
return MemLocationVault[index];
846845
}
@@ -869,8 +868,8 @@ bool RLEContext::gatherValues(SILBasicBlock *BB, MemLocation &L,
869868
// use its ForwardValOut.
870869
//
871870
BBState &Forwarder = getBBLocState(BB);
872-
ValueTableMap &OTM = UseForwardValOut ? Forwarder.getForwardValOut() :
873-
Forwarder.getForwardValIn();
871+
ValueTableMap &OTM = UseForwardValOut ? Forwarder.getForwardValOut()
872+
: Forwarder.getForwardValIn();
874873
for (auto &X : Locs) {
875874
Values[X] = OTM[getMemLocationBit(X)];
876875
if (!Values[X].isCoveringValue())
@@ -887,23 +886,23 @@ bool RLEContext::gatherValues(SILBasicBlock *BB, MemLocation &L,
887886
for (auto &X : CSLocs) {
888887
SILValue V = computePredecessorCoveringValue(BB, X);
889888
if (!V)
890-
return false;
889+
return false;
891890
// We've constructed a concrete value for the covering value. Expand and
892891
// collect the newly created forwardable values.
893892
MemLocationList Locs;
894893
LoadStoreValueList Vals;
895894
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];
898897
assert(Values[Locs[i]].isValid() && "Invalid load store value");
899898
}
900899
}
901900

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.
904903
#ifndef NDEBUG
905904
for (auto &X : Locs) {
906-
(void) X;
905+
(void)X;
907906
assert(Values[X].isValid() && "Invalid load store value");
908907
}
909908
#endif

0 commit comments

Comments
 (0)