27 #define DEBUG_TYPE "objc-arc-ap-elim"
35 using namespace llvm::objcarc;
41 virtual bool runOnModule(
Module &M);
57 "ObjC ARC autorelease pool elimination",
61 return new ObjCARCAPElim();
64 void ObjCARCAPElim::getAnalysisUsage(
AnalysisUsage &AU)
const {
72 if (Callee->isDeclaration() || Callee->mayBeOverridden())
83 !JCS.onlyReadsMemory() &&
84 MayAutorelease(JCS, Depth + 1))
93 bool ObjCARCAPElim::OptimizeBB(
BasicBlock *BB) {
106 if (Push && cast<CallInst>(Inst)->getArgOperand(0) == Push) {
108 DEBUG(
dbgs() <<
"ObjCARCAPElim::OptimizeBB: Zapping push pop "
109 "autorelease pair:\n"
110 " Pop: " << *Inst <<
"\n"
111 <<
" Push: " << *Push <<
"\n");
129 bool ObjCARCAPElim::runOnModule(
Module &M) {
148 "llvm.global_ctors is uncooperative!");
150 bool Changed =
false;
171 Changed |= OptimizeBB(F->
begin());
static PassRegistry * getPassRegistry()
void initializeObjCARCAPElimPass(PassRegistry &)
The main container class for the LLVM Intermediate Representation.
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static InstructionClass GetBasicInstructionClass(const Value *V)
Determine which objc runtime call instruction class V belongs to.
const Constant * getInitializer() const
const GlobalVariable * getGlobalVariable(StringRef Name, bool AllowInternal=false) const
ID
LLVM Calling Convention Representation.
Pass * createObjCARCAPElimPass()
bool EnableARCOpts
A handy option to enable/disable all ARC Optimizations.
bool hasDefinitiveInitializer() const
LLVM Basic Block Representation.
ItTy next(ItTy it, Dist n)
could call objc_release and/or "use" pointers
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
bool isDeclaration() const
ImmutableCallSite - establish a view to a call site for examination.
LLVM Value Representation.
INITIALIZE_PASS(ObjCARCAPElim,"objc-arc-apelim","ObjC ARC autorelease pool elimination", false, false) Pass *llvm
static bool ModuleHasARC(const Module &M)
Test if the given module looks interesting to run ARC optimization on.
FunTy * getCalledFunction() const