LLVM 24.0.0git
ObjCARCInstKind.h
Go to the documentation of this file.
1//===- ObjCARCInstKind.h - ARC instruction equivalence classes --*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_ANALYSIS_OBJCARCINSTKIND_H
10#define LLVM_ANALYSIS_OBJCARCINSTKIND_H
11
13
14namespace llvm {
15namespace objcarc {
16
17/// \enum ARCInstKind
18///
19/// Equivalence classes of instructions in the ARC Model.
20///
21/// Since we do not have "instructions" to represent ARC concepts in LLVM IR,
22/// we instead operate on equivalence classes of instructions.
23///
24/// TODO: This should be split into two enums: a runtime entry point enum
25/// (possibly united with the ARCRuntimeEntrypoint class) and an enum that deals
26/// with effects of instructions in the ARC model (which would handle the notion
27/// of a User or CallOrUser).
28enum class ARCInstKind {
29 Retain, ///< objc_retain
30 RetainRV, ///< objc_retainAutoreleasedReturnValue,
31 ///< objc_claimAutoreleasedReturnValue
32 UnsafeClaimRV, ///< objc_unsafeClaimAutoreleasedReturnValue
33 RetainBlock, ///< objc_retainBlock
34 Release, ///< objc_release
35 Autorelease, ///< objc_autorelease
36 AutoreleaseRV, ///< objc_autoreleaseReturnValue
37 AutoreleasepoolPush, ///< objc_autoreleasePoolPush
38 AutoreleasepoolPop, ///< objc_autoreleasePoolPop
39 NoopCast, ///< objc_retainedObject, etc.
40 FusedRetainAutorelease, ///< objc_retainAutorelease
41 FusedRetainAutoreleaseRV, ///< objc_retainAutoreleaseReturnValue
42 LoadWeakRetained, ///< objc_loadWeakRetained (primitive)
43 StoreWeak, ///< objc_storeWeak (primitive)
44 InitWeak, ///< objc_initWeak (derived)
45 LoadWeak, ///< objc_loadWeak (derived)
46 MoveWeak, ///< objc_moveWeak (derived)
47 CopyWeak, ///< objc_copyWeak (derived)
48 DestroyWeak, ///< objc_destroyWeak (derived)
49 StoreStrong, ///< objc_storeStrong (derived)
50 IntrinsicUser, ///< llvm.objc.clang.arc.use
51 CallOrUser, ///< could call objc_release and/or "use" pointers
52 Call, ///< could call objc_release
53 User, ///< could "use" a pointer
54 None ///< anything that is inert from an ARC perspective.
55};
56
58
59/// Test if the given class is a kind of user.
60LLVM_ABI bool IsUser(ARCInstKind Class);
61
62/// Test if the given class is objc_retain or equivalent.
63LLVM_ABI bool IsRetain(ARCInstKind Class);
64
65/// Test if the given class is objc_autorelease or equivalent.
67
68/// Test if the given class represents instructions which return their
69/// argument verbatim.
71
72/// Test if the given class represents instructions which do nothing if
73/// passed a null pointer.
75
76/// Test if the given class represents instructions which do nothing if
77/// passed a global variable.
79
80/// Test if the given class represents instructions which are always safe
81/// to mark with the "tail" keyword.
83
84/// Test if the given class represents instructions which are never safe
85/// to mark with the "tail" keyword.
87
88/// Test if the given class represents instructions which are always safe
89/// to mark with the nounwind attribute.
91
92/// Test whether the given instruction can autorelease any pointer or cause an
93/// autoreleasepool pop.
95
96/// Determine if F is one of the special known Functions. If it isn't,
97/// return ARCInstKind::CallOrUser.
99
100/// Determine which objc runtime call instruction class V belongs to.
101///
102/// This is similar to GetARCInstKind except that it only detects objc
103/// runtime calls. This allows it to be faster.
104///
106 if (const CallInst *CI = dyn_cast<CallInst>(V)) {
107 if (const Function *F = CI->getCalledFunction())
108 return GetFunctionClass(F);
109 // Otherwise, be conservative.
111 }
112
113 // Otherwise, be conservative.
115}
116
117/// Map V to its ARCInstKind equivalence class.
119
120/// Returns false if conservatively we can prove that any instruction mapped to
121/// this kind can not decrement ref counts. Returns true otherwise.
123
124} // end namespace objcarc
125} // end namespace llvm
126
127#endif
#define LLVM_ABI
Definition Compiler.h:211
#define F(x, y, z)
Definition MD5.cpp:54
This class represents a function call, abstracting a target machine's calling convention.
LLVM Value Representation.
Definition Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
LLVM_ABI bool IsUser(ARCInstKind Class)
Test if the given class is a kind of user.
LLVM_ABI raw_ostream & operator<<(raw_ostream &OS, const ARCInstKind Class)
LLVM_ABI bool IsRetain(ARCInstKind Class)
Test if the given class is objc_retain or equivalent.
LLVM_ABI bool IsNeverTail(ARCInstKind Class)
Test if the given class represents instructions which are never safe to mark with the "tail" keyword.
LLVM_ABI bool IsAlwaysTail(ARCInstKind Class)
Test if the given class represents instructions which are always safe to mark with the "tail" keyword...
LLVM_ABI bool IsAutorelease(ARCInstKind Class)
Test if the given class is objc_autorelease or equivalent.
ARCInstKind
Equivalence classes of instructions in the ARC Model.
@ DestroyWeak
objc_destroyWeak (derived)
@ FusedRetainAutorelease
objc_retainAutorelease
@ CallOrUser
could call objc_release and/or "use" pointers
@ StoreStrong
objc_storeStrong (derived)
@ LoadWeakRetained
objc_loadWeakRetained (primitive)
@ StoreWeak
objc_storeWeak (primitive)
@ AutoreleasepoolPop
objc_autoreleasePoolPop
@ AutoreleasepoolPush
objc_autoreleasePoolPush
@ InitWeak
objc_initWeak (derived)
@ Autorelease
objc_autorelease
@ LoadWeak
objc_loadWeak (derived)
@ None
anything that is inert from an ARC perspective.
@ MoveWeak
objc_moveWeak (derived)
@ User
could "use" a pointer
@ RetainRV
objc_retainAutoreleasedReturnValue, objc_claimAutoreleasedReturnValue
@ RetainBlock
objc_retainBlock
@ FusedRetainAutoreleaseRV
objc_retainAutoreleaseReturnValue
@ AutoreleaseRV
objc_autoreleaseReturnValue
@ Call
could call objc_release
@ CopyWeak
objc_copyWeak (derived)
@ NoopCast
objc_retainedObject, etc.
@ UnsafeClaimRV
objc_unsafeClaimAutoreleasedReturnValue
@ IntrinsicUser
llvm.objc.clang.arc.use
LLVM_ABI ARCInstKind GetFunctionClass(const Function *F)
Determine if F is one of the special known Functions.
LLVM_ABI bool IsForwarding(ARCInstKind Class)
Test if the given class represents instructions which return their argument verbatim.
ARCInstKind GetBasicARCInstKind(const Value *V)
Determine which objc runtime call instruction class V belongs to.
LLVM_ABI ARCInstKind GetARCInstKind(const Value *V)
Map V to its ARCInstKind equivalence class.
LLVM_ABI bool CanInterruptRV(ARCInstKind Class)
Test whether the given instruction can autorelease any pointer or cause an autoreleasepool pop.
LLVM_ABI bool IsNoThrow(ARCInstKind Class)
Test if the given class represents instructions which are always safe to mark with the nounwind attri...
LLVM_ABI bool CanDecrementRefCount(ARCInstKind Kind)
Returns false if conservatively we can prove that any instruction mapped to this kind can not decreme...
LLVM_ABI bool IsNoopOnGlobal(ARCInstKind Class)
Test if the given class represents instructions which do nothing if passed a global variable.
LLVM_ABI bool IsNoopOnNull(ARCInstKind Class)
Test if the given class represents instructions which do nothing if passed a null pointer.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547