Skip to content

Commit c9e0bb5

Browse files
committed
[Mem2Reg] NFC: Removed spurious typealias.
`BlockSetVector` is not much shorter than `BasicBlockSetVector`, and there's no reason to tie the type to `StackAllocationPromoter`.
1 parent 4967614 commit c9e0bb5

File tree

1 file changed

+35
-34
lines changed

1 file changed

+35
-34
lines changed

lib/SILOptimizer/Transforms/SILMem2Reg.cpp

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,6 @@ namespace {
847847

848848
/// Promotes a single AllocStackInst into registers..
849849
class StackAllocationPromoter {
850-
using BlockSetVector = BasicBlockSetVector;
851850
using BlockToInstMap = llvm::DenseMap<SILBasicBlock *, SILInstruction *>;
852851

853852
// Use a priority queue keyed on dominator tree level so that inserted nodes
@@ -955,56 +954,58 @@ class StackAllocationPromoter {
955954

956955
private:
957956
/// Promote AllocStacks into SSA.
958-
void promoteAllocationToPhi(BlockSetVector &livePhiBlocks);
957+
void promoteAllocationToPhi(BasicBlockSetVector &livePhiBlocks);
959958

960959
/// Replace the dummy nodes with new block arguments.
961-
void addBlockArguments(BlockSetVector &phiBlocks);
960+
void addBlockArguments(BasicBlockSetVector &phiBlocks);
962961

963962
/// Check if \p phi is a proactively added phi by SILMem2Reg
964-
bool isProactivePhi(SILPhiArgument *phi, const BlockSetVector &phiBlocks);
963+
bool isProactivePhi(SILPhiArgument *phi,
964+
const BasicBlockSetVector &phiBlocks);
965965

966966
/// Check if \p proactivePhi is live.
967967
bool isNecessaryProactivePhi(SILPhiArgument *proactivePhi,
968-
const BlockSetVector &phiBlocks);
968+
const BasicBlockSetVector &phiBlocks);
969969

970970
/// Given a \p proactivePhi that is live, backward propagate liveness to
971971
/// other proactivePhis.
972972
void propagateLiveness(SILPhiArgument *proactivePhi,
973-
const BlockSetVector &phiBlocks,
973+
const BasicBlockSetVector &phiBlocks,
974974
SmallPtrSetImpl<SILPhiArgument *> &livePhis);
975975

976976
/// End the lexical borrow scope that is introduced for lexical alloc_stack
977977
/// instructions.
978-
void endLexicalLifetime(BlockSetVector &phiBlocks);
978+
void endLexicalLifetime(BasicBlockSetVector &phiBlocks);
979979

980980
/// Fix all of the branch instructions and the uses to use
981981
/// the AllocStack definitions (which include stores and Phis).
982-
void fixBranchesAndUses(BlockSetVector &blocks, BlockSetVector &liveBlocks);
982+
void fixBranchesAndUses(BasicBlockSetVector &blocks,
983+
BasicBlockSetVector &liveBlocks);
983984

984985
/// update the branch instructions with the new Phi argument.
985986
/// The blocks in \p PhiBlocks are blocks that define a value, \p Dest is
986987
/// the branch destination, and \p Pred is the predecessors who's branch we
987988
/// modify.
988-
void fixPhiPredBlock(BlockSetVector &phiBlocks, SILBasicBlock *dest,
989+
void fixPhiPredBlock(BasicBlockSetVector &phiBlocks, SILBasicBlock *dest,
989990
SILBasicBlock *pred);
990991

991992
/// Get the values for this AllocStack variable that are flowing out of
992993
/// StartBB.
993-
llvm::Optional<LiveValues> getLiveOutValues(BlockSetVector &phiBlocks,
994+
llvm::Optional<LiveValues> getLiveOutValues(BasicBlockSetVector &phiBlocks,
994995
SILBasicBlock *startBlock);
995996

996997
/// Get the values for this AllocStack variable that are flowing out of
997998
/// StartBB or undef if there are none.
998-
LiveValues getEffectiveLiveOutValues(BlockSetVector &phiBlocks,
999+
LiveValues getEffectiveLiveOutValues(BasicBlockSetVector &phiBlocks,
9991000
SILBasicBlock *startBlock);
10001001

10011002
/// Get the values for this AllocStack variable that are flowing into block.
1002-
llvm::Optional<LiveValues> getLiveInValues(BlockSetVector &phiBlocks,
1003+
llvm::Optional<LiveValues> getLiveInValues(BasicBlockSetVector &phiBlocks,
10031004
SILBasicBlock *block);
10041005

10051006
/// Get the values for this AllocStack variable that are flowing into block or
10061007
/// undef if there are none.
1007-
LiveValues getEffectiveLiveInValues(BlockSetVector &phiBlocks,
1008+
LiveValues getEffectiveLiveInValues(BasicBlockSetVector &phiBlocks,
10081009
SILBasicBlock *block);
10091010

10101011
/// Prune AllocStacks usage in the function. Scan the function
@@ -1256,7 +1257,8 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
12561257
return nullptr;
12571258
}
12581259

1259-
void StackAllocationPromoter::addBlockArguments(BlockSetVector &phiBlocks) {
1260+
void StackAllocationPromoter::addBlockArguments(
1261+
BasicBlockSetVector &phiBlocks) {
12601262
LLVM_DEBUG(llvm::dbgs() << "*** Adding new block arguments.\n");
12611263

12621264
for (auto *block : phiBlocks) {
@@ -1266,7 +1268,7 @@ void StackAllocationPromoter::addBlockArguments(BlockSetVector &phiBlocks) {
12661268
}
12671269

12681270
llvm::Optional<LiveValues>
1269-
StackAllocationPromoter::getLiveOutValues(BlockSetVector &phiBlocks,
1271+
StackAllocationPromoter::getLiveOutValues(BasicBlockSetVector &phiBlocks,
12701272
SILBasicBlock *startBlock) {
12711273
LLVM_DEBUG(llvm::dbgs() << "*** Searching for a value definition.\n");
12721274
// Walk the Dom tree in search of a defining value:
@@ -1301,9 +1303,8 @@ StackAllocationPromoter::getLiveOutValues(BlockSetVector &phiBlocks,
13011303
return llvm::None;
13021304
}
13031305

1304-
LiveValues
1305-
StackAllocationPromoter::getEffectiveLiveOutValues(BlockSetVector &phiBlocks,
1306-
SILBasicBlock *startBlock) {
1306+
LiveValues StackAllocationPromoter::getEffectiveLiveOutValues(
1307+
BasicBlockSetVector &phiBlocks, SILBasicBlock *startBlock) {
13071308
if (auto values = getLiveOutValues(phiBlocks, startBlock)) {
13081309
return *values;
13091310
}
@@ -1312,7 +1313,7 @@ StackAllocationPromoter::getEffectiveLiveOutValues(BlockSetVector &phiBlocks,
13121313
}
13131314

13141315
llvm::Optional<LiveValues>
1315-
StackAllocationPromoter::getLiveInValues(BlockSetVector &phiBlocks,
1316+
StackAllocationPromoter::getLiveInValues(BasicBlockSetVector &phiBlocks,
13161317
SILBasicBlock *block) {
13171318
// First, check if there is a Phi value in the current block. We know that
13181319
// our loads happen before stores, so we need to first check for Phi nodes
@@ -1337,9 +1338,8 @@ StackAllocationPromoter::getLiveInValues(BlockSetVector &phiBlocks,
13371338
return getLiveOutValues(phiBlocks, iDom->getBlock());
13381339
}
13391340

1340-
LiveValues
1341-
StackAllocationPromoter::getEffectiveLiveInValues(BlockSetVector &phiBlocks,
1342-
SILBasicBlock *block) {
1341+
LiveValues StackAllocationPromoter::getEffectiveLiveInValues(
1342+
BasicBlockSetVector &phiBlocks, SILBasicBlock *block) {
13431343
if (auto values = getLiveInValues(phiBlocks, block)) {
13441344
return *values;
13451345
}
@@ -1348,7 +1348,7 @@ StackAllocationPromoter::getEffectiveLiveInValues(BlockSetVector &phiBlocks,
13481348
return LiveValues::forOwned(undef, undef);
13491349
}
13501350

1351-
void StackAllocationPromoter::fixPhiPredBlock(BlockSetVector &phiBlocks,
1351+
void StackAllocationPromoter::fixPhiPredBlock(BasicBlockSetVector &phiBlocks,
13521352
SILBasicBlock *destBlock,
13531353
SILBasicBlock *predBlock) {
13541354
TermInst *ti = predBlock->getTerminator();
@@ -1366,15 +1366,15 @@ void StackAllocationPromoter::fixPhiPredBlock(BlockSetVector &phiBlocks,
13661366
deleter.forceDelete(ti);
13671367
}
13681368

1369-
bool StackAllocationPromoter::isProactivePhi(SILPhiArgument *phi,
1370-
const BlockSetVector &phiBlocks) {
1369+
bool StackAllocationPromoter::isProactivePhi(
1370+
SILPhiArgument *phi, const BasicBlockSetVector &phiBlocks) {
13711371
auto *phiBlock = phi->getParentBlock();
13721372
return phiBlocks.contains(phiBlock) &&
13731373
phi == phiBlock->getArgument(phiBlock->getNumArguments() - 1);
13741374
}
13751375

13761376
bool StackAllocationPromoter::isNecessaryProactivePhi(
1377-
SILPhiArgument *proactivePhi, const BlockSetVector &phiBlocks) {
1377+
SILPhiArgument *proactivePhi, const BasicBlockSetVector &phiBlocks) {
13781378
assert(isProactivePhi(proactivePhi, phiBlocks));
13791379
for (auto *use : proactivePhi->getUses()) {
13801380
auto *branch = dyn_cast<BranchInst>(use->getUser());
@@ -1392,7 +1392,7 @@ bool StackAllocationPromoter::isNecessaryProactivePhi(
13921392
}
13931393

13941394
void StackAllocationPromoter::propagateLiveness(
1395-
SILPhiArgument *proactivePhi, const BlockSetVector &phiBlocks,
1395+
SILPhiArgument *proactivePhi, const BasicBlockSetVector &phiBlocks,
13961396
SmallPtrSetImpl<SILPhiArgument *> &livePhis) {
13971397
assert(isProactivePhi(proactivePhi, phiBlocks));
13981398
if (livePhis.contains(proactivePhi))
@@ -1412,8 +1412,8 @@ void StackAllocationPromoter::propagateLiveness(
14121412
}
14131413
}
14141414

1415-
void StackAllocationPromoter::fixBranchesAndUses(BlockSetVector &phiBlocks,
1416-
BlockSetVector &phiBlocksOut) {
1415+
void StackAllocationPromoter::fixBranchesAndUses(
1416+
BasicBlockSetVector &phiBlocks, BasicBlockSetVector &phiBlocksOut) {
14171417
// First update uses of the value.
14181418
SmallVector<SILInstruction *, 4> collectedLoads;
14191419
// Collect all alloc_stack uses.
@@ -1565,7 +1565,8 @@ void StackAllocationPromoter::fixBranchesAndUses(BlockSetVector &phiBlocks,
15651565
///
15661566
/// This can only happen if the successor is a CFG merge and all paths
15671567
/// from here lead to unreachable.
1568-
void StackAllocationPromoter::endLexicalLifetime(BlockSetVector &phiBlocks) {
1568+
void StackAllocationPromoter::endLexicalLifetime(
1569+
BasicBlockSetVector &phiBlocks) {
15691570
if (!lexicalLifetimeEnsured(asi))
15701571
return;
15711572

@@ -1679,7 +1680,7 @@ void StackAllocationPromoter::endLexicalLifetime(BlockSetVector &phiBlocks) {
16791680

16801681
void StackAllocationPromoter::pruneAllocStackUsage() {
16811682
LLVM_DEBUG(llvm::dbgs() << "*** Pruning : " << *asi);
1682-
BlockSetVector functionBlocks(asi->getFunction());
1683+
BasicBlockSetVector functionBlocks(asi->getFunction());
16831684

16841685
// Insert all of the blocks that asi is live in.
16851686
for (auto *use : asi->getUses())
@@ -1703,11 +1704,11 @@ void StackAllocationPromoter::pruneAllocStackUsage() {
17031704
}
17041705

17051706
void StackAllocationPromoter::promoteAllocationToPhi(
1706-
BlockSetVector &livePhiBlocks) {
1707+
BasicBlockSetVector &livePhiBlocks) {
17071708
LLVM_DEBUG(llvm::dbgs() << "*** Placing Phis for : " << *asi);
17081709

17091710
// A list of blocks that will require new Phi values.
1710-
BlockSetVector phiBlocks(asi->getFunction());
1711+
BasicBlockSetVector phiBlocks(asi->getFunction());
17111712

17121713
// The "piggy-bank" data-structure that we use for processing the dom-tree
17131714
// bottom-up.
@@ -1818,7 +1819,7 @@ void StackAllocationPromoter::run() {
18181819
// The blocks which still have new phis after fixBranchesAndUses runs. These
18191820
// are not necessarily the same as phiBlocks because fixBranchesAndUses
18201821
// removes superfluous proactive phis.
1821-
BlockSetVector livePhiBlocks(asi->getFunction());
1822+
BasicBlockSetVector livePhiBlocks(asi->getFunction());
18221823

18231824
// Replace AllocStacks with Phi-nodes.
18241825
promoteAllocationToPhi(livePhiBlocks);

0 commit comments

Comments
 (0)