Skip to content

Commit 5ecacb9

Browse files
committed
[pmo] Cleanup some old code to use the same style.
1 parent 8c1bfbe commit 5ecacb9

File tree

1 file changed

+34
-36
lines changed

1 file changed

+34
-36
lines changed

lib/SILOptimizer/Mandatory/PredictableMemOpt.cpp

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,9 +1492,9 @@ class AllocOptimize {
14921492
Optional<std::pair<SILType, unsigned>>
14931493
computeAvailableValues(SILValue SrcAddr, SILInstruction *Inst,
14941494
SmallVectorImpl<AvailableValue> &AvailableValues);
1495-
bool promoteLoadCopy(LoadInst *Inst);
1496-
bool promoteLoadBorrow(LoadBorrowInst *Inst);
1497-
bool promoteCopyAddr(CopyAddrInst *CAI);
1495+
bool promoteLoadCopy(LoadInst *li);
1496+
bool promoteLoadBorrow(LoadBorrowInst *lbi);
1497+
bool promoteCopyAddr(CopyAddrInst *cai);
14981498
void promoteLoadTake(LoadInst *Inst, MutableArrayRef<AvailableValue> values);
14991499
void promoteDestroyAddr(DestroyAddrInst *dai,
15001500
MutableArrayRef<AvailableValue> values);
@@ -1570,7 +1570,7 @@ static SILValue tryFindSrcAddrForLoad(SILInstruction *i) {
15701570
/// cross element accesses have been scalarized.
15711571
///
15721572
/// This returns true if the load has been removed from the program.
1573-
bool AllocOptimize::promoteLoadCopy(LoadInst *Inst) {
1573+
bool AllocOptimize::promoteLoadCopy(LoadInst *li) {
15741574
// Note that we intentionally don't support forwarding of weak pointers,
15751575
// because the underlying value may drop be deallocated at any time. We would
15761576
// have to prove that something in this function is holding the weak value
@@ -1579,28 +1579,27 @@ bool AllocOptimize::promoteLoadCopy(LoadInst *Inst) {
15791579

15801580
// First attempt to find a source addr for our "load" instruction. If we fail
15811581
// to find a valid value, just return.
1582-
SILValue SrcAddr = tryFindSrcAddrForLoad(Inst);
1583-
if (!SrcAddr)
1582+
SILValue srcAddr = tryFindSrcAddrForLoad(li);
1583+
if (!srcAddr)
15841584
return false;
15851585

1586-
SmallVector<AvailableValue, 8> AvailableValues;
1587-
auto Result = computeAvailableValues(SrcAddr, Inst, AvailableValues);
1588-
if (!Result.hasValue())
1586+
SmallVector<AvailableValue, 8> availableValues;
1587+
auto result = computeAvailableValues(srcAddr, li, availableValues);
1588+
if (!result.hasValue())
15891589
return false;
15901590

1591-
SILType LoadTy = Result->first;
1592-
unsigned FirstElt = Result->second;
1591+
SILType loadTy = result->first;
1592+
unsigned firstElt = result->second;
15931593

15941594
// Aggregate together all of the subelements into something that has the same
15951595
// type as the load did, and emit smaller loads for any subelements that were
15961596
// not available. We are "propagating" a +1 available value from the store
15971597
// points.
1598-
auto *load = dyn_cast<SingleValueInstruction>(Inst);
1599-
AvailableValueAggregator agg(load, AvailableValues, Uses, deadEndBlocks,
1598+
AvailableValueAggregator agg(li, availableValues, Uses, deadEndBlocks,
16001599
false /*isTake*/);
1601-
SILValue newVal = agg.aggregateValues(LoadTy, load->getOperand(0), FirstElt);
1600+
SILValue newVal = agg.aggregateValues(loadTy, li->getOperand(), firstElt);
16021601

1603-
LLVM_DEBUG(llvm::dbgs() << " *** Promoting load: " << *load << "\n");
1602+
LLVM_DEBUG(llvm::dbgs() << " *** Promoting load: " << *li << "\n");
16041603
LLVM_DEBUG(llvm::dbgs() << " To value: " << *newVal << "\n");
16051604

16061605
// If we inserted any copies, we created the copies at our stores. We know
@@ -1610,7 +1609,7 @@ bool AllocOptimize::promoteLoadCopy(LoadInst *Inst) {
16101609
// blocks that we may have can be found by performing a linear lifetime check
16111610
// over all copies that we found using the load as the "consuming uses" (just
16121611
// for the purposes of identifying the consuming block).
1613-
auto *oldLoad = agg.addMissingDestroysForCopiedValues(load, newVal);
1612+
auto *oldLoad = agg.addMissingDestroysForCopiedValues(li, newVal);
16141613

16151614
++NumLoadPromoted;
16161615

@@ -1627,7 +1626,7 @@ bool AllocOptimize::promoteLoadCopy(LoadInst *Inst) {
16271626
return true;
16281627
}
16291628

1630-
bool AllocOptimize::promoteCopyAddr(CopyAddrInst *Inst) {
1629+
bool AllocOptimize::promoteCopyAddr(CopyAddrInst *cai) {
16311630
// Note that we intentionally don't support forwarding of weak pointers,
16321631
// because the underlying value may drop be deallocated at any time. We would
16331632
// have to prove that something in this function is holding the weak value
@@ -1636,19 +1635,19 @@ bool AllocOptimize::promoteCopyAddr(CopyAddrInst *Inst) {
16361635

16371636
// First attempt to find a source addr for our "load" instruction. If we fail
16381637
// to find a valid value, just return.
1639-
SILValue SrcAddr = tryFindSrcAddrForLoad(Inst);
1640-
if (!SrcAddr)
1638+
SILValue srcAddr = tryFindSrcAddrForLoad(cai);
1639+
if (!srcAddr)
16411640
return false;
16421641

1643-
SmallVector<AvailableValue, 8> AvailableValues;
1644-
auto Result = computeAvailableValues(SrcAddr, Inst, AvailableValues);
1645-
if (!Result.hasValue())
1642+
SmallVector<AvailableValue, 8> availableValues;
1643+
auto result = computeAvailableValues(srcAddr, cai, availableValues);
1644+
if (!result.hasValue())
16461645
return false;
16471646

16481647
// Ok, we have some available values. If we have a copy_addr, explode it now,
16491648
// exposing the load operation within it. Subsequent optimization passes will
16501649
// see the load and propagate the available values into it.
1651-
DataflowContext.explodeCopyAddr(Inst);
1650+
DataflowContext.explodeCopyAddr(cai);
16521651

16531652
// This is removing the copy_addr, but explodeCopyAddr takes care of
16541653
// removing the instruction from Uses for us, so we return false.
@@ -1661,7 +1660,7 @@ bool AllocOptimize::promoteCopyAddr(CopyAddrInst *Inst) {
16611660
/// cross element accesses have been scalarized.
16621661
///
16631662
/// This returns true if the load has been removed from the program.
1664-
bool AllocOptimize::promoteLoadBorrow(LoadBorrowInst *Inst) {
1663+
bool AllocOptimize::promoteLoadBorrow(LoadBorrowInst *lbi) {
16651664
// Note that we intentionally don't support forwarding of weak pointers,
16661665
// because the underlying value may drop be deallocated at any time. We would
16671666
// have to prove that something in this function is holding the weak value
@@ -1670,28 +1669,27 @@ bool AllocOptimize::promoteLoadBorrow(LoadBorrowInst *Inst) {
16701669

16711670
// First attempt to find a source addr for our "load" instruction. If we fail
16721671
// to find a valid value, just return.
1673-
SILValue SrcAddr = tryFindSrcAddrForLoad(Inst);
1674-
if (!SrcAddr)
1672+
SILValue srcAddr = tryFindSrcAddrForLoad(lbi);
1673+
if (!srcAddr)
16751674
return false;
16761675

1677-
SmallVector<AvailableValue, 8> AvailableValues;
1678-
auto Result = computeAvailableValues(SrcAddr, Inst, AvailableValues);
1679-
if (!Result.hasValue())
1676+
SmallVector<AvailableValue, 8> availableValues;
1677+
auto result = computeAvailableValues(srcAddr, lbi, availableValues);
1678+
if (!result.hasValue())
16801679
return false;
16811680

1682-
SILType LoadTy = Result->first;
1683-
unsigned FirstElt = Result->second;
1681+
SILType loadTy = result->first;
1682+
unsigned firstElt = result->second;
16841683

16851684
// Aggregate together all of the subelements into something that has the same
16861685
// type as the load did, and emit smaller loads for any subelements that were
16871686
// not available. We are "propagating" a +1 available value from the store
16881687
// points.
1689-
auto *load = dyn_cast<SingleValueInstruction>(Inst);
1690-
AvailableValueAggregator agg(load, AvailableValues, Uses, deadEndBlocks,
1688+
AvailableValueAggregator agg(lbi, availableValues, Uses, deadEndBlocks,
16911689
false /*isTake*/);
1692-
SILValue newVal = agg.aggregateValues(LoadTy, load->getOperand(0), FirstElt);
1690+
SILValue newVal = agg.aggregateValues(loadTy, lbi->getOperand(), firstElt);
16931691

1694-
LLVM_DEBUG(llvm::dbgs() << " *** Promoting load: " << *load << "\n");
1692+
LLVM_DEBUG(llvm::dbgs() << " *** Promoting load: " << *lbi << "\n");
16951693
LLVM_DEBUG(llvm::dbgs() << " To value: " << *newVal << "\n");
16961694

16971695
// If we inserted any copies, we created the copies at our stores. We know
@@ -1701,7 +1699,7 @@ bool AllocOptimize::promoteLoadBorrow(LoadBorrowInst *Inst) {
17011699
// blocks that we may have can be found by performing a linear lifetime check
17021700
// over all copies that we found using the load as the "consuming uses" (just
17031701
// for the purposes of identifying the consuming block).
1704-
auto *oldLoad = agg.addMissingDestroysForCopiedValues(load, newVal);
1702+
auto *oldLoad = agg.addMissingDestroysForCopiedValues(lbi, newVal);
17051703

17061704
++NumLoadPromoted;
17071705

0 commit comments

Comments
 (0)