diff options
author | Michael Gottesman <mgottesman@apple.com> | 2015-03-06 00:34:42 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2015-03-06 00:34:42 +0000 |
commit | 6080596328e6d37e170115214d33523f2b7c4846 (patch) | |
tree | e7af47d0aa43273b5e1450d1d0f2ed2c1dabe1bf /llvm/lib/Transforms/ObjCARC/PtrState.cpp | |
parent | 4eae396ae9eb37ad4e7f5648069110d6a08f5f52 (diff) | |
download | bcm5719-llvm-6080596328e6d37e170115214d33523f2b7c4846.tar.gz bcm5719-llvm-6080596328e6d37e170115214d33523f2b7c4846.zip |
[objc-arc] Move the checking of whether or not we can match onto PtrStates and out of the main dataflow.
These refactored computations check whether or not we are at a stage
of the sequence where we can perform a match. This patch moves the
computation out of the main dataflow and into
{BottomUp,TopDown}PtrState.
llvm-svn: 231439
Diffstat (limited to 'llvm/lib/Transforms/ObjCARC/PtrState.cpp')
-rw-r--r-- | llvm/lib/Transforms/ObjCARC/PtrState.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/ObjCARC/PtrState.cpp b/llvm/lib/Transforms/ObjCARC/PtrState.cpp index db4a81650e4..9a82f36c5c4 100644 --- a/llvm/lib/Transforms/ObjCARC/PtrState.cpp +++ b/llvm/lib/Transforms/ObjCARC/PtrState.cpp @@ -164,6 +164,29 @@ bool BottomUpPtrState::InitBottomUp(ARCMDKindCache &Cache, Instruction *I) { return NestingDetected; } +bool BottomUpPtrState::MatchWithRetain() { + SetKnownPositiveRefCount(); + + Sequence OldSeq = GetSeq(); + switch (OldSeq) { + case S_Stop: + case S_Release: + case S_MovableRelease: + case S_Use: + // If OldSeq is not S_Use or OldSeq is S_Use and we are tracking an + // imprecise release, clear our reverse insertion points. + if (OldSeq != S_Use || IsTrackingImpreciseReleases()) + ClearReverseInsertPts(); + // FALL THROUGH + case S_CanRelease: + return true; + case S_None: + return false; + case S_Retain: + llvm_unreachable("bottom-up pointer in retain state!"); + } +} + bool TopDownPtrState::InitTopDown(ARCInstKind Kind, Instruction *I) { bool NestingDetected = false; // Don't do retain+release tracking for ARCInstKind::RetainRV, because @@ -188,3 +211,30 @@ bool TopDownPtrState::InitTopDown(ARCInstKind Kind, Instruction *I) { SetKnownPositiveRefCount(); return NestingDetected; } + +bool TopDownPtrState::MatchWithRelease(ARCMDKindCache &Cache, + Instruction *Release) { + ClearKnownPositiveRefCount(); + + Sequence OldSeq = GetSeq(); + + MDNode *ReleaseMetadata = Release->getMetadata(Cache.ImpreciseReleaseMDKind); + + switch (OldSeq) { + case S_Retain: + case S_CanRelease: + if (OldSeq == S_Retain || ReleaseMetadata != nullptr) + ClearReverseInsertPts(); + // FALL THROUGH + case S_Use: + SetReleaseMetadata(ReleaseMetadata); + SetTailCallRelease(cast<CallInst>(Release)->isTailCall()); + return true; + case S_None: + return false; + case S_Stop: + case S_Release: + case S_MovableRelease: + llvm_unreachable("top-down pointer in bottom up state!"); + } +} |