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 LLVM_DEBUG(
dbgs() <<
"ObjCARCAPElim::OptimizeBB: Zapping push pop " 107 "autorelease pair:\n" 110 <<
" Push: " << *Push
129 bool ObjCARCAPElim::runOnModule(
Module &M) {
151 "llvm.global_ctors is uncooperative!");
153 bool Changed =
false;
171 if (std::next(F->
begin()) != F->
end())
174 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.
bool hasDefinitiveInitializer() const
hasDefinitiveInitializer - Whether the global variable has an initializer, and any other instances of...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
This class represents lattice values for constants.
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. ...
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.
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.
amdgpu Simplify well known AMD library false Value * Callee
bool ModuleHasARC(const Module &M)
Test if the given module looks interesting to run ARC optimization on.
INITIALIZE_PASS(ObjCARCAPElim, "objc-arc-apelim", "ObjC ARC autorelease pool elimination", false, false) Pass *llvm
LLVM Basic Block Representation.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
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.
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)
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
FunTy * getCalledFunction() const
Return the function being called if this is a direct call, otherwise return null (if it's an indirect...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const BasicBlock & front() const
LLVM Value Representation.