diff options
author | Michael Gottesman <mgottesman@apple.com> | 2015-02-20 00:02:45 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2015-02-20 00:02:45 +0000 |
commit | 5ab64de62bbea1a02ae611a50ec443cbccd72e7b (patch) | |
tree | 5a398c8e1259197a506602a861fb3e29936471f3 /llvm/lib/Transforms/ObjCARC/ARCInstKind.cpp | |
parent | c50b75c75c3766a81701b6cfb5b381a9388b5130 (diff) | |
download | bcm5719-llvm-5ab64de62bbea1a02ae611a50ec443cbccd72e7b.tar.gz bcm5719-llvm-5ab64de62bbea1a02ae611a50ec443cbccd72e7b.zip |
[objc-arc] Add the predicate CanDecrementRefCount.
This is different from CanAlterRefCount since CanDecrementRefCount is
attempting to prove specifically whether or not an instruction can
decrement instead of the more general question of whether it can
decrement or increment.
llvm-svn: 229936
Diffstat (limited to 'llvm/lib/Transforms/ObjCARC/ARCInstKind.cpp')
-rw-r--r-- | llvm/lib/Transforms/ObjCARC/ARCInstKind.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/ObjCARC/ARCInstKind.cpp b/llvm/lib/Transforms/ObjCARC/ARCInstKind.cpp index e086e1f5239..f1e9dcecfc8 100644 --- a/llvm/lib/Transforms/ObjCARC/ARCInstKind.cpp +++ b/llvm/lib/Transforms/ObjCARC/ARCInstKind.cpp @@ -605,3 +605,41 @@ bool llvm::objcarc::CanInterruptRV(ARCInstKind Class) { } llvm_unreachable("covered switch isn't covered?"); } + +bool llvm::objcarc::CanDecrementRefCount(ARCInstKind Kind) { + switch (Kind) { + case ARCInstKind::Retain: + case ARCInstKind::RetainRV: + case ARCInstKind::Autorelease: + case ARCInstKind::AutoreleaseRV: + case ARCInstKind::NoopCast: + case ARCInstKind::FusedRetainAutorelease: + case ARCInstKind::FusedRetainAutoreleaseRV: + case ARCInstKind::IntrinsicUser: + case ARCInstKind::User: + case ARCInstKind::None: + return false; + + // The cases below are conservative. + + // RetainBlock can result in user defined copy constructors being called + // implying releases may occur. + case ARCInstKind::RetainBlock: + case ARCInstKind::Release: + case ARCInstKind::AutoreleasepoolPush: + case ARCInstKind::AutoreleasepoolPop: + case ARCInstKind::LoadWeakRetained: + case ARCInstKind::StoreWeak: + case ARCInstKind::InitWeak: + case ARCInstKind::LoadWeak: + case ARCInstKind::MoveWeak: + case ARCInstKind::CopyWeak: + case ARCInstKind::DestroyWeak: + case ARCInstKind::StoreStrong: + case ARCInstKind::CallOrUser: + case ARCInstKind::Call: + return true; + } + + llvm_unreachable("covered switch isn't covered?"); +} |