22#ifndef LLVM_LIB_TRANSFORMS_OBJCARC_OBJCARC_H
23#define LLVM_LIB_TRANSFORMS_OBJCARC_OBJCARC_H
50 "Can't delete non-forwarding instruction with users!");
74template<
class PHINodeTy,
class VectorTy>
76 auto *BB = PN.getParent();
77 for (
auto &
P : BB->phis()) {
80 unsigned I = 0,
E = PN.getNumIncomingValues();
82 auto *BB = PN.getIncomingBlock(
I);
83 auto *PNOpnd = PN.getIncomingValue(
I)->stripPointerCasts();
84 auto *POpnd =
P.getIncomingValueForBlock(BB)->stripPointerCasts();
89 PHIList.push_back(&
P);
110 : EP(EP), ContractPass(ContractPass), UseClaimRV(UseClaimRV) {}
130 return RVCalls.count(CI);
136 auto It = RVCalls.find(CI);
137 if (It != RVCalls.end()) {
139 for (
User *U : It->second->users())
148 It->second->getIterator());
149 NewCall->copyMetadata(*It->second);
150 It->second->replaceAllUsesWith(NewCall);
151 It->second->eraseFromParent();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file contains a class ARCRuntimeEntryPoints for use in creating/managing references to entry poi...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines common analysis utilities used by the ObjC ARC Optimizer.
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),...
InstListType::iterator iterator
Instruction iterators...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
LLVM_ABI Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
static LLVM_ABI CallBase * removeOperandBundle(CallBase *CB, uint32_t ID, InsertPosition InsertPt=nullptr)
Create a clone of CB with operand bundle ID removed.
This class represents a function call, abstracting a target machine's calling convention.
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...
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
@ OB_clang_arc_attachedcall
A Module instance is used to store all the information related to an LLVM module.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Value * getOperand(unsigned i) const
LLVM Value Representation.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Declarations for ObjC runtime functions and constants.
bool contains(const Instruction *I) const
See if an instruction is a bundled retainRV/claimRV call.
BundledRetainClaimRVs(ARCRuntimeEntryPoints &EP, bool ContractPass, bool UseClaimRV)
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...
CallInst * insertRVCall(BasicBlock::iterator InsertPt, CallBase *AnnotatedCall)
Insert a retainRV/claimRV call.
void eraseInst(CallInst *CI)
Remove a retainRV/claimRV call entirely.
CallInst * insertRVCallWithColors(BasicBlock::iterator InsertPt, CallBase *AnnotatedCall, const DenseMap< BasicBlock *, ColorVector > &BlockColors)
Insert a retainRV/claimRV call with colors.
@ C
The default llvm calling convention, compatible with C.
static const Instruction * getreturnRVOperand(const Instruction &Inst, ARCInstKind Class)
If Inst is a ReturnRV and its operand is a call or invoke, return the operand.
const char * getRVMarkerModuleFlagStr()
bool IsNullOrUndef(const Value *V)
ARCInstKind
Equivalence classes of instructions in the ARC Model.
@ User
could "use" a pointer
@ RetainRV
objc_retainAutoreleasedReturnValue
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.
void getEquivalentPHIs(PHINodeTy &PN, VectorTy &PHIList)
Return the list of PHI nodes that are equivalent to PN.
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.
bool IsNoopOnNull(ARCInstKind Class)
Test if the given class represents instructions which do nothing if passed a null pointer.
static MDString * getRVInstMarker(Module &M)
static void EraseInstruction(Instruction *CI)
Erase the given instruction.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr, std::function< void(Value *)> AboutToDeleteCallback=std::function< void(Value *)>())
If the specified value is a trivially dead instruction, delete it.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto dyn_cast_or_null(const Y &Val)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.