diff options
author | Michael Gottesman <mgottesman@apple.com> | 2015-02-19 19:51:36 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2015-02-19 19:51:36 +0000 |
commit | 2e0e4e07b475953cc21f3b846ce63bb47b4745af (patch) | |
tree | ab6a4b557853e6261c39c58d239ba26bba44a46c /llvm/lib/Transforms/ObjCARC/ARCInstKind.h | |
parent | 6f729fa6754414064160fa4105346bbe1cd46968 (diff) | |
download | bcm5719-llvm-2e0e4e07b475953cc21f3b846ce63bb47b4745af.tar.gz bcm5719-llvm-2e0e4e07b475953cc21f3b846ce63bb47b4745af.zip |
[objc-arc] Convert the bodies of ARCInstKind predicates into covered switches.
This is much better than the previous manner of just using
short-curcuiting booleans from:
1. A "naive" efficiency perspective: we do not have to rely on the
compiler to change the short circuiting boolean operations into a
switch.
2. An understanding perspective by making the implicit behavior of
negative predicates explicit.
3. A maintainability perspective through the covered switch flag making
it easy to know where to update code when adding new ARCInstKinds.
llvm-svn: 229906
Diffstat (limited to 'llvm/lib/Transforms/ObjCARC/ARCInstKind.h')
-rw-r--r-- | llvm/lib/Transforms/ObjCARC/ARCInstKind.h | 67 |
1 files changed, 9 insertions, 58 deletions
diff --git a/llvm/lib/Transforms/ObjCARC/ARCInstKind.h b/llvm/lib/Transforms/ObjCARC/ARCInstKind.h index a09e846cb9c..e8e4fed5489 100644 --- a/llvm/lib/Transforms/ObjCARC/ARCInstKind.h +++ b/llvm/lib/Transforms/ObjCARC/ARCInstKind.h @@ -57,86 +57,37 @@ enum class ARCInstKind { raw_ostream &operator<<(raw_ostream &OS, const ARCInstKind Class); /// \brief Test if the given class is a kind of user. -inline static bool IsUser(ARCInstKind Class) { - return Class == ARCInstKind::User || Class == ARCInstKind::CallOrUser || - Class == ARCInstKind::IntrinsicUser; -} +bool IsUser(ARCInstKind Class); /// \brief Test if the given class is objc_retain or equivalent. -static inline bool IsRetain(ARCInstKind Class) { - return Class == ARCInstKind::Retain || Class == ARCInstKind::RetainRV; -} +bool IsRetain(ARCInstKind Class); /// \brief Test if the given class is objc_autorelease or equivalent. -static inline bool IsAutorelease(ARCInstKind Class) { - return Class == ARCInstKind::Autorelease || - Class == ARCInstKind::AutoreleaseRV; -} +bool IsAutorelease(ARCInstKind Class); /// \brief Test if the given class represents instructions which return their /// argument verbatim. -static inline bool IsForwarding(ARCInstKind Class) { - return Class == ARCInstKind::Retain || Class == ARCInstKind::RetainRV || - Class == ARCInstKind::Autorelease || - Class == ARCInstKind::AutoreleaseRV || Class == ARCInstKind::NoopCast; -} +bool IsForwarding(ARCInstKind Class); /// \brief Test if the given class represents instructions which do nothing if /// passed a null pointer. -static inline bool IsNoopOnNull(ARCInstKind Class) { - return Class == ARCInstKind::Retain || Class == ARCInstKind::RetainRV || - Class == ARCInstKind::Release || Class == ARCInstKind::Autorelease || - Class == ARCInstKind::AutoreleaseRV || - Class == ARCInstKind::RetainBlock; -} +bool IsNoopOnNull(ARCInstKind Class); /// \brief Test if the given class represents instructions which are always safe /// to mark with the "tail" keyword. -static inline bool IsAlwaysTail(ARCInstKind Class) { - // ARCInstKind::RetainBlock may be given a stack argument. - return Class == ARCInstKind::Retain || Class == ARCInstKind::RetainRV || - Class == ARCInstKind::AutoreleaseRV; -} +bool IsAlwaysTail(ARCInstKind Class); /// \brief Test if the given class represents instructions which are never safe /// to mark with the "tail" keyword. -static inline bool IsNeverTail(ARCInstKind Class) { - /// It is never safe to tail call objc_autorelease since by tail calling - /// objc_autorelease, we also tail call -[NSObject autorelease] which supports - /// fast autoreleasing causing our object to be potentially reclaimed from the - /// autorelease pool which violates the semantics of __autoreleasing types in - /// ARC. - return Class == ARCInstKind::Autorelease; -} +bool IsNeverTail(ARCInstKind Class); /// \brief Test if the given class represents instructions which are always safe /// to mark with the nounwind attribute. -static inline bool IsNoThrow(ARCInstKind Class) { - // objc_retainBlock is not nounwind because it calls user copy constructors - // which could theoretically throw. - return Class == ARCInstKind::Retain || Class == ARCInstKind::RetainRV || - Class == ARCInstKind::Release || Class == ARCInstKind::Autorelease || - Class == ARCInstKind::AutoreleaseRV || - Class == ARCInstKind::AutoreleasepoolPush || - Class == ARCInstKind::AutoreleasepoolPop; -} +bool IsNoThrow(ARCInstKind Class); /// Test whether the given instruction can autorelease any pointer or cause an /// autoreleasepool pop. -static inline bool CanInterruptRV(ARCInstKind Class) { - switch (Class) { - case ARCInstKind::AutoreleasepoolPop: - case ARCInstKind::CallOrUser: - case ARCInstKind::Call: - case ARCInstKind::Autorelease: - case ARCInstKind::AutoreleaseRV: - case ARCInstKind::FusedRetainAutorelease: - case ARCInstKind::FusedRetainAutoreleaseRV: - return true; - default: - return false; - } -} +bool CanInterruptRV(ARCInstKind Class); /// \brief Determine if F is one of the special known Functions. If it isn't, /// return ARCInstKind::CallOrUser. |