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:
@@ -1934,20 +1934,26 @@ bool SimplifyCFG::simplifyCheckedCastBranchBlock(CheckedCastBranchInst *CCBI) {
|
||||
auto ThisBB = CCBI->getParent();
|
||||
|
||||
bool MadeChange = false;
|
||||
CastOptimizer CastOpt(FuncBuilder,
|
||||
[&MadeChange](SILInstruction *I,
|
||||
ValueBase *V) { /* ReplaceInstUsesAction */
|
||||
CastOptimizer CastOpt(
|
||||
FuncBuilder,
|
||||
/* ReplaceValueUsesAction */
|
||||
[&MadeChange](SILValue oldValue, SILValue newValue) {
|
||||
MadeChange = true;
|
||||
},
|
||||
[&MadeChange](SILInstruction *I) { /* EraseInstAction */
|
||||
/* ReplaceInstUsesAction */
|
||||
[&MadeChange](SILInstruction *I, ValueBase *V) { MadeChange = true; },
|
||||
/* EraseInstAction */
|
||||
[&MadeChange](SILInstruction *I) {
|
||||
MadeChange = true;
|
||||
I->eraseFromParent();
|
||||
},
|
||||
[&]() { /* WillSucceedAction */
|
||||
/* WillSucceedAction */
|
||||
[&]() {
|
||||
MadeChange |= removeIfDead(FailureBB);
|
||||
addToWorklist(ThisBB);
|
||||
},
|
||||
[&]() { /* WillFailAction */
|
||||
/* WillFailAction */
|
||||
[&]() {
|
||||
MadeChange |= removeIfDead(SuccessBB);
|
||||
addToWorklist(ThisBB);
|
||||
});
|
||||
@@ -1965,21 +1971,26 @@ bool SimplifyCFG::simplifyCheckedCastValueBranchBlock(
|
||||
bool MadeChange = false;
|
||||
CastOptimizer CastOpt(
|
||||
FuncBuilder,
|
||||
[&MadeChange](SILInstruction *I,
|
||||
ValueBase *V) { /* ReplaceInstUsesAction */
|
||||
MadeChange = true;
|
||||
/* ReplaceValueUsesAction */
|
||||
[&MadeChange](SILValue oldValue, SILValue newValue) {
|
||||
MadeChange = true;
|
||||
},
|
||||
[&MadeChange](SILInstruction *I) { /* EraseInstAction */
|
||||
MadeChange = true;
|
||||
I->eraseFromParent();
|
||||
/* ReplaceInstUsesAction */
|
||||
[&MadeChange](SILInstruction *I, ValueBase *V) { MadeChange = true; },
|
||||
/* EraseInstAction */
|
||||
[&MadeChange](SILInstruction *I) {
|
||||
MadeChange = true;
|
||||
I->eraseFromParent();
|
||||
},
|
||||
[&]() { /* WillSucceedAction */
|
||||
MadeChange |= removeIfDead(FailureBB);
|
||||
addToWorklist(ThisBB);
|
||||
/* WillSucceedAction */
|
||||
[&]() {
|
||||
MadeChange |= removeIfDead(FailureBB);
|
||||
addToWorklist(ThisBB);
|
||||
},
|
||||
[&]() { /* WillFailAction */
|
||||
MadeChange |= removeIfDead(SuccessBB);
|
||||
addToWorklist(ThisBB);
|
||||
/* WillFailAction */
|
||||
[&]() {
|
||||
MadeChange |= removeIfDead(SuccessBB);
|
||||
addToWorklist(ThisBB);
|
||||
});
|
||||
|
||||
MadeChange |= bool(CastOpt.simplifyCheckedCastValueBranchInst(CCBI));
|
||||
@@ -1994,19 +2005,24 @@ simplifyCheckedCastAddrBranchBlock(CheckedCastAddrBranchInst *CCABI) {
|
||||
auto ThisBB = CCABI->getParent();
|
||||
|
||||
bool MadeChange = false;
|
||||
CastOptimizer CastOpt(FuncBuilder,
|
||||
[&MadeChange](SILInstruction *I, ValueBase *V) {
|
||||
MadeChange = true;
|
||||
}, /* ReplaceInstUsesAction */
|
||||
[&MadeChange](SILInstruction *I) { /* EraseInstAction */
|
||||
CastOptimizer CastOpt(
|
||||
FuncBuilder,
|
||||
/* ReplaceValueUsesAction */
|
||||
[&MadeChange](SILValue, SILValue) { MadeChange = true; },
|
||||
/* ReplaceInstUsesAction */
|
||||
[&MadeChange](SILInstruction *I, ValueBase *V) { MadeChange = true; },
|
||||
/* EraseInstAction */
|
||||
[&MadeChange](SILInstruction *I) {
|
||||
MadeChange = true;
|
||||
I->eraseFromParent();
|
||||
},
|
||||
[&]() { /* WillSucceedAction */
|
||||
/* WillSucceedAction */
|
||||
[&]() {
|
||||
MadeChange |= removeIfDead(FailureBB);
|
||||
addToWorklist(ThisBB);
|
||||
},
|
||||
[&]() { /* WillFailAction */
|
||||
/* WillFailAction */
|
||||
[&]() {
|
||||
MadeChange |= removeIfDead(SuccessBB);
|
||||
addToWorklist(ThisBB);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user