34 using namespace llvm::objcarc;
36 #define DEBUG_TYPE "objc-arc-ap-elim"
42 bool runOnModule(
Module &M)
override;
58 "ObjC ARC autorelease pool elimination",
62 return new ObjCARCAPElim();
65 void ObjCARCAPElim::getAnalysisUsage(
AnalysisUsage &AU)
const {
73 if (Callee->isDeclaration() || Callee->mayBeOverridden())
84 !JCS.onlyReadsMemory() &&
85 MayAutorelease(JCS, Depth + 1))
94 bool ObjCARCAPElim::OptimizeBB(
BasicBlock *BB) {
107 if (Push && cast<CallInst>(Inst)->getArgOperand(0) == Push) {
109 DEBUG(
dbgs() <<
"ObjCARCAPElim::OptimizeBB: Zapping push pop "
110 "autorelease pair:\n"
111 " Pop: " << *Inst <<
"\n"
112 <<
" Push: " << *Push <<
"\n");
130 bool ObjCARCAPElim::runOnModule(
Module &M) {
149 "llvm.global_ctors is uncooperative!");
151 bool Changed =
false;
169 if (std::next(F->
begin()) != F->
end())
172 Changed |= OptimizeBB(F->
begin());
Pass interface - Implemented by all 'passes'.
iplist< Instruction >::iterator eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing basic block and deletes it...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
could call objc_release and/or "use" pointers
void initializeObjCARCAPElimPass(PassRegistry &)
A Module instance is used to store all the information related to an LLVM module. ...
static ARCInstKind GetBasicARCInstKind(const Value *V)
Determine which objc runtime call instruction class V belongs to.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
iterator begin()
Instruction iterator methods.
A Use represents the edge between a Value definition and its users.
Pass * createObjCARCAPElimPass()
bool EnableARCOpts
A handy option to enable/disable all ARC Optimizations.
bool hasDefinitiveInitializer() const
hasDefinitiveInitializer - Whether the global variable has an initializer, and any other instances of...
LLVM Basic Block Representation.
FunTy * getCalledFunction() const
getCalledFunction - Return the function being called if this is a direct call, otherwise return null ...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Represent the analysis usage information of a pass.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
ConstantArray - Constant Array Declarations.
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
ImmutableCallSite - establish a view to a call site for examination.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
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.
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.