39#define DEBUG_TYPE "objc-arc-ap-elim"
47 if (!Callee->hasExactDefinition())
51 if (
const CallBase *JCB = dyn_cast<CallBase>(&
I))
54 if (Depth < 3 && !JCB->onlyReadsMemory() &&
55 MayAutorelease(*JCB,
Depth + 1))
70 case ARCInstKind::AutoreleasepoolPush:
73 case ARCInstKind::AutoreleasepoolPop:
76 if (Push && cast<CallInst>(&Inst)->getArgOperand(0) == Push) {
78 LLVM_DEBUG(
dbgs() <<
"ObjCARCAPElim::OptimizeBB: Zapping push pop "
84 Inst.eraseFromParent();
89 case ARCInstKind::CallOrUser:
90 if (MayAutorelease(cast<CallBase>(Inst)))
119 "llvm.global_ctors is uncooperative!");
121 bool Changed =
false;
130 Function *
F = dyn_cast<Function>(cast<ConstantStruct>(
Op)->getOperand(1));
136 if (
F->isDeclaration())
139 if (std::next(
F->begin()) !=
F->end())
142 Changed |= OptimizeBB(&
F->front());
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool runImpl(Function &F, const TargetLowering &TLI)
This file defines common analysis utilities used by the ObjC ARC Optimizer.
This header defines various interfaces for pass management in LLVM.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A container for analyses that lazily runs them and caches their results.
LLVM Basic Block Representation.
Represents analyses that only rely on functions' control flow.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
ConstantArray - Constant Array Declarations.
This class represents an Operation in the Expression.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool hasDefinitiveInitializer() const
hasDefinitiveInitializer - Whether the global variable has an initializer, and any other instances of...
InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void preserveSet()
Mark an analysis set as preserved.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
bool ModuleHasARC(const Module &M)
Test if the given module looks interesting to run ARC optimization on.
bool EnableARCOpts
A handy option to enable/disable all ARC Optimizations.
ARCInstKind GetBasicARCInstKind(const Value *V)
Determine which objc runtime call instruction class V belongs to.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)