LLVM: lib/Transforms/ObjCARC/ObjCARC.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
20
21using namespace llvm;
23
29 Value *Callee = Func.getCallee();
31
32 if (!BlockColors.empty()) {
33 const ColorVector &CV = BlockColors.find(InsertBefore->getParent())->second;
34 assert(CV.size() == 1 && "non-unique color for block!");
36 if (EHPad->isEHPad())
38 }
39
40 return CallInst::Create(FTy, Callee, Args, OpBundles, NameStr, InsertBefore);
41}
42
43std::pair<bool, bool>
45 bool Changed = false, CFGChanged = false;
46
49
50 if ()
51 continue;
52
54 continue;
55
57
59 assert(I->getSuccessor(0) == DestBB &&
60 "the normal dest is expected to be the first successor");
62 CFGChanged = true;
63 }
64
65
66
69 }
70
71 return std::make_pair(Changed, CFGChanged);
72}
73
79
83 IRBuilder<> Builder(InsertPt->getParent(), InsertPt);
85 assert(Func && "operand isn't a Function");
86 Type *ParamTy = Func->getArg(0)->getType();
87 Value *CallArg = Builder.CreateBitCast(AnnotatedCall, ParamTy);
90 RVCalls[Call] = AnnotatedCall;
92}
93
95 for (auto P : RVCalls) {
96 if (ContractPass) {
98
99
100
101
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121 if (UseClaimRV) {
128 break;
129 }
130 }
131 }
132 }
133
134
136 }
137
138 RVCalls.clear();
139}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines ARC utility functions which are used by various parts of the compiler.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
LLVM_ABI const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
LLVM_ABI InstListType::const_iterator getFirstNonPHIIt() const
Returns an iterator to the first instruction in this block that is not a PHINode instruction.
LLVM_ABI const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
InstListType::iterator iterator
Instruction iterators...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
OperandBundleUse operandBundleFromBundleOpInfo(const BundleOpInfo &BOI) const
Simple helper function to map a BundleOpInfo to an OperandBundleUse.
iterator_range< bundle_op_iterator > bundle_op_infos()
Return the range [bundle_op_info_begin, bundle_op_info_end).
This class represents a function call, abstracting a target machine's calling convention.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
iterator find(const_arg_type_t< KeyT > Val)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Class to represent function types.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
@ OB_clang_arc_attachedcall
reference emplace_back(ArgTypes &&... Args)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
void setOperand(unsigned i, Value *Val)
LLVM Value Representation.
std::pair< bool, bool > insertAfterInvokes(Function &F, DominatorTree *DT)
Insert a retainRV/claimRV call to the normal destination blocks of invokes with operand bundle "clang...
Definition ObjCARC.cpp:44
CallInst * insertRVCall(BasicBlock::iterator InsertPt, CallBase *AnnotatedCall)
Insert a retainRV/claimRV call.
Definition ObjCARC.cpp:74
CallInst * insertRVCallWithColors(BasicBlock::iterator InsertPt, CallBase *AnnotatedCall, const DenseMap< BasicBlock *, ColorVector > &BlockColors)
Insert a retainRV/claimRV call with colors.
Definition ObjCARC.cpp:80
~BundledRetainClaimRVs()
Definition ObjCARC.cpp:94
This file defines common definitions/declarations used by the ObjC ARC Optimizer.
@ Call
could call objc_release
CallInst * createCallInstWithColors(FunctionCallee Func, ArrayRef< Value * > Args, const Twine &NameStr, BasicBlock::iterator InsertBefore, const DenseMap< BasicBlock *, ColorVector > &BlockColors)
Create a call instruction with the correct funclet token.
Definition ObjCARC.cpp:24
std::optional< Function * > getAttachedARCFunction(const CallBase *CB)
This function returns operand bundle clang_arc_attachedcall's argument, which is the address of the A...
bool hasAttachedCallOpBundle(const CallBase *CB)
static void EraseInstruction(Instruction *CI)
Erase the given instruction.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
LLVM_ABI BasicBlock * SplitCriticalEdge(Instruction *TI, unsigned SuccNum, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions(), const Twine &BBName="")
If this edge is a critical edge, insert a new node to split the critical edge.
TinyPtrVector< BasicBlock * > ColorVector
Option class for critical edge splitting.