mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[cast-opt] Add a new callback: ReplaceValueUsesAction.
This is the first in a series of patches to update the cast optimizer for ownership and multiple value instructions. This specific patch is NFC.
This commit is contained in:
@@ -1439,26 +1439,34 @@ ConstantFolder::processWorkList() {
|
||||
llvm::DenseSet<SILInstruction *> ErrorSet;
|
||||
llvm::SetVector<SILInstruction *> FoldedUsers;
|
||||
CastOptimizer CastOpt(FuncBuilder,
|
||||
[&](SingleValueInstruction *I, ValueBase *V) { /* ReplaceInstUsesAction */
|
||||
/* ReplaceValueUsesAction */
|
||||
[&](SILValue oldValue, SILValue newValue) {
|
||||
InvalidateInstructions = true;
|
||||
oldValue->replaceAllUsesWith(newValue);
|
||||
},
|
||||
/* ReplaceInstUsesAction */
|
||||
[&](SingleValueInstruction *I, ValueBase *V) {
|
||||
InvalidateInstructions = true;
|
||||
I->replaceAllUsesWith(V);
|
||||
},
|
||||
/* EraseAction */
|
||||
[&](SILInstruction *I) {
|
||||
auto *TI = dyn_cast<TermInst>(I);
|
||||
|
||||
InvalidateInstructions = true;
|
||||
I->replaceAllUsesWith(V);
|
||||
},
|
||||
[&](SILInstruction *I) { /* EraseAction */
|
||||
auto *TI = dyn_cast<TermInst>(I);
|
||||
if (TI) {
|
||||
// Invalidate analysis information related to
|
||||
// branches. Replacing
|
||||
// unconditional_check_branch type instructions
|
||||
// by a trap will also invalidate branches/the
|
||||
// CFG.
|
||||
InvalidateBranches = true;
|
||||
}
|
||||
|
||||
if (TI) {
|
||||
// Invalidate analysis information related to branches. Replacing
|
||||
// unconditional_check_branch type instructions by a trap will also
|
||||
// invalidate branches/the CFG.
|
||||
InvalidateBranches = true;
|
||||
}
|
||||
InvalidateInstructions = true;
|
||||
|
||||
InvalidateInstructions = true;
|
||||
|
||||
WorkList.remove(I);
|
||||
I->eraseFromParent();
|
||||
});
|
||||
WorkList.remove(I);
|
||||
I->eraseFromParent();
|
||||
});
|
||||
|
||||
while (!WorkList.empty()) {
|
||||
SILInstruction *I = WorkList.pop_back_val();
|
||||
|
||||
Reference in New Issue
Block a user