@@ -3541,24 +3541,24 @@ struct CachedReachabilityAA : public BaseTy {
3541
3541
// / See AbstractAttribute::updateImpl(...).
3542
3542
ChangeStatus updateImpl (Attributor &A) override {
3543
3543
ChangeStatus Changed = ChangeStatus::UNCHANGED;
3544
- InUpdate = true ;
3545
3544
for (unsigned u = 0 , e = QueryVector.size (); u < e; ++u) {
3546
3545
RQITy *RQI = QueryVector[u];
3547
- if (RQI->Result == RQITy::Reachable::No && isReachableImpl (A, *RQI))
3546
+ if (RQI->Result == RQITy::Reachable::No &&
3547
+ isReachableImpl (A, *RQI, /* IsTemporaryRQI=*/ false ))
3548
3548
Changed = ChangeStatus::CHANGED;
3549
3549
}
3550
- InUpdate = false ;
3551
3550
return Changed;
3552
3551
}
3553
3552
3554
- virtual bool isReachableImpl (Attributor &A, RQITy &RQI) = 0;
3553
+ virtual bool isReachableImpl (Attributor &A, RQITy &RQI,
3554
+ bool IsTemporaryRQI) = 0;
3555
3555
3556
3556
bool rememberResult (Attributor &A, typename RQITy::Reachable Result,
3557
- RQITy &RQI, bool UsedExclusionSet) {
3557
+ RQITy &RQI, bool UsedExclusionSet, bool IsTemporaryRQI ) {
3558
3558
RQI.Result = Result;
3559
3559
3560
3560
// Remove the temporary RQI from the cache.
3561
- if (!InUpdate )
3561
+ if (IsTemporaryRQI )
3562
3562
QueryCache.erase (&RQI);
3563
3563
3564
3564
// Insert a plain RQI (w/o exclusion set) if that makes sense. Two options:
@@ -3576,7 +3576,7 @@ struct CachedReachabilityAA : public BaseTy {
3576
3576
}
3577
3577
3578
3578
// Check if we need to insert a new permanent RQI with the exclusion set.
3579
- if (!InUpdate && Result != RQITy::Reachable::Yes && UsedExclusionSet) {
3579
+ if (IsTemporaryRQI && Result != RQITy::Reachable::Yes && UsedExclusionSet) {
3580
3580
assert ((!RQI.ExclusionSet || !RQI.ExclusionSet ->empty ()) &&
3581
3581
" Did not expect empty set!" );
3582
3582
RQITy *RQIPtr = new (A.Allocator )
@@ -3588,7 +3588,7 @@ struct CachedReachabilityAA : public BaseTy {
3588
3588
QueryCache.insert (RQIPtr);
3589
3589
}
3590
3590
3591
- if (Result == RQITy::Reachable::No && !InUpdate )
3591
+ if (Result == RQITy::Reachable::No && IsTemporaryRQI )
3592
3592
A.registerForUpdate (*this );
3593
3593
return Result == RQITy::Reachable::Yes;
3594
3594
}
@@ -3629,7 +3629,6 @@ struct CachedReachabilityAA : public BaseTy {
3629
3629
}
3630
3630
3631
3631
private:
3632
- bool InUpdate = false ;
3633
3632
SmallVector<RQITy *> QueryVector;
3634
3633
DenseSet<RQITy *> QueryCache;
3635
3634
};
@@ -3653,7 +3652,8 @@ struct AAIntraFnReachabilityFunction final
3653
3652
RQITy StackRQI (A, From, To, ExclusionSet, false );
3654
3653
typename RQITy::Reachable Result;
3655
3654
if (!NonConstThis->checkQueryCache (A, StackRQI, Result))
3656
- return NonConstThis->isReachableImpl (A, StackRQI);
3655
+ return NonConstThis->isReachableImpl (A, StackRQI,
3656
+ /* IsTemporaryRQI=*/ true );
3657
3657
return Result == RQITy::Reachable::Yes;
3658
3658
}
3659
3659
@@ -3678,7 +3678,8 @@ struct AAIntraFnReachabilityFunction final
3678
3678
return Base::updateImpl (A);
3679
3679
}
3680
3680
3681
- bool isReachableImpl (Attributor &A, RQITy &RQI) override {
3681
+ bool isReachableImpl (Attributor &A, RQITy &RQI,
3682
+ bool IsTemporaryRQI) override {
3682
3683
const Instruction *Origin = RQI.From ;
3683
3684
bool UsedExclusionSet = false ;
3684
3685
@@ -3704,12 +3705,14 @@ struct AAIntraFnReachabilityFunction final
3704
3705
// possible.
3705
3706
if (FromBB == ToBB &&
3706
3707
WillReachInBlock (*RQI.From , *RQI.To , RQI.ExclusionSet ))
3707
- return rememberResult (A, RQITy::Reachable::Yes, RQI, UsedExclusionSet);
3708
+ return rememberResult (A, RQITy::Reachable::Yes, RQI, UsedExclusionSet,
3709
+ IsTemporaryRQI);
3708
3710
3709
3711
// Check if reaching the ToBB block is sufficient or if even that would not
3710
3712
// ensure reaching the target. In the latter case we are done.
3711
3713
if (!WillReachInBlock (ToBB->front (), *RQI.To , RQI.ExclusionSet ))
3712
- return rememberResult (A, RQITy::Reachable::No, RQI, UsedExclusionSet);
3714
+ return rememberResult (A, RQITy::Reachable::No, RQI, UsedExclusionSet,
3715
+ IsTemporaryRQI);
3713
3716
3714
3717
const Function *Fn = FromBB->getParent ();
3715
3718
SmallPtrSet<const BasicBlock *, 16 > ExclusionBlocks;
@@ -3722,13 +3725,14 @@ struct AAIntraFnReachabilityFunction final
3722
3725
if (ExclusionBlocks.count (FromBB) &&
3723
3726
!WillReachInBlock (*RQI.From , *FromBB->getTerminator (),
3724
3727
RQI.ExclusionSet ))
3725
- return rememberResult (A, RQITy::Reachable::No, RQI, true );
3728
+ return rememberResult (A, RQITy::Reachable::No, RQI, true , IsTemporaryRQI );
3726
3729
3727
3730
auto *LivenessAA =
3728
3731
A.getAAFor <AAIsDead>(*this , getIRPosition (), DepClassTy::OPTIONAL);
3729
3732
if (LivenessAA && LivenessAA->isAssumedDead (ToBB)) {
3730
3733
DeadBlocks.insert (ToBB);
3731
- return rememberResult (A, RQITy::Reachable::No, RQI, UsedExclusionSet);
3734
+ return rememberResult (A, RQITy::Reachable::No, RQI, UsedExclusionSet,
3735
+ IsTemporaryRQI);
3732
3736
}
3733
3737
3734
3738
SmallPtrSet<const BasicBlock *, 16 > Visited;
@@ -3747,11 +3751,11 @@ struct AAIntraFnReachabilityFunction final
3747
3751
}
3748
3752
// We checked before if we just need to reach the ToBB block.
3749
3753
if (SuccBB == ToBB)
3750
- return rememberResult (A, RQITy::Reachable::Yes, RQI,
3751
- UsedExclusionSet );
3754
+ return rememberResult (A, RQITy::Reachable::Yes, RQI, UsedExclusionSet,
3755
+ IsTemporaryRQI );
3752
3756
if (DT && ExclusionBlocks.empty () && DT->dominates (BB, ToBB))
3753
- return rememberResult (A, RQITy::Reachable::Yes, RQI,
3754
- UsedExclusionSet );
3757
+ return rememberResult (A, RQITy::Reachable::Yes, RQI, UsedExclusionSet,
3758
+ IsTemporaryRQI );
3755
3759
3756
3760
if (ExclusionBlocks.count (SuccBB)) {
3757
3761
UsedExclusionSet = true ;
@@ -3762,7 +3766,8 @@ struct AAIntraFnReachabilityFunction final
3762
3766
}
3763
3767
3764
3768
DeadEdges.insert (LocalDeadEdges.begin (), LocalDeadEdges.end ());
3765
- return rememberResult (A, RQITy::Reachable::No, RQI, UsedExclusionSet);
3769
+ return rememberResult (A, RQITy::Reachable::No, RQI, UsedExclusionSet,
3770
+ IsTemporaryRQI);
3766
3771
}
3767
3772
3768
3773
// / See AbstractAttribute::trackStatistics()
@@ -10646,22 +10651,19 @@ struct AAInterFnReachabilityFunction
10646
10651
RQITy StackRQI (A, From, To, ExclusionSet, false );
10647
10652
typename RQITy::Reachable Result;
10648
10653
if (!NonConstThis->checkQueryCache (A, StackRQI, Result))
10649
- return NonConstThis->isReachableImpl (A, StackRQI);
10654
+ return NonConstThis->isReachableImpl (A, StackRQI,
10655
+ /* IsTemporaryRQI=*/ true );
10650
10656
return Result == RQITy::Reachable::Yes;
10651
10657
}
10652
10658
10653
- bool isReachableImpl (Attributor &A, RQITy &RQI) override {
10654
- return isReachableImpl (A, RQI, nullptr );
10655
- }
10656
-
10657
10659
bool isReachableImpl (Attributor &A, RQITy &RQI,
10658
- SmallPtrSet<const Function *, 16 > *Visited) {
10659
-
10660
+ bool IsTemporaryRQI) override {
10660
10661
const Instruction *EntryI =
10661
10662
&RQI.From ->getFunction ()->getEntryBlock ().front ();
10662
10663
if (EntryI != RQI.From &&
10663
10664
!instructionCanReach (A, *EntryI, *RQI.To , nullptr ))
10664
- return rememberResult (A, RQITy::Reachable::No, RQI, false );
10665
+ return rememberResult (A, RQITy::Reachable::No, RQI, false ,
10666
+ IsTemporaryRQI);
10665
10667
10666
10668
auto CheckReachableCallBase = [&](CallBase *CB) {
10667
10669
auto *CBEdges = A.getAAFor <AACallEdges>(
@@ -10721,9 +10723,11 @@ struct AAInterFnReachabilityFunction
10721
10723
if (!A.checkForAllCallLikeInstructions (CheckCallBase, *this ,
10722
10724
UsedAssumedInformation,
10723
10725
/* CheckBBLivenessOnly */ true ))
10724
- return rememberResult (A, RQITy::Reachable::Yes, RQI, UsedExclusionSet);
10726
+ return rememberResult (A, RQITy::Reachable::Yes, RQI, UsedExclusionSet,
10727
+ IsTemporaryRQI);
10725
10728
10726
- return rememberResult (A, RQITy::Reachable::No, RQI, UsedExclusionSet);
10729
+ return rememberResult (A, RQITy::Reachable::No, RQI, UsedExclusionSet,
10730
+ IsTemporaryRQI);
10727
10731
}
10728
10732
10729
10733
void trackStatistics () const override {}
0 commit comments