Skip to content

Commit 534db2c

Browse files
authored
Merge pull request swiftlang#9196 from gottesmm/small_gardening
2 parents 39c550f + c55c0f8 commit 534db2c

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

lib/SILOptimizer/Mandatory/MandatoryInlining.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ cleanupCalleeValue(SILValue CalleeValue, ArrayRef<SILValue> CaptureArgs,
110110
ArrayRef<SILValue> FullArgs) {
111111
SmallVector<SILInstruction*, 16> InstsToDelete;
112112
for (SILValue V : FullArgs) {
113-
if (SILInstruction *I = dyn_cast<SILInstruction>(V))
113+
if (auto *I = dyn_cast<SILInstruction>(V))
114114
if (I != CalleeValue &&
115115
isInstructionTriviallyDead(I))
116116
InstsToDelete.push_back(I);
117117
}
118118
recursivelyDeleteTriviallyDeadInstructions(InstsToDelete, true);
119119

120120
// Handle the case where the callee of the apply is a load instruction.
121-
if (LoadInst *LI = dyn_cast<LoadInst>(CalleeValue)) {
121+
if (auto *LI = dyn_cast<LoadInst>(CalleeValue)) {
122122
auto *PBI = cast<ProjectBoxInst>(LI->getOperand());
123123
auto *ABI = cast<AllocBoxInst>(PBI->getOperand());
124124

@@ -133,15 +133,23 @@ cleanupCalleeValue(SILValue CalleeValue, ArrayRef<SILValue> CaptureArgs,
133133
for (Operand *ABIUse : ABI->getUses()) {
134134
if (SRI == nullptr && isa<StrongReleaseInst>(ABIUse->getUser())) {
135135
SRI = cast<StrongReleaseInst>(ABIUse->getUser());
136-
} else if (ABIUse->getUser() != PBI)
137-
return;
136+
continue;
137+
}
138+
139+
if (ABIUse->getUser() == PBI)
140+
continue;
141+
142+
return;
138143
}
144+
139145
StoreInst *SI = nullptr;
140146
for (Operand *PBIUse : PBI->getUses()) {
141147
if (SI == nullptr && isa<StoreInst>(PBIUse->getUser())) {
142148
SI = cast<StoreInst>(PBIUse->getUser());
143-
} else
144-
return;
149+
continue;
150+
}
151+
152+
return;
145153
}
146154

147155
// If we found a store, record its source and erase it.
@@ -183,7 +191,7 @@ cleanupCalleeValue(SILValue CalleeValue, ArrayRef<SILValue> CaptureArgs,
183191
CalleeValue = Callee;
184192
}
185193

186-
if (FunctionRefInst *FRI = dyn_cast<FunctionRefInst>(CalleeValue)) {
194+
if (auto *FRI = dyn_cast<FunctionRefInst>(CalleeValue)) {
187195
if (!FRI->use_empty())
188196
return;
189197
FRI->eraseFromParent();

0 commit comments

Comments
 (0)