@@ -1398,19 +1398,17 @@ struct DataflowState {
1398
1398
applySiteToPromotedArgIndices (applySiteToPromotedArgIndices),
1399
1399
closureConsumes(closureConsumes) {}
1400
1400
void init ();
1401
- bool
1402
- process (SILValue address,
1403
- SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers,
1404
- SmallSetVector<SILInstruction *, 8 > &debugInfoBlockSplitPoints);
1401
+ bool process (
1402
+ SILValue address,
1403
+ SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers);
1405
1404
bool handleSingleBlockClosure (SILArgument *address,
1406
1405
ClosureOperandState &state);
1407
1406
bool cleanupAllDestroyAddr (
1408
1407
SILValue address, SILFunction *fn, SmallBitVector &destroyIndices,
1409
1408
SmallBitVector &reinitIndices, SmallBitVector &consumingClosureIndices,
1410
1409
BasicBlockSet &blocksVisitedWhenProcessingNewTakes,
1411
1410
BasicBlockSet &blocksWithMovesThatAreNowTakes,
1412
- SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers,
1413
- SmallSetVector<SILInstruction *, 8 > &debugInfoBlockSplitPoints);
1411
+ SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers);
1414
1412
void clear () {
1415
1413
useBlocks.clear ();
1416
1414
initBlocks.clear ();
@@ -1429,8 +1427,7 @@ bool DataflowState::cleanupAllDestroyAddr(
1429
1427
SmallBitVector &reinitIndices, SmallBitVector &consumingClosureIndices,
1430
1428
BasicBlockSet &blocksVisitedWhenProcessingNewTakes,
1431
1429
BasicBlockSet &blocksWithMovesThatAreNowTakes,
1432
- SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers,
1433
- SmallSetVector<SILInstruction *, 8 > &debugInfoBlockSplitPoints) {
1430
+ SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers) {
1434
1431
bool madeChange = false ;
1435
1432
BasicBlockWorklist worklist (fn);
1436
1433
@@ -1544,12 +1541,8 @@ bool DataflowState::cleanupAllDestroyAddr(
1544
1541
if (auto varInfo = debugVarInst.getVarInfo ()) {
1545
1542
SILBuilderWithScope reinitBuilder (*reinit);
1546
1543
reinitBuilder.setCurrentDebugScope (debugVarInst->getDebugScope ());
1547
- auto *dvi =
1548
- reinitBuilder.createDebugValue (debugVarInst.inst ->getLoc (), address,
1549
- *varInfo, false , /* was moved*/ true );
1550
- // After we are done processing, we are going to split at the reinit
1551
- // point.
1552
- debugInfoBlockSplitPoints.insert (dvi);
1544
+ reinitBuilder.createDebugValue (debugVarInst.inst ->getLoc (), address,
1545
+ *varInfo, false , /* was moved*/ true );
1553
1546
}
1554
1547
}
1555
1548
madeChange = true ;
@@ -1591,8 +1584,7 @@ bool DataflowState::cleanupAllDestroyAddr(
1591
1584
1592
1585
bool DataflowState::process (
1593
1586
SILValue address,
1594
- SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers,
1595
- SmallSetVector<SILInstruction *, 8 > &debugInfoBlockSplitPoints) {
1587
+ SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers) {
1596
1588
SILFunction *fn = address->getFunction ();
1597
1589
assert (fn);
1598
1590
@@ -1811,25 +1803,13 @@ bool DataflowState::process(
1811
1803
if (!convertedMarkMoveToTake)
1812
1804
return madeChange;
1813
1805
1814
- // Now if we had a debug var carrying inst for our address, add the debug var
1815
- // carrying inst to debugInfoBlockSplitPoints so when we are done processing
1816
- // we can break blocks at those locations. This is done to ensure that we
1817
- // don't have to worry about the CFG changing while we are processing. The
1818
- // reason why we do this is that we are working around a bug in SelectionDAG
1819
- // that results in llvm.dbg.addr being sunk to the end of blocks. This can
1820
- // cause the value to appear to not be available after it is initialized. By
1821
- // breaking the block here, we guarantee that SelectionDAG's sinking has no
1822
- // effect since we are the end of the block.
1823
- if (auto debug = DebugVarCarryingInst::getFromValue (address))
1824
- debugInfoBlockSplitPoints.insert (*debug);
1825
-
1826
1806
// Now that we have processed all of our mark_moves, eliminate all of the
1827
1807
// destroy_addr.
1828
1808
madeChange |= cleanupAllDestroyAddr (
1829
1809
address, fn, getIndicesOfPairedDestroys (), getIndicesOfPairedReinits (),
1830
1810
getIndicesOfPairedConsumingClosureUses (),
1831
1811
blocksVisitedWhenProcessingNewTakes, blocksWithMovesThatAreNowTakes,
1832
- postDominatingConsumingUsers, debugInfoBlockSplitPoints );
1812
+ postDominatingConsumingUsers);
1833
1813
1834
1814
return madeChange;
1835
1815
}
@@ -1932,19 +1912,6 @@ struct MoveKillsCopyableAddressesChecker {
1932
1912
applySiteToPromotedArgIndices;
1933
1913
SmallBlotSetVector<SILInstruction *, 8 > closureConsumes;
1934
1914
1935
- // / A list of instructions where to work around the behavior of SelectionDAG,
1936
- // / we break the block. These are debug var carrying insts or debug_value
1937
- // / associated with reinits. This is initialized when we process all of the
1938
- // / addresses. Then as a final step after wards we use this as a worklist and
1939
- // / break blocks at each of these instructions. We update DebugInfo, LoopInfo
1940
- // / if we found that they already exist.
1941
- // /
1942
- // / We on purpose use a set vector to ensure that we only ever split a block
1943
- // / once.
1944
- SmallSetVector<SILInstruction *, 8 > debugInfoBlockSplitPoints;
1945
- DominanceInfo *dominanceToUpdate = nullptr ;
1946
- SILLoopInfo *loopInfoToUpdate = nullptr ;
1947
-
1948
1915
MoveKillsCopyableAddressesChecker (SILFunction *fn,
1949
1916
SILOptFunctionBuilder &funcBuilder)
1950
1917
: fn(fn), useState(),
@@ -1953,12 +1920,6 @@ struct MoveKillsCopyableAddressesChecker {
1953
1920
closureUseState(), closureUseDataflowState(closureUseState),
1954
1921
funcBuilder(funcBuilder) {}
1955
1922
1956
- void setDominanceToUpdate (DominanceInfo *newInfo) {
1957
- dominanceToUpdate = newInfo;
1958
- }
1959
-
1960
- void setLoopInfoToUpdate (SILLoopInfo *newInfo) { loopInfoToUpdate = newInfo; }
1961
-
1962
1923
void cloneDeferCalleeAndRewriteUses (
1963
1924
SmallVectorImpl<SILValue> &temporaryStorage,
1964
1925
const SmallBitVector &bitVector, FullApplySite oldApplySite,
@@ -1970,20 +1931,6 @@ struct MoveKillsCopyableAddressesChecker {
1970
1931
1971
1932
void emitDiagnosticForMove (SILValue borrowedValue,
1972
1933
StringRef borrowedValueName, MoveValueInst *mvi);
1973
- bool splitBlocksAfterDebugInfoCarryingInst (SILModule &mod) {
1974
- if (debugInfoBlockSplitPoints.empty ())
1975
- return false ;
1976
-
1977
- SILBuilderContext ctx (mod);
1978
- do {
1979
- auto *next = debugInfoBlockSplitPoints.pop_back_val ();
1980
- splitBasicBlockAndBranch (ctx, next->getNextInstruction (),
1981
- dominanceToUpdate, loopInfoToUpdate);
1982
- } while (!debugInfoBlockSplitPoints.empty ());
1983
-
1984
- return true ;
1985
- }
1986
-
1987
1934
bool performSingleBasicBlockAnalysis (SILValue address,
1988
1935
MarkUnresolvedMoveAddrInst *mvi);
1989
1936
@@ -2131,7 +2078,6 @@ bool MoveKillsCopyableAddressesChecker::performSingleBasicBlockAnalysis(
2131
2078
if (auto debug = DebugVarCarryingInst::getFromValue (address)) {
2132
2079
if (auto varInfo = debug.getVarInfo ()) {
2133
2080
SILBuilderWithScope undefBuilder (builder);
2134
- debugInfoBlockSplitPoints.insert (*debug);
2135
2081
undefBuilder.setCurrentDebugScope (debug->getDebugScope ());
2136
2082
undefBuilder.createDebugValue (
2137
2083
debug->getLoc (),
@@ -2242,7 +2188,6 @@ bool MoveKillsCopyableAddressesChecker::performSingleBasicBlockAnalysis(
2242
2188
if (auto debug = DebugVarCarryingInst::getFromValue (address)) {
2243
2189
if (auto varInfo = debug.getVarInfo ()) {
2244
2190
{
2245
- debugInfoBlockSplitPoints.insert (*debug);
2246
2191
SILBuilderWithScope undefBuilder (builder);
2247
2192
undefBuilder.setCurrentDebugScope (debug->getDebugScope ());
2248
2193
undefBuilder.createDebugValue (
@@ -2257,10 +2202,9 @@ bool MoveKillsCopyableAddressesChecker::performSingleBasicBlockAnalysis(
2257
2202
auto *next = interestingUser->getNextInstruction ();
2258
2203
SILBuilderWithScope reinitBuilder (next);
2259
2204
reinitBuilder.setCurrentDebugScope (debug->getDebugScope ());
2260
- auto *dvi = reinitBuilder.createDebugValue (debug->getLoc (),
2261
- address, *varInfo, false ,
2262
- /* was moved*/ true );
2263
- debugInfoBlockSplitPoints.insert (dvi);
2205
+ reinitBuilder.createDebugValue (debug->getLoc (), address, *varInfo,
2206
+ false ,
2207
+ /* was moved*/ true );
2264
2208
}
2265
2209
}
2266
2210
debug.markAsMoved ();
@@ -2296,7 +2240,6 @@ bool MoveKillsCopyableAddressesChecker::performSingleBasicBlockAnalysis(
2296
2240
dumpBitVector (llvm::dbgs (), bitVector); llvm::dbgs () << ' \n ' );
2297
2241
if (auto debug = DebugVarCarryingInst::getFromValue (address)) {
2298
2242
if (auto varInfo = debug.getVarInfo ()) {
2299
- debugInfoBlockSplitPoints.insert (*debug);
2300
2243
SILBuilderWithScope undefBuilder (builder);
2301
2244
undefBuilder.setCurrentDebugScope (debug->getDebugScope ());
2302
2245
undefBuilder.createDebugValue (
@@ -2415,8 +2358,7 @@ bool MoveKillsCopyableAddressesChecker::check(SILValue address) {
2415
2358
// Ok, we need to perform global dataflow for one of our moves. Initialize our
2416
2359
// dataflow state engine and then run the dataflow itself.
2417
2360
dataflowState.init ();
2418
- bool result = dataflowState.process (address, closureConsumes,
2419
- debugInfoBlockSplitPoints);
2361
+ bool result = dataflowState.process (address, closureConsumes);
2420
2362
return result;
2421
2363
}
2422
2364
@@ -2471,15 +2413,6 @@ class MoveKillsCopyableAddressesCheckerPass : public SILFunctionTransform {
2471
2413
2472
2414
MoveKillsCopyableAddressesChecker checker (getFunction (), funcBuilder);
2473
2415
2474
- // If we already had dominance or loop info generated, update them when
2475
- // splitting blocks.
2476
- auto *dominanceAnalysis = getAnalysis<DominanceAnalysis>();
2477
- if (dominanceAnalysis->hasFunctionInfo (fn))
2478
- checker.setDominanceToUpdate (dominanceAnalysis->get (fn));
2479
- auto *loopAnalysis = getAnalysis<SILLoopAnalysis>();
2480
- if (loopAnalysis->hasFunctionInfo (fn))
2481
- checker.setLoopInfoToUpdate (loopAnalysis->get (fn));
2482
-
2483
2416
bool madeChange = false ;
2484
2417
while (!addressToProcess.empty ()) {
2485
2418
auto address = addressToProcess.front ();
@@ -2492,13 +2425,6 @@ class MoveKillsCopyableAddressesCheckerPass : public SILFunctionTransform {
2492
2425
invalidateAnalysis (SILAnalysis::InvalidationKind::Instructions);
2493
2426
}
2494
2427
2495
- // We update debug info/loop info here, so we just invalidate instructions.
2496
- if (checker.splitBlocksAfterDebugInfoCarryingInst (fn->getModule ())) {
2497
- AnalysisPreserver preserveDominance (dominanceAnalysis);
2498
- AnalysisPreserver preserveLoop (loopAnalysis);
2499
- invalidateAnalysis (SILAnalysis::InvalidationKind::BranchesAndInstructions);
2500
- }
2501
-
2502
2428
// Now go through and clone any apply sites that we need to clone.
2503
2429
SmallVector<SILValue, 8 > newArgs;
2504
2430
bool rewroteCallee = false ;
0 commit comments