Skip to content

Commit f234d8d

Browse files
committed
[Mem2Reg] NFC: Lifted livePhiBlocks into caller.
Previously, the value was computed and destroyed during `promoteAllocationInBlock`. Make the value available in `StackAllocationPromoter`'s top-level routine (`::run`) in preparation for using it there.
1 parent 62b9323 commit f234d8d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/SILOptimizer/Transforms/SILMem2Reg.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ class StackAllocationPromoter {
938938

939939
private:
940940
/// Promote AllocStacks into SSA.
941-
void promoteAllocationToPhi();
941+
void promoteAllocationToPhi(BlockSetVector &livePhiBlocks);
942942

943943
/// Replace the dummy nodes with new block arguments.
944944
void addBlockArguments(BlockSetVector &phiBlocks);
@@ -1685,7 +1685,8 @@ void StackAllocationPromoter::pruneAllocStackUsage() {
16851685
LLVM_DEBUG(llvm::dbgs() << "*** Finished pruning : " << *asi);
16861686
}
16871687

1688-
void StackAllocationPromoter::promoteAllocationToPhi() {
1688+
void StackAllocationPromoter::promoteAllocationToPhi(
1689+
BlockSetVector &livePhiBlocks) {
16891690
LLVM_DEBUG(llvm::dbgs() << "*** Placing Phis for : " << *asi);
16901691

16911692
// A list of blocks that will require new Phi values.
@@ -1781,10 +1782,6 @@ void StackAllocationPromoter::promoteAllocationToPhi() {
17811782
// Replace the dummy values with new block arguments.
17821783
addBlockArguments(phiBlocks);
17831784

1784-
// The blocks which still have new phis after fixBranchesAndUses runs. These
1785-
// are not necessarily the same as phiBlocks because fixBranchesAndUses
1786-
// removes superfluous proactive phis.
1787-
BlockSetVector livePhiBlocks(asi->getFunction());
17881785
// Hook up the Phi nodes, loads, and debug_value_addr with incoming values.
17891786
fixBranchesAndUses(phiBlocks, livePhiBlocks);
17901787

@@ -1801,8 +1798,13 @@ void StackAllocationPromoter::run() {
18011798
// per block and the last store is recorded.
18021799
pruneAllocStackUsage();
18031800

1801+
// The blocks which still have new phis after fixBranchesAndUses runs. These
1802+
// are not necessarily the same as phiBlocks because fixBranchesAndUses
1803+
// removes superfluous proactive phis.
1804+
BlockSetVector livePhiBlocks(asi->getFunction());
1805+
18041806
// Replace AllocStacks with Phi-nodes.
1805-
promoteAllocationToPhi();
1807+
promoteAllocationToPhi(livePhiBlocks);
18061808

18071809
// Make sure that all of the allocations were promoted into registers.
18081810
assert(isWriteOnlyAllocation(asi) && "Non-write uses left behind");

0 commit comments

Comments
 (0)