[objc-arc-opts] Encapsulated PtrState.RRI.{Calls,ReverseInsertPts} into several methods on PtrState.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184586 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Michael Gottesman 2013-06-21 19:44:27 +00:00
parent 93702a3b07
commit 72507101f7

View File

@ -599,6 +599,22 @@ namespace {
} }
void Merge(const PtrState &Other, bool TopDown); void Merge(const PtrState &Other, bool TopDown);
void InsertCall(Instruction *I) {
RRI.Calls.insert(I);
}
void InsertReverseInsertPt(Instruction *I) {
RRI.ReverseInsertPts.insert(I);
}
void ClearReverseInsertPts() {
RRI.ReverseInsertPts.clear();
}
bool HasReverseInsertPts() const {
return !RRI.ReverseInsertPts.empty();
}
}; };
} }
@ -1944,7 +1960,7 @@ ObjCARCOpt::VisitInstructionBottomUp(Instruction *Inst,
S.SetReleaseMetadata(ReleaseMetadata); S.SetReleaseMetadata(ReleaseMetadata);
S.SetKnownSafe(S.HasKnownPositiveRefCount()); S.SetKnownSafe(S.HasKnownPositiveRefCount());
S.SetTailCallRelease(cast<CallInst>(Inst)->isTailCall()); S.SetTailCallRelease(cast<CallInst>(Inst)->isTailCall());
S.RRI.Calls.insert(Inst); S.InsertCall(Inst);
S.SetKnownPositiveRefCount(); S.SetKnownPositiveRefCount();
break; break;
} }
@ -1969,7 +1985,7 @@ ObjCARCOpt::VisitInstructionBottomUp(Instruction *Inst,
// If OldSeq is not S_Use or OldSeq is S_Use and we are tracking an // If OldSeq is not S_Use or OldSeq is S_Use and we are tracking an
// imprecise release, clear our reverse insertion points. // imprecise release, clear our reverse insertion points.
if (OldSeq != S_Use || S.IsTrackingImpreciseReleases()) if (OldSeq != S_Use || S.IsTrackingImpreciseReleases())
S.RRI.ReverseInsertPts.clear(); S.ClearReverseInsertPts();
// FALL THROUGH // FALL THROUGH
case S_CanRelease: case S_CanRelease:
// Don't do retain+release tracking for IC_RetainRV, because it's // Don't do retain+release tracking for IC_RetainRV, because it's
@ -2059,14 +2075,14 @@ ObjCARCOpt::VisitInstructionBottomUp(Instruction *Inst,
if (CanUse(Inst, Ptr, PA, Class)) { if (CanUse(Inst, Ptr, PA, Class)) {
DEBUG(dbgs() << "CanUse: Seq: " << Seq << "; " << *Ptr DEBUG(dbgs() << "CanUse: Seq: " << Seq << "; " << *Ptr
<< "\n"); << "\n");
assert(S.RRI.ReverseInsertPts.empty()); assert(!S.HasReverseInsertPts());
// If this is an invoke instruction, we're scanning it as part of // If this is an invoke instruction, we're scanning it as part of
// one of its successor blocks, since we can't insert code after it // one of its successor blocks, since we can't insert code after it
// in its own block, and we don't want to split critical edges. // in its own block, and we don't want to split critical edges.
if (isa<InvokeInst>(Inst)) if (isa<InvokeInst>(Inst))
S.RRI.ReverseInsertPts.insert(BB->getFirstInsertionPt()); S.InsertReverseInsertPt(BB->getFirstInsertionPt());
else else
S.RRI.ReverseInsertPts.insert(llvm::next(BasicBlock::iterator(Inst))); S.InsertReverseInsertPt(llvm::next(BasicBlock::iterator(Inst)));
S.SetSeq(S_Use); S.SetSeq(S_Use);
ANNOTATE_BOTTOMUP(Inst, Ptr, Seq, S_Use); ANNOTATE_BOTTOMUP(Inst, Ptr, Seq, S_Use);
} else if (Seq == S_Release && IsUser(Class)) { } else if (Seq == S_Release && IsUser(Class)) {
@ -2075,12 +2091,12 @@ ObjCARCOpt::VisitInstructionBottomUp(Instruction *Inst,
// Non-movable releases depend on any possible objc pointer use. // Non-movable releases depend on any possible objc pointer use.
S.SetSeq(S_Stop); S.SetSeq(S_Stop);
ANNOTATE_BOTTOMUP(Inst, Ptr, S_Release, S_Stop); ANNOTATE_BOTTOMUP(Inst, Ptr, S_Release, S_Stop);
assert(S.RRI.ReverseInsertPts.empty()); assert(!S.HasReverseInsertPts());
// As above; handle invoke specially. // As above; handle invoke specially.
if (isa<InvokeInst>(Inst)) if (isa<InvokeInst>(Inst))
S.RRI.ReverseInsertPts.insert(BB->getFirstInsertionPt()); S.InsertReverseInsertPt(BB->getFirstInsertionPt());
else else
S.RRI.ReverseInsertPts.insert(llvm::next(BasicBlock::iterator(Inst))); S.InsertReverseInsertPt(llvm::next(BasicBlock::iterator(Inst)));
} }
break; break;
case S_Stop: case S_Stop:
@ -2201,7 +2217,7 @@ ObjCARCOpt::VisitInstructionTopDown(Instruction *Inst,
ANNOTATE_TOPDOWN(Inst, Arg, S.GetSeq(), S_Retain); ANNOTATE_TOPDOWN(Inst, Arg, S.GetSeq(), S_Retain);
S.ResetSequenceProgress(S_Retain); S.ResetSequenceProgress(S_Retain);
S.SetKnownSafe(S.HasKnownPositiveRefCount()); S.SetKnownSafe(S.HasKnownPositiveRefCount());
S.RRI.Calls.insert(Inst); S.InsertCall(Inst);
} }
S.SetKnownPositiveRefCount(); S.SetKnownPositiveRefCount();
@ -2224,7 +2240,7 @@ ObjCARCOpt::VisitInstructionTopDown(Instruction *Inst,
case S_Retain: case S_Retain:
case S_CanRelease: case S_CanRelease:
if (OldSeq == S_Retain || ReleaseMetadata != 0) if (OldSeq == S_Retain || ReleaseMetadata != 0)
S.RRI.ReverseInsertPts.clear(); S.ClearReverseInsertPts();
// FALL THROUGH // FALL THROUGH
case S_Use: case S_Use:
S.SetReleaseMetadata(ReleaseMetadata); S.SetReleaseMetadata(ReleaseMetadata);
@ -2273,8 +2289,8 @@ ObjCARCOpt::VisitInstructionTopDown(Instruction *Inst,
case S_Retain: case S_Retain:
S.SetSeq(S_CanRelease); S.SetSeq(S_CanRelease);
ANNOTATE_TOPDOWN(Inst, Ptr, Seq, S_CanRelease); ANNOTATE_TOPDOWN(Inst, Ptr, Seq, S_CanRelease);
assert(S.RRI.ReverseInsertPts.empty()); assert(!S.HasReverseInsertPts());
S.RRI.ReverseInsertPts.insert(Inst); S.InsertReverseInsertPt(Inst);
// One call can't cause a transition from S_Retain to S_CanRelease // One call can't cause a transition from S_Retain to S_CanRelease
// and S_CanRelease to S_Use. If we've made the first transition, // and S_CanRelease to S_Use. If we've made the first transition,