23 #ifndef LLVM_TRANSFORMS_SCALAR_OBJCARC_H
24 #define LLVM_TRANSFORMS_SCALAR_OBJCARC_H
204 if (
const CallInst *CI = dyn_cast<CallInst>(V)) {
205 if (
const Function *
F = CI->getCalledFunction())
226 V = cast<CallInst>(V)->getArgOperand(0);
240 V = cast<CallInst>(V)->getArgOperand(0);
253 V = cast<CallInst>(V)->getArgOperand(0);
266 return isa<ConstantPointerNull>(V) || isa<UndefValue>(V);
270 return isa<BitCastInst>(
I) ||
271 (isa<GetElementPtrInst>(I) &&
272 cast<GetElementPtrInst>(
I)->hasAllZeroIndices());
283 Value *OldArg = cast<CallInst>(CI)->getArgOperand(0);
291 isa<ConstantPointerNull>(OldArg))) &&
292 "Can't delete non-forwarding instruction with users!");
306 if (isa<Constant>(Op) || isa<AllocaInst>(Op))
309 if (
const Argument *Arg = dyn_cast<Argument>(Op))
310 if (Arg->hasByValAttr() ||
311 Arg->hasNestAttr() ||
312 Arg->hasStructRetAttr())
338 if (
const LoadInst *
LI = dyn_cast<LoadInst>(Op))
366 if (isa<CallInst>(V) || isa<InvokeInst>(V) ||
367 isa<Argument>(V) || isa<Constant>(V) ||
371 if (
const LoadInst *
LI = dyn_cast<LoadInst>(V)) {
372 const Value *Pointer =
374 if (
const GlobalVariable *GV = dyn_cast<GlobalVariable>(Pointer)) {
377 if (GV->isConstant())
382 if (Name.
startswith(
"\01L_OBJC_SELECTOR_REFERENCES_") ||
383 Name.
startswith(
"\01L_OBJC_CLASSLIST_REFERENCES_") ||
384 Name.
startswith(
"\01L_OBJC_CLASSLIST_SUP_REFS_$_") ||
385 Name.
startswith(
"\01L_OBJC_METH_VAR_NAME_") ||
397 #endif // LLVM_TRANSFORMS_SCALAR_OBJCARC_H
virtual bool pointsToConstantMemory(const Location &Loc, bool OrLocal=false)
LLVM Argument representation.
objc_retainedObject, etc.
The main container class for the LLVM Intermediate Representation.
static Value * GetObjCArg(Value *Inst)
Assuming the given instruction is one of the special calls such as objc_retain or objc_release...
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static bool IsUser(InstructionClass Class)
Test if the given class is a kind of user.
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=0)
static InstructionClass GetBasicInstructionClass(const Value *V)
Determine which objc runtime call instruction class V belongs to.
objc_storeWeak (primitive)
static bool IsNoopOnNull(InstructionClass Class)
Test if the given class represents instructions which do nothing if passed a null pointer...
raw_ostream & operator<<(raw_ostream &OS, const InstructionClass Class)
static bool IsForwarding(InstructionClass Class)
Test if the given class represents instructions which return their argument verbatim.
LoopInfoBase< BlockT, LoopT > * LI
Value * GetUnderlyingObject(Value *V, const DataLayout *TD=0, unsigned MaxLookup=6)
static const Value * StripPointerCastsAndObjCCalls(const Value *V)
This is a wrapper around Value::stripPointerCasts which also knows how to look through objc_retain an...
InstructionClass GetInstructionClass(const Value *V)
Determine what kind of construct V is.
InstructionClass GetFunctionClass(const Function *F)
Determine if F is one of the special known Functions. If it isn't, return IC_CallOrUser.
bool EnableARCOpts
A handy option to enable/disable all ARC Optimizations.
void replaceAllUsesWith(Value *V)
objc_destroyWeak (derived)
InstructionClass
A simple classification for instructions.
static bool IsNoopInstruction(const Instruction *I)
static bool IsObjCIdentifiedObject(const Value *V)
Return true if this value refers to a distinct and identifiable object.
static bool CanInterruptRV(InstructionClass Class)
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
static void EraseInstruction(Instruction *CI)
Erase the given instruction.
static bool IsNoThrow(InstructionClass Class)
Test if the given class represents instructions which are always safe to mark with the nounwind attri...
bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
static bool IsNullOrUndef(const Value *V)
static InstructionClass GetCallSiteClass(ImmutableCallSite CS)
Helper for GetInstructionClass. Determines what kind of construct CS is.
static bool IsNeverTail(InstructionClass Class)
Test if the given class represents instructions which are never safe to mark with the "tail" keyword...
Value * stripPointerCasts()
Strips off any unneeded pointer casts, all-zero GEPs and aliases from the specified value...
could call objc_release and/or "use" pointers
static bool IsAutorelease(InstructionClass Class)
Test if the given class is objc_autorelease or equivalent.
static bool IsPotentialRetainableObjPtr(const Value *Op)
Test whether the given value is possible a retainable object pointer.
objc_autoreleaseReturnValue
ImmutableCallSite - establish a view to a call site for examination.
objc_retainAutoreleasedReturnValue
objc_retainAutoreleaseReturnValue
LLVM Value Representation.
static bool IsRetain(InstructionClass Class)
Test if the given class is objc_retain or equivalent.
objc_loadWeakRetained (primitive)
static const Value * GetUnderlyingObjCPtr(const Value *V)
This is a wrapper around getUnderlyingObject which also knows how to look through objc_retain and obj...
static bool IsAlwaysTail(InstructionClass Class)
Test if the given class represents instructions which are always safe to mark with the "tail" keyword...
objc_storeStrong (derived)
GlobalValue * getNamedValue(StringRef Name) const
static bool ModuleHasARC(const Module &M)
Test if the given module looks interesting to run ARC optimization on.