LLVM 23.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 UnsafeClaimRV, ///< objc_unsafeClaimAutoreleasedReturnValue
32 RetainBlock, ///< objc_retainBlock
33 Release, ///< objc_release
34 Autorelease, ///< objc_autorelease
35 AutoreleaseRV, ///< objc_autoreleaseReturnValue
36 AutoreleasepoolPush, ///< objc_autoreleasePoolPush
37 AutoreleasepoolPop, ///< objc_autoreleasePoolPop
38 NoopCast, ///< objc_retainedObject, etc.
39 FusedRetainAutorelease, ///< objc_retainAutorelease
40 FusedRetainAutoreleaseRV, ///< objc_retainAutoreleaseReturnValue
41 LoadWeakRetained, ///< objc_loadWeakRetained (primitive)
42 StoreWeak, ///< objc_storeWeak (primitive)
43 InitWeak, ///< objc_initWeak (derived)
44 LoadWeak, ///< objc_loadWeak (derived)
45 MoveWeak, ///< objc_moveWeak (derived)
46 CopyWeak, ///< objc_copyWeak (derived)
47 DestroyWeak, ///< objc_destroyWeak (derived)
48 StoreStrong, ///< objc_storeStrong (derived)
49 IntrinsicUser, ///< llvm.objc.clang.arc.use
50 CallOrUser, ///< could call objc_release and/or "use" pointers
51 Call, ///< could call objc_release
52 User, ///< could "use" a pointer
53 None ///< anything that is inert from an ARC perspective.
54};
55
57
58/// Test if the given class is a kind of user.
59LLVM_ABI bool IsUser(ARCInstKind Class);
60
61/// Test if the given class is objc_retain or equivalent.
62LLVM_ABI bool IsRetain(ARCInstKind Class);
63
64/// Test if the given class is objc_autorelease or equivalent.
66
67/// Test if the given class represents instructions which return their
68/// argument verbatim.
70
71/// Test if the given class represents instructions which do nothing if
72/// passed a null pointer.
74
75/// Test if the given class represents instructions which do nothing if
76/// passed a global variable.
78
79/// Test if the given class represents instructions which are always safe
80/// to mark with the "tail" keyword.
82
83/// Test if the given class represents instructions which are never safe
84/// to mark with the "tail" keyword.
86
87/// Test if the given class represents instructions which are always safe
88/// to mark with the nounwind attribute.
90
91/// Test whether the given instruction can autorelease any pointer or cause an
92/// autoreleasepool pop.
94
95/// Determine if F is one of the special known Functions. If it isn't,
96/// return ARCInstKind::CallOrUser.
98
99/// Determine which objc runtime call instruction class V belongs to.
100///
101/// This is similar to GetARCInstKind except that it only detects objc
102/// runtime calls. This allows it to be faster.
103///
105 if (const CallInst *CI = dyn_cast<CallInst>(V)) {
106 if (const Function *F = CI->getCalledFunction())
107 return GetFunctionClass(F);
108 // Otherwise, be conservative.
110 }
111
112 // Otherwise, be conservative.
114}
115
116/// Map V to its ARCInstKind equivalence class.
118
119/// Returns false if conservatively we can prove that any instruction mapped to
120/// this kind can not decrement ref counts. Returns true otherwise.
122
123} // end namespace objcarc
124} // end namespace llvm
125
126#endif
#define LLVM_ABI
Definition Compiler.h:213
#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
@ 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