@@ -1398,19 +1398,17 @@ struct DataflowState {
13981398 applySiteToPromotedArgIndices (applySiteToPromotedArgIndices),
13991399 closureConsumes(closureConsumes) {}
14001400 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);
14051404 bool handleSingleBlockClosure (SILArgument *address,
14061405 ClosureOperandState &state);
14071406 bool cleanupAllDestroyAddr (
14081407 SILValue address, SILFunction *fn, SmallBitVector &destroyIndices,
14091408 SmallBitVector &reinitIndices, SmallBitVector &consumingClosureIndices,
14101409 BasicBlockSet &blocksVisitedWhenProcessingNewTakes,
14111410 BasicBlockSet &blocksWithMovesThatAreNowTakes,
1412- SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers,
1413- SmallSetVector<SILInstruction *, 8 > &debugInfoBlockSplitPoints);
1411+ SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers);
14141412 void clear () {
14151413 useBlocks.clear ();
14161414 initBlocks.clear ();
@@ -1429,8 +1427,7 @@ bool DataflowState::cleanupAllDestroyAddr(
14291427 SmallBitVector &reinitIndices, SmallBitVector &consumingClosureIndices,
14301428 BasicBlockSet &blocksVisitedWhenProcessingNewTakes,
14311429 BasicBlockSet &blocksWithMovesThatAreNowTakes,
1432- SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers,
1433- SmallSetVector<SILInstruction *, 8 > &debugInfoBlockSplitPoints) {
1430+ SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers) {
14341431 bool madeChange = false ;
14351432 BasicBlockWorklist worklist (fn);
14361433
@@ -1544,12 +1541,8 @@ bool DataflowState::cleanupAllDestroyAddr(
15441541 if (auto varInfo = debugVarInst.getVarInfo ()) {
15451542 SILBuilderWithScope reinitBuilder (*reinit);
15461543 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 );
15531546 }
15541547 }
15551548 madeChange = true ;
@@ -1591,8 +1584,7 @@ bool DataflowState::cleanupAllDestroyAddr(
15911584
15921585bool DataflowState::process (
15931586 SILValue address,
1594- SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers,
1595- SmallSetVector<SILInstruction *, 8 > &debugInfoBlockSplitPoints) {
1587+ SmallBlotSetVector<SILInstruction *, 8 > &postDominatingConsumingUsers) {
15961588 SILFunction *fn = address->getFunction ();
15971589 assert (fn);
15981590
@@ -1811,25 +1803,13 @@ bool DataflowState::process(
18111803 if (!convertedMarkMoveToTake)
18121804 return madeChange;
18131805
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-
18261806 // Now that we have processed all of our mark_moves, eliminate all of the
18271807 // destroy_addr.
18281808 madeChange |= cleanupAllDestroyAddr (
18291809 address, fn, getIndicesOfPairedDestroys (), getIndicesOfPairedReinits (),
18301810 getIndicesOfPairedConsumingClosureUses (),
18311811 blocksVisitedWhenProcessingNewTakes, blocksWithMovesThatAreNowTakes,
1832- postDominatingConsumingUsers, debugInfoBlockSplitPoints );
1812+ postDominatingConsumingUsers);
18331813
18341814 return madeChange;
18351815}
@@ -1932,19 +1912,6 @@ struct MoveKillsCopyableAddressesChecker {
19321912 applySiteToPromotedArgIndices;
19331913 SmallBlotSetVector<SILInstruction *, 8 > closureConsumes;
19341914
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-
19481915 MoveKillsCopyableAddressesChecker (SILFunction *fn,
19491916 SILOptFunctionBuilder &funcBuilder)
19501917 : fn(fn), useState(),
@@ -1953,12 +1920,6 @@ struct MoveKillsCopyableAddressesChecker {
19531920 closureUseState(), closureUseDataflowState(closureUseState),
19541921 funcBuilder(funcBuilder) {}
19551922
1956- void setDominanceToUpdate (DominanceInfo *newInfo) {
1957- dominanceToUpdate = newInfo;
1958- }
1959-
1960- void setLoopInfoToUpdate (SILLoopInfo *newInfo) { loopInfoToUpdate = newInfo; }
1961-
19621923 void cloneDeferCalleeAndRewriteUses (
19631924 SmallVectorImpl<SILValue> &temporaryStorage,
19641925 const SmallBitVector &bitVector, FullApplySite oldApplySite,
@@ -1970,20 +1931,6 @@ struct MoveKillsCopyableAddressesChecker {
19701931
19711932 void emitDiagnosticForMove (SILValue borrowedValue,
19721933 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-
19871934 bool performSingleBasicBlockAnalysis (SILValue address,
19881935 MarkUnresolvedMoveAddrInst *mvi);
19891936
@@ -2131,7 +2078,6 @@ bool MoveKillsCopyableAddressesChecker::performSingleBasicBlockAnalysis(
21312078 if (auto debug = DebugVarCarryingInst::getFromValue (address)) {
21322079 if (auto varInfo = debug.getVarInfo ()) {
21332080 SILBuilderWithScope undefBuilder (builder);
2134- debugInfoBlockSplitPoints.insert (*debug);
21352081 undefBuilder.setCurrentDebugScope (debug->getDebugScope ());
21362082 undefBuilder.createDebugValue (
21372083 debug->getLoc (),
@@ -2242,7 +2188,6 @@ bool MoveKillsCopyableAddressesChecker::performSingleBasicBlockAnalysis(
22422188 if (auto debug = DebugVarCarryingInst::getFromValue (address)) {
22432189 if (auto varInfo = debug.getVarInfo ()) {
22442190 {
2245- debugInfoBlockSplitPoints.insert (*debug);
22462191 SILBuilderWithScope undefBuilder (builder);
22472192 undefBuilder.setCurrentDebugScope (debug->getDebugScope ());
22482193 undefBuilder.createDebugValue (
@@ -2257,10 +2202,9 @@ bool MoveKillsCopyableAddressesChecker::performSingleBasicBlockAnalysis(
22572202 auto *next = interestingUser->getNextInstruction ();
22582203 SILBuilderWithScope reinitBuilder (next);
22592204 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 );
22642208 }
22652209 }
22662210 debug.markAsMoved ();
@@ -2296,7 +2240,6 @@ bool MoveKillsCopyableAddressesChecker::performSingleBasicBlockAnalysis(
22962240 dumpBitVector (llvm::dbgs (), bitVector); llvm::dbgs () << ' \n ' );
22972241 if (auto debug = DebugVarCarryingInst::getFromValue (address)) {
22982242 if (auto varInfo = debug.getVarInfo ()) {
2299- debugInfoBlockSplitPoints.insert (*debug);
23002243 SILBuilderWithScope undefBuilder (builder);
23012244 undefBuilder.setCurrentDebugScope (debug->getDebugScope ());
23022245 undefBuilder.createDebugValue (
@@ -2415,8 +2358,7 @@ bool MoveKillsCopyableAddressesChecker::check(SILValue address) {
24152358 // Ok, we need to perform global dataflow for one of our moves. Initialize our
24162359 // dataflow state engine and then run the dataflow itself.
24172360 dataflowState.init ();
2418- bool result = dataflowState.process (address, closureConsumes,
2419- debugInfoBlockSplitPoints);
2361+ bool result = dataflowState.process (address, closureConsumes);
24202362 return result;
24212363}
24222364
@@ -2471,15 +2413,6 @@ class MoveKillsCopyableAddressesCheckerPass : public SILFunctionTransform {
24712413
24722414 MoveKillsCopyableAddressesChecker checker (getFunction (), funcBuilder);
24732415
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-
24832416 bool madeChange = false ;
24842417 while (!addressToProcess.empty ()) {
24852418 auto address = addressToProcess.front ();
@@ -2492,13 +2425,6 @@ class MoveKillsCopyableAddressesCheckerPass : public SILFunctionTransform {
24922425 invalidateAnalysis (SILAnalysis::InvalidationKind::Instructions);
24932426 }
24942427
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-
25022428 // Now go through and clone any apply sites that we need to clone.
25032429 SmallVector<SILValue, 8 > newArgs;
25042430 bool rewroteCallee = false ;
0 commit comments