LLVM  13.0.0git
ObjCARCAnalysisUtils.cpp
Go to the documentation of this file.
1 //===- ObjCARCAnalysisUtils.cpp -------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements common infrastructure for libLLVMObjCARCOpts.a, which
10 // implements several scalar transformations over the LLVM intermediate
11 // representation, including the C bindings for that library.
12 //
13 //===----------------------------------------------------------------------===//
14 
18 
19 using namespace llvm;
20 using namespace llvm::objcarc;
21 
22 /// A handy option to enable/disable all ARC Optimizations.
25  "enable-objc-arc-opts", cl::desc("enable/disable all ARC Optimizations"),
27 
29  AAResults &AA) {
30  // First make the rudimentary check.
32  return false;
33 
34  // Objects in constant memory are not reference-counted.
35  if (AA.pointsToConstantMemory(Op))
36  return false;
37 
38  // Pointers in constant memory are not pointing to reference-counted objects.
39  if (const LoadInst *LI = dyn_cast<LoadInst>(Op))
40  if (AA.pointsToConstantMemory(LI->getPointerOperand()))
41  return false;
42 
43  // Otherwise assume the worst.
44  return true;
45 }
llvm
Definition: AllocatorList.h:23
llvm::cl::location
LocationClass< Ty > location(Ty &L)
Definition: CommandLine.h:459
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
AliasAnalysis.h
CommandLine.h
llvm::objcarc::IsPotentialRetainableObjPtr
bool IsPotentialRetainableObjPtr(const Value *Op)
Test whether the given value is possible a retainable object pointer.
Definition: ObjCARCAnalysisUtils.h:143
llvm::AAResults
Definition: AliasAnalysis.h:456
llvm::cl::opt
Definition: CommandLine.h:1422
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
llvm::objcarc::EnableARCOpts
bool EnableARCOpts
A handy option to enable/disable all ARC Optimizations.
Definition: ObjCARCAnalysisUtils.cpp:23
llvm::objcarc
Definition: ObjCARCAliasAnalysis.h:29
llvm::LoadInst
An instruction for reading from memory.
Definition: Instructions.h:174
ObjCARCAnalysisUtils.h
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:314
llvm::AAResults::pointsToConstantMemory
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal=false)
Checks whether the given location points to constant memory, or if OrLocal is true whether it points ...
Definition: AliasAnalysis.cpp:163
llvm::cl::desc
Definition: CommandLine.h:414
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
EnableARCOptimizations
static cl::opt< bool, true > EnableARCOptimizations("enable-objc-arc-opts", cl::desc("enable/disable all ARC Optimizations"), cl::location(EnableARCOpts), cl::init(true), cl::Hidden)