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->hasExactDefinition())
81 !JCS.onlyReadsMemory() &&
82 MayAutorelease(JCS, Depth + 1))
91 bool ObjCARCAPElim::OptimizeBB(
BasicBlock *BB) {
104 if (Push && cast<CallInst>(Inst)->getArgOperand(0) == Push) {
106 DEBUG(
dbgs() <<
"ObjCARCAPElim::OptimizeBB: Zapping push pop "
107 "autorelease pair:\n"
108 " Pop: " << *Inst <<
"\n"
109 <<
" Push: " << *Push <<
"\n");
127 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->
front());
Pass interface - Implemented by all 'passes'.
SymbolTableList< Instruction >::iterator 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. ...
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...
bool ModuleHasARC(const Module &M)
Test if the given module looks interesting to run ARC optimization on.
LLVM Basic Block Representation.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Represent the analysis usage information of a pass.
ARCInstKind GetBasicARCInstKind(const Value *V)
Determine which objc runtime call instruction class V belongs to.
Iterator for intrusive lists based on ilist_node.
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.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Establish a view to a call site for examination.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const BasicBlock & front() const
FunTy * getCalledFunction() const
Return the function being called if this is a direct call, otherwise return null (if it's an indirect...
LLVM Value Representation.
INITIALIZE_PASS(ObjCARCAPElim,"objc-arc-apelim","ObjC ARC autorelease pool elimination", false, false) Pass *llvm
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.