@@ -110,15 +110,15 @@ cleanupCalleeValue(SILValue CalleeValue, ArrayRef<SILValue> CaptureArgs,
110
110
ArrayRef<SILValue> FullArgs) {
111
111
SmallVector<SILInstruction*, 16 > InstsToDelete;
112
112
for (SILValue V : FullArgs) {
113
- if (SILInstruction *I = dyn_cast<SILInstruction>(V))
113
+ if (auto *I = dyn_cast<SILInstruction>(V))
114
114
if (I != CalleeValue &&
115
115
isInstructionTriviallyDead (I))
116
116
InstsToDelete.push_back (I);
117
117
}
118
118
recursivelyDeleteTriviallyDeadInstructions (InstsToDelete, true );
119
119
120
120
// 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)) {
122
122
auto *PBI = cast<ProjectBoxInst>(LI->getOperand ());
123
123
auto *ABI = cast<AllocBoxInst>(PBI->getOperand ());
124
124
@@ -133,15 +133,23 @@ cleanupCalleeValue(SILValue CalleeValue, ArrayRef<SILValue> CaptureArgs,
133
133
for (Operand *ABIUse : ABI->getUses ()) {
134
134
if (SRI == nullptr && isa<StrongReleaseInst>(ABIUse->getUser ())) {
135
135
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 ;
138
143
}
144
+
139
145
StoreInst *SI = nullptr ;
140
146
for (Operand *PBIUse : PBI->getUses ()) {
141
147
if (SI == nullptr && isa<StoreInst>(PBIUse->getUser ())) {
142
148
SI = cast<StoreInst>(PBIUse->getUser ());
143
- } else
144
- return ;
149
+ continue ;
150
+ }
151
+
152
+ return ;
145
153
}
146
154
147
155
// If we found a store, record its source and erase it.
@@ -183,7 +191,7 @@ cleanupCalleeValue(SILValue CalleeValue, ArrayRef<SILValue> CaptureArgs,
183
191
CalleeValue = Callee;
184
192
}
185
193
186
- if (FunctionRefInst *FRI = dyn_cast<FunctionRefInst>(CalleeValue)) {
194
+ if (auto *FRI = dyn_cast<FunctionRefInst>(CalleeValue)) {
187
195
if (!FRI->use_empty ())
188
196
return ;
189
197
FRI->eraseFromParent ();
0 commit comments