@@ -1492,9 +1492,9 @@ class AllocOptimize {
1492
1492
Optional<std::pair<SILType, unsigned >>
1493
1493
computeAvailableValues (SILValue SrcAddr, SILInstruction *Inst,
1494
1494
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 );
1498
1498
void promoteLoadTake (LoadInst *Inst, MutableArrayRef<AvailableValue> values);
1499
1499
void promoteDestroyAddr (DestroyAddrInst *dai,
1500
1500
MutableArrayRef<AvailableValue> values);
@@ -1570,7 +1570,7 @@ static SILValue tryFindSrcAddrForLoad(SILInstruction *i) {
1570
1570
// / cross element accesses have been scalarized.
1571
1571
// /
1572
1572
// / This returns true if the load has been removed from the program.
1573
- bool AllocOptimize::promoteLoadCopy (LoadInst *Inst ) {
1573
+ bool AllocOptimize::promoteLoadCopy (LoadInst *li ) {
1574
1574
// Note that we intentionally don't support forwarding of weak pointers,
1575
1575
// because the underlying value may drop be deallocated at any time. We would
1576
1576
// have to prove that something in this function is holding the weak value
@@ -1579,28 +1579,27 @@ bool AllocOptimize::promoteLoadCopy(LoadInst *Inst) {
1579
1579
1580
1580
// First attempt to find a source addr for our "load" instruction. If we fail
1581
1581
// to find a valid value, just return.
1582
- SILValue SrcAddr = tryFindSrcAddrForLoad (Inst );
1583
- if (!SrcAddr )
1582
+ SILValue srcAddr = tryFindSrcAddrForLoad (li );
1583
+ if (!srcAddr )
1584
1584
return false ;
1585
1585
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 ())
1589
1589
return false ;
1590
1590
1591
- SILType LoadTy = Result ->first ;
1592
- unsigned FirstElt = Result ->second ;
1591
+ SILType loadTy = result ->first ;
1592
+ unsigned firstElt = result ->second ;
1593
1593
1594
1594
// Aggregate together all of the subelements into something that has the same
1595
1595
// type as the load did, and emit smaller loads for any subelements that were
1596
1596
// not available. We are "propagating" a +1 available value from the store
1597
1597
// points.
1598
- auto *load = dyn_cast<SingleValueInstruction>(Inst);
1599
- AvailableValueAggregator agg (load, AvailableValues, Uses, deadEndBlocks,
1598
+ AvailableValueAggregator agg (li, availableValues, Uses, deadEndBlocks,
1600
1599
false /* isTake*/ );
1601
- SILValue newVal = agg.aggregateValues (LoadTy, load ->getOperand (0 ), FirstElt );
1600
+ SILValue newVal = agg.aggregateValues (loadTy, li ->getOperand (), firstElt );
1602
1601
1603
- LLVM_DEBUG (llvm::dbgs () << " *** Promoting load: " << *load << " \n " );
1602
+ LLVM_DEBUG (llvm::dbgs () << " *** Promoting load: " << *li << " \n " );
1604
1603
LLVM_DEBUG (llvm::dbgs () << " To value: " << *newVal << " \n " );
1605
1604
1606
1605
// If we inserted any copies, we created the copies at our stores. We know
@@ -1610,7 +1609,7 @@ bool AllocOptimize::promoteLoadCopy(LoadInst *Inst) {
1610
1609
// blocks that we may have can be found by performing a linear lifetime check
1611
1610
// over all copies that we found using the load as the "consuming uses" (just
1612
1611
// for the purposes of identifying the consuming block).
1613
- auto *oldLoad = agg.addMissingDestroysForCopiedValues (load , newVal);
1612
+ auto *oldLoad = agg.addMissingDestroysForCopiedValues (li , newVal);
1614
1613
1615
1614
++NumLoadPromoted;
1616
1615
@@ -1627,7 +1626,7 @@ bool AllocOptimize::promoteLoadCopy(LoadInst *Inst) {
1627
1626
return true ;
1628
1627
}
1629
1628
1630
- bool AllocOptimize::promoteCopyAddr (CopyAddrInst *Inst ) {
1629
+ bool AllocOptimize::promoteCopyAddr (CopyAddrInst *cai ) {
1631
1630
// Note that we intentionally don't support forwarding of weak pointers,
1632
1631
// because the underlying value may drop be deallocated at any time. We would
1633
1632
// have to prove that something in this function is holding the weak value
@@ -1636,19 +1635,19 @@ bool AllocOptimize::promoteCopyAddr(CopyAddrInst *Inst) {
1636
1635
1637
1636
// First attempt to find a source addr for our "load" instruction. If we fail
1638
1637
// to find a valid value, just return.
1639
- SILValue SrcAddr = tryFindSrcAddrForLoad (Inst );
1640
- if (!SrcAddr )
1638
+ SILValue srcAddr = tryFindSrcAddrForLoad (cai );
1639
+ if (!srcAddr )
1641
1640
return false ;
1642
1641
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 ())
1646
1645
return false ;
1647
1646
1648
1647
// Ok, we have some available values. If we have a copy_addr, explode it now,
1649
1648
// exposing the load operation within it. Subsequent optimization passes will
1650
1649
// see the load and propagate the available values into it.
1651
- DataflowContext.explodeCopyAddr (Inst );
1650
+ DataflowContext.explodeCopyAddr (cai );
1652
1651
1653
1652
// This is removing the copy_addr, but explodeCopyAddr takes care of
1654
1653
// removing the instruction from Uses for us, so we return false.
@@ -1661,7 +1660,7 @@ bool AllocOptimize::promoteCopyAddr(CopyAddrInst *Inst) {
1661
1660
// / cross element accesses have been scalarized.
1662
1661
// /
1663
1662
// / This returns true if the load has been removed from the program.
1664
- bool AllocOptimize::promoteLoadBorrow (LoadBorrowInst *Inst ) {
1663
+ bool AllocOptimize::promoteLoadBorrow (LoadBorrowInst *lbi ) {
1665
1664
// Note that we intentionally don't support forwarding of weak pointers,
1666
1665
// because the underlying value may drop be deallocated at any time. We would
1667
1666
// have to prove that something in this function is holding the weak value
@@ -1670,28 +1669,27 @@ bool AllocOptimize::promoteLoadBorrow(LoadBorrowInst *Inst) {
1670
1669
1671
1670
// First attempt to find a source addr for our "load" instruction. If we fail
1672
1671
// to find a valid value, just return.
1673
- SILValue SrcAddr = tryFindSrcAddrForLoad (Inst );
1674
- if (!SrcAddr )
1672
+ SILValue srcAddr = tryFindSrcAddrForLoad (lbi );
1673
+ if (!srcAddr )
1675
1674
return false ;
1676
1675
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 ())
1680
1679
return false ;
1681
1680
1682
- SILType LoadTy = Result ->first ;
1683
- unsigned FirstElt = Result ->second ;
1681
+ SILType loadTy = result ->first ;
1682
+ unsigned firstElt = result ->second ;
1684
1683
1685
1684
// Aggregate together all of the subelements into something that has the same
1686
1685
// type as the load did, and emit smaller loads for any subelements that were
1687
1686
// not available. We are "propagating" a +1 available value from the store
1688
1687
// points.
1689
- auto *load = dyn_cast<SingleValueInstruction>(Inst);
1690
- AvailableValueAggregator agg (load, AvailableValues, Uses, deadEndBlocks,
1688
+ AvailableValueAggregator agg (lbi, availableValues, Uses, deadEndBlocks,
1691
1689
false /* isTake*/ );
1692
- SILValue newVal = agg.aggregateValues (LoadTy, load ->getOperand (0 ), FirstElt );
1690
+ SILValue newVal = agg.aggregateValues (loadTy, lbi ->getOperand (), firstElt );
1693
1691
1694
- LLVM_DEBUG (llvm::dbgs () << " *** Promoting load: " << *load << " \n " );
1692
+ LLVM_DEBUG (llvm::dbgs () << " *** Promoting load: " << *lbi << " \n " );
1695
1693
LLVM_DEBUG (llvm::dbgs () << " To value: " << *newVal << " \n " );
1696
1694
1697
1695
// If we inserted any copies, we created the copies at our stores. We know
@@ -1701,7 +1699,7 @@ bool AllocOptimize::promoteLoadBorrow(LoadBorrowInst *Inst) {
1701
1699
// blocks that we may have can be found by performing a linear lifetime check
1702
1700
// over all copies that we found using the load as the "consuming uses" (just
1703
1701
// for the purposes of identifying the consuming block).
1704
- auto *oldLoad = agg.addMissingDestroysForCopiedValues (load , newVal);
1702
+ auto *oldLoad = agg.addMissingDestroysForCopiedValues (lbi , newVal);
1705
1703
1706
1704
++NumLoadPromoted;
1707
1705
0 commit comments