@@ -1654,6 +1654,7 @@ ConstantFolder::processWorkList() {
16541654 InvalidateInstructions = true ;
16551655 instToDelete->eraseFromParent ();
16561656 });
1657+ InstructionDeleter deleter (std::move (callbacks));
16571658
16581659 // An out parameter array that we use to return new simplified results from
16591660 // constantFoldInstruction.
@@ -1677,7 +1678,7 @@ ConstantFolder::processWorkList() {
16771678 // Schedule users for constant folding.
16781679 WorkList.insert (AssertConfInt);
16791680 // Delete the call.
1680- eliminateDeadInstruction (BI, callbacks );
1681+ eliminateDeadInstruction (BI, deleter. getCallbacks () );
16811682 continue ;
16821683 }
16831684
@@ -1686,7 +1687,7 @@ ConstantFolder::processWorkList() {
16861687 if (isApplyOfBuiltin (*BI, BuiltinValueKind::CondUnreachable)) {
16871688 assert (BI->use_empty () && " use of conditionallyUnreachable?!" );
16881689 recursivelyDeleteTriviallyDeadInstructions (BI, /* force*/ true ,
1689- callbacks );
1690+ deleter. getCallbacks () );
16901691 InvalidateInstructions = true ;
16911692 continue ;
16921693 }
@@ -1698,7 +1699,7 @@ ConstantFolder::processWorkList() {
16981699 SILBuilderWithScope B (I);
16991700 auto tru = B.createIntegerLiteral (apply->getLoc (), apply->getType (), 1 );
17001701 apply->replaceAllUsesWith (tru);
1701- eliminateDeadInstruction (I, callbacks );
1702+ eliminateDeadInstruction (I, deleter. getCallbacks () );
17021703 WorkList.insert (tru);
17031704 InvalidateInstructions = true ;
17041705 }
@@ -1747,7 +1748,7 @@ ConstantFolder::processWorkList() {
17471748 if (constantFoldGlobalStringTablePointerBuiltin (cast<BuiltinInst>(I),
17481749 EnableDiagnostics)) {
17491750 // Here, the builtin instruction got folded, so clean it up.
1750- eliminateDeadInstruction (I, callbacks );
1751+ eliminateDeadInstruction (I, deleter. getCallbacks () );
17511752 }
17521753 continue ;
17531754 }
@@ -1763,7 +1764,7 @@ ConstantFolder::processWorkList() {
17631764 sli->getValue ());
17641765 WorkList.insert (cfi);
17651766 recursivelyDeleteTriviallyDeadInstructions (I, /* force*/ true ,
1766- callbacks );
1767+ deleter. getCallbacks () );
17671768 }
17681769 }
17691770 continue ;
@@ -1773,7 +1774,7 @@ ConstantFolder::processWorkList() {
17731774 if (constantFoldIsConcrete (cast<BuiltinInst>(I))) {
17741775 // Here, the builtin instruction got folded, so clean it up.
17751776 recursivelyDeleteTriviallyDeadInstructions (I, /* force*/ true ,
1776- callbacks );
1777+ deleter. getCallbacks () );
17771778 }
17781779 continue ;
17791780 }
@@ -1796,7 +1797,7 @@ ConstantFolder::processWorkList() {
17961797 SILType::getBuiltinIntegerType (1 , builder.getASTContext ()), val);
17971798 BI->replaceAllUsesWith (inst);
17981799
1799- eliminateDeadInstruction (I, callbacks );
1800+ eliminateDeadInstruction (I, deleter. getCallbacks () );
18001801 continue ;
18011802 }
18021803 }
@@ -1817,7 +1818,6 @@ ConstantFolder::processWorkList() {
18171818 }
18181819
18191820 // Go through all users of the constant and try to fold them.
1820- InstructionDeleter deleter (callbacks);
18211821 for (auto Result : I->getResults ()) {
18221822 for (auto *Use : Result->getUses ()) {
18231823 SILInstruction *User = Use->getUser ();
0 commit comments