22#ifndef LLVM_LIB_TRANSFORMS_OBJCARC_OBJCARC_H
23#define LLVM_LIB_TRANSFORMS_OBJCARC_OBJCARC_H
40 Value *OldArg = cast<CallInst>(CI)->getArgOperand(0);
49 "Can't delete non-forwarding instruction with users!");
67 if (
const auto *
C = dyn_cast<CallInst>(Opnd))
69 return dyn_cast<InvokeInst>(Opnd);
73template<
class PHINodeTy,
class VectorTy>
75 auto *BB = PN.getParent();
76 for (
auto &
P : BB->phis()) {
79 unsigned I = 0,
E = PN.getNumIncomingValues();
81 auto *BB = PN.getIncomingBlock(
I);
82 auto *PNOpnd = PN.getIncomingValue(
I)->stripPointerCasts();
83 auto *POpnd =
P.getIncomingValueForBlock(BB)->stripPointerCasts();
88 PHIList.push_back(&
P);
94 return dyn_cast_or_null<MDString>(M.getModuleFlag(MarkerKey));
126 if (
auto *CI = dyn_cast<CallInst>(
I))
127 return RVCalls.count(CI);
133 auto It = RVCalls.find(CI);
134 if (It != RVCalls.end()) {
136 for (
User *U : It->second->users())
137 if (
auto *CI = dyn_cast<CallInst>(U))
145 It->second->getIterator());
146 NewCall->copyMetadata(*It->second);
147 It->second->replaceAllUsesWith(NewCall);
148 It->second->eraseFromParent();
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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...
Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
static 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...
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.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
bool contains(const Instruction *I) const
See if an instruction is a bundled retainRV/claimRV call.
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.
BundledRetainClaimRVs(bool ContractPass)
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.
@ 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.
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.