@@ -66,15 +66,10 @@ class MemoryBehaviorVisitor
66
66
// / The SILType of the value.
67
67
Optional<SILType> TypedAccessTy;
68
68
69
- // / Should we treat instructions that increment ref counts as None instead of
70
- // / MayHaveSideEffects.
71
- RetainObserveKind InspectionMode;
72
-
73
69
public:
74
70
MemoryBehaviorVisitor (AliasAnalysis *AA, SideEffectAnalysis *SEA,
75
- EscapeAnalysis *EA, SILValue V,
76
- RetainObserveKind IgnoreRefCountIncs)
77
- : AA(AA), SEA(SEA), EA(EA), V(V), InspectionMode(IgnoreRefCountIncs) {}
71
+ EscapeAnalysis *EA, SILValue V)
72
+ : AA(AA), SEA(SEA), EA(EA), V(V) {}
78
73
79
74
SILType getValueTBAAType () {
80
75
if (!TypedAccessTy)
@@ -223,9 +218,7 @@ class MemoryBehaviorVisitor
223
218
// memory this will be unnecessary.
224
219
#define REFCOUNTINC_MEMBEHAVIOR_INST (Name ) \
225
220
MemBehavior visit##Name(Name *I) { \
226
- if (InspectionMode == RetainObserveKind::IgnoreRetains) \
227
- return MemBehavior::None; \
228
- return I->getMemoryBehavior (); \
221
+ return MemBehavior::None; \
229
222
}
230
223
REFCOUNTINC_MEMBEHAVIOR_INST (StrongRetainInst)
231
224
REFCOUNTINC_MEMBEHAVIOR_INST (RetainValueInst)
@@ -364,19 +357,15 @@ MemBehavior MemoryBehaviorVisitor::visitApplyInst(ApplyInst *AI) {
364
357
// one the parameters in the function call is @in_guaranteed of V, ie. the
365
358
// callee isn't allowed to modify it.
366
359
Behavior = MemBehavior::MayRead;
367
- } else if (ApplyEffects.mayReadRC () ||
368
- (InspectionMode == RetainObserveKind::ObserveRetains &&
369
- ApplyEffects.mayAllocObjects ())) {
370
- Behavior = MemBehavior::MayHaveSideEffects;
371
360
} else {
372
361
auto &GlobalEffects = ApplyEffects.getGlobalEffects ();
373
- Behavior = GlobalEffects.getMemBehavior (InspectionMode );
362
+ Behavior = GlobalEffects.getMemBehavior (RetainObserveKind::IgnoreRetains );
374
363
375
364
// Check all parameter effects.
376
365
for (unsigned Idx = 0 , End = AI->getNumArguments ();
377
366
Idx < End && Behavior < MemBehavior::MayHaveSideEffects; ++Idx) {
378
367
auto &ArgEffect = ApplyEffects.getParameterEffects ()[Idx];
379
- auto ArgBehavior = ArgEffect.getMemBehavior (InspectionMode );
368
+ auto ArgBehavior = ArgEffect.getMemBehavior (RetainObserveKind::IgnoreRetains );
380
369
if (ArgEffect.mayRelease ()) {
381
370
Behavior = MemBehavior::MayHaveSideEffects;
382
371
break ;
@@ -442,9 +431,8 @@ visitBeginCOWMutationInst(BeginCOWMutationInst *BCMI) {
442
431
// ===----------------------------------------------------------------------===//
443
432
444
433
MemBehavior
445
- AliasAnalysis::computeMemoryBehavior (SILInstruction *Inst, SILValue V,
446
- RetainObserveKind InspectionMode) {
447
- MemBehaviorKeyTy Key = toMemoryBehaviorKey (Inst, V, InspectionMode);
434
+ AliasAnalysis::computeMemoryBehavior (SILInstruction *Inst, SILValue V) {
435
+ MemBehaviorKeyTy Key = toMemoryBehaviorKey (Inst, V);
448
436
// Check if we've already computed this result.
449
437
auto It = MemoryBehaviorCache.find (Key);
450
438
if (It != MemoryBehaviorCache.end ()) {
@@ -457,27 +445,25 @@ AliasAnalysis::computeMemoryBehavior(SILInstruction *Inst, SILValue V,
457
445
MemoryBehaviorNodeToIndex.clear ();
458
446
459
447
// Key is no longer valid as we cleared the MemoryBehaviorNodeToIndex.
460
- Key = toMemoryBehaviorKey (Inst, V, InspectionMode );
448
+ Key = toMemoryBehaviorKey (Inst, V);
461
449
}
462
450
463
451
// Calculate the aliasing result and store it in the cache.
464
- auto Result = computeMemoryBehaviorInner (Inst, V, InspectionMode );
452
+ auto Result = computeMemoryBehaviorInner (Inst, V);
465
453
MemoryBehaviorCache[Key] = Result;
466
454
return Result;
467
455
}
468
456
469
457
MemBehavior
470
- AliasAnalysis::computeMemoryBehaviorInner (SILInstruction *Inst, SILValue V,
471
- RetainObserveKind InspectionMode) {
458
+ AliasAnalysis::computeMemoryBehaviorInner (SILInstruction *Inst, SILValue V) {
472
459
LLVM_DEBUG (llvm::dbgs () << " GET MEMORY BEHAVIOR FOR:\n " << *Inst << " "
473
460
<< *V);
474
461
assert (SEA && " SideEffectsAnalysis must be initialized!" );
475
- return MemoryBehaviorVisitor (this , SEA, EA, V, InspectionMode ).visit (Inst);
462
+ return MemoryBehaviorVisitor (this , SEA, EA, V).visit (Inst);
476
463
}
477
464
478
465
MemBehaviorKeyTy AliasAnalysis::toMemoryBehaviorKey (SILInstruction *V1,
479
- SILValue V2,
480
- RetainObserveKind M) {
466
+ SILValue V2) {
481
467
size_t idx1 =
482
468
MemoryBehaviorNodeToIndex.getIndex (V1->getRepresentativeSILNodeInObject ());
483
469
assert (idx1 != std::numeric_limits<size_t >::max () &&
@@ -486,5 +472,5 @@ MemBehaviorKeyTy AliasAnalysis::toMemoryBehaviorKey(SILInstruction *V1,
486
472
V2->getRepresentativeSILNodeInObject ());
487
473
assert (idx2 != std::numeric_limits<size_t >::max () &&
488
474
" ~0 index reserved for empty/tombstone keys" );
489
- return {idx1, idx2, M };
475
+ return {idx1, idx2};
490
476
}
0 commit comments