@@ -1126,7 +1126,6 @@ void ObjCARCOpt::OptimizeIndividualCallImpl(
1126
1126
continue ;
1127
1127
1128
1128
SmallPtrSet<Instruction *, 4 > DependingInstructions;
1129
- SmallPtrSet<const BasicBlock *, 4 > Visited;
1130
1129
1131
1130
// Check that there is nothing that cares about the reference
1132
1131
// count between the call and the phi.
@@ -1139,12 +1138,12 @@ void ObjCARCOpt::OptimizeIndividualCallImpl(
1139
1138
// These can't be moved across things that care about the retain
1140
1139
// count.
1141
1140
FindDependencies (NeedsPositiveRetainCount, Arg, Inst->getParent (), Inst,
1142
- DependingInstructions, Visited, PA);
1141
+ DependingInstructions, PA);
1143
1142
break ;
1144
1143
case ARCInstKind::Autorelease:
1145
1144
// These can't be moved across autorelease pool scope boundaries.
1146
1145
FindDependencies (AutoreleasePoolBoundary, Arg, Inst->getParent (), Inst,
1147
- DependingInstructions, Visited, PA);
1146
+ DependingInstructions, PA);
1148
1147
break ;
1149
1148
case ARCInstKind::ClaimRV:
1150
1149
case ARCInstKind::RetainRV:
@@ -2237,10 +2236,9 @@ bool ObjCARCOpt::OptimizeSequences(Function &F) {
2237
2236
static bool
2238
2237
HasSafePathToPredecessorCall (const Value *Arg, Instruction *Retain,
2239
2238
SmallPtrSetImpl<Instruction *> &DepInsts,
2240
- SmallPtrSetImpl<const BasicBlock *> &Visited,
2241
2239
ProvenanceAnalysis &PA) {
2242
2240
FindDependencies (CanChangeRetainCount, Arg, Retain->getParent (), Retain,
2243
- DepInsts, Visited, PA);
2241
+ DepInsts, PA);
2244
2242
if (DepInsts.size () != 1 )
2245
2243
return false ;
2246
2244
@@ -2261,11 +2259,9 @@ HasSafePathToPredecessorCall(const Value *Arg, Instruction *Retain,
2261
2259
static CallInst *
2262
2260
FindPredecessorRetainWithSafePath (const Value *Arg, BasicBlock *BB,
2263
2261
Instruction *Autorelease,
2264
- SmallPtrSetImpl<const BasicBlock *> &Visited,
2265
2262
ProvenanceAnalysis &PA) {
2266
2263
SmallPtrSet<Instruction *, 4 > DepInsts;
2267
- FindDependencies (CanChangeRetainCount, Arg,
2268
- BB, Autorelease, DepInsts, Visited, PA);
2264
+ FindDependencies (CanChangeRetainCount, Arg, BB, Autorelease, DepInsts, PA);
2269
2265
if (DepInsts.size () != 1 )
2270
2266
return nullptr ;
2271
2267
@@ -2286,11 +2282,9 @@ FindPredecessorRetainWithSafePath(const Value *Arg, BasicBlock *BB,
2286
2282
static CallInst *
2287
2283
FindPredecessorAutoreleaseWithSafePath (const Value *Arg, BasicBlock *BB,
2288
2284
ReturnInst *Ret,
2289
- SmallPtrSetImpl<const BasicBlock *> &V,
2290
2285
ProvenanceAnalysis &PA) {
2291
2286
SmallPtrSet<Instruction *, 4 > DepInsts;
2292
- FindDependencies (NeedsPositiveRetainCount, Arg,
2293
- BB, Ret, DepInsts, V, PA);
2287
+ FindDependencies (NeedsPositiveRetainCount, Arg, BB, Ret, DepInsts, PA);
2294
2288
if (DepInsts.size () != 1 )
2295
2289
return nullptr ;
2296
2290
@@ -2321,7 +2315,6 @@ void ObjCARCOpt::OptimizeReturns(Function &F) {
2321
2315
LLVM_DEBUG (dbgs () << " \n == ObjCARCOpt::OptimizeReturns ==\n " );
2322
2316
2323
2317
SmallPtrSet<Instruction *, 4 > DependingInstructions;
2324
- SmallPtrSet<const BasicBlock *, 4 > Visited;
2325
2318
for (BasicBlock &BB: F) {
2326
2319
ReturnInst *Ret = dyn_cast<ReturnInst>(&BB.back ());
2327
2320
if (!Ret)
@@ -2335,37 +2328,32 @@ void ObjCARCOpt::OptimizeReturns(Function &F) {
2335
2328
// dependent on Arg such that there are no instructions dependent on Arg
2336
2329
// that need a positive ref count in between the autorelease and Ret.
2337
2330
CallInst *Autorelease =
2338
- FindPredecessorAutoreleaseWithSafePath (Arg, &BB, Ret, Visited, PA);
2339
- Visited.clear ();
2331
+ FindPredecessorAutoreleaseWithSafePath (Arg, &BB, Ret, PA);
2340
2332
2341
2333
if (!Autorelease)
2342
2334
continue ;
2343
2335
2344
2336
CallInst *Retain = FindPredecessorRetainWithSafePath (
2345
- Arg, Autorelease->getParent (), Autorelease, Visited, PA);
2346
- Visited.clear ();
2337
+ Arg, Autorelease->getParent (), Autorelease, PA);
2347
2338
2348
2339
if (!Retain)
2349
2340
continue ;
2350
2341
2351
2342
// Check that there is nothing that can affect the reference count
2352
2343
// between the retain and the call. Note that Retain need not be in BB.
2353
- bool HasSafePathToCall = HasSafePathToPredecessorCall (Arg, Retain,
2354
- DependingInstructions,
2355
- Visited, PA);
2344
+ bool HasSafePathToCall =
2345
+ HasSafePathToPredecessorCall (Arg, Retain, DependingInstructions, PA);
2356
2346
2357
2347
// Don't remove retainRV/autoreleaseRV pairs if the call isn't a tail call.
2358
2348
if (HasSafePathToCall &&
2359
2349
GetBasicARCInstKind (Retain) == ARCInstKind::RetainRV &&
2360
2350
GetBasicARCInstKind (Autorelease) == ARCInstKind::AutoreleaseRV &&
2361
2351
!cast<CallInst>(*DependingInstructions.begin ())->isTailCall ()) {
2362
2352
DependingInstructions.clear ();
2363
- Visited.clear ();
2364
2353
continue ;
2365
2354
}
2366
2355
2367
2356
DependingInstructions.clear ();
2368
- Visited.clear ();
2369
2357
2370
2358
if (!HasSafePathToCall)
2371
2359
continue ;
0 commit comments