@@ -950,7 +950,7 @@ class StackAllocationPromoter {
950
950
}
951
951
952
952
// / Promote the Allocation.
953
- void run ();
953
+ void run (BasicBlockSetVector &livePhiBlocks );
954
954
955
955
private:
956
956
// / Promote AllocStacks into SSA.
@@ -1808,19 +1808,14 @@ void StackAllocationPromoter::promoteAllocationToPhi(
1808
1808
LLVM_DEBUG (llvm::dbgs () << " *** Finished placing Phis ***\n " );
1809
1809
}
1810
1810
1811
- void StackAllocationPromoter::run () {
1811
+ void StackAllocationPromoter::run (BasicBlockSetVector &livePhiBlocks ) {
1812
1812
auto *function = asi->getFunction ();
1813
1813
1814
1814
// Reduce the number of load/stores in the function to minimum.
1815
1815
// After this phase we are left with up to one load and store
1816
1816
// per block and the last store is recorded.
1817
1817
pruneAllocStackUsage ();
1818
1818
1819
- // The blocks which still have new phis after fixBranchesAndUses runs. These
1820
- // are not necessarily the same as phiBlocks because fixBranchesAndUses
1821
- // removes superfluous proactive phis.
1822
- BasicBlockSetVector livePhiBlocks (asi->getFunction ());
1823
-
1824
1819
// Replace AllocStacks with Phi-nodes.
1825
1820
promoteAllocationToPhi (livePhiBlocks);
1826
1821
@@ -1931,7 +1926,8 @@ class MemoryToRegisters {
1931
1926
// /
1932
1927
// / Note: Populates instructionsToDelete with the instructions the caller is
1933
1928
// / responsible for deleting.
1934
- bool promoteAllocation (AllocStackInst *asi);
1929
+ bool promoteAllocation (AllocStackInst *asi,
1930
+ BasicBlockSetVector &livePhiBlocks);
1935
1931
1936
1932
public:
1937
1933
// / C'tor
@@ -2132,7 +2128,8 @@ void MemoryToRegisters::removeSingleBlockAllocation(AllocStackInst *asi) {
2132
2128
// / or false if not. On success, this returns true and usually drops all of the
2133
2129
// / uses of the AllocStackInst, but never deletes the ASI itself. Callers
2134
2130
// / should check to see if the ASI is dead after this and remove it if so.
2135
- bool MemoryToRegisters::promoteAllocation (AllocStackInst *alloc) {
2131
+ bool MemoryToRegisters::promoteAllocation (AllocStackInst *alloc,
2132
+ BasicBlockSetVector &livePhiBlocks) {
2136
2133
LLVM_DEBUG (llvm::dbgs () << " *** Memory to register looking at: " << *alloc);
2137
2134
++NumAllocStackFound;
2138
2135
@@ -2174,7 +2171,8 @@ bool MemoryToRegisters::promoteAllocation(AllocStackInst *alloc) {
2174
2171
auto &domTreeLevels = getDomTreeLevels ();
2175
2172
StackAllocationPromoter (alloc, domInfo, domTreeLevels, ctx, deleter,
2176
2173
instructionsToDelete)
2177
- .run ();
2174
+ .run (livePhiBlocks);
2175
+
2178
2176
return true ;
2179
2177
}
2180
2178
@@ -2194,7 +2192,11 @@ bool MemoryToRegisters::run() {
2194
2192
if (!asi)
2195
2193
continue ;
2196
2194
2197
- if (promoteAllocation (asi)) {
2195
+ // The blocks which still have new phis after fixBranchesAndUses runs.
2196
+ // These are not necessarily the same as phiBlocks because
2197
+ // fixBranchesAndUses removes superfluous proactive phis.
2198
+ BasicBlockSetVector livePhiBlocks (asi->getFunction ());
2199
+ if (promoteAllocation (asi, livePhiBlocks)) {
2198
2200
for (auto *inst : instructionsToDelete) {
2199
2201
deleter.forceDelete (inst);
2200
2202
}
0 commit comments