LLVM 19.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
19using namespace llvm;
20using 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.
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}
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)
This file defines common analysis utilities used by the ObjC ARC Optimizer.
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 ...
This class represents an Operation in the Expression.
An instruction for reading from memory.
Definition: Instructions.h:184
LLVM Value Representation.
Definition: Value.h:74
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:450
LocationClass< Ty > location(Ty &L)
Definition: CommandLine.h:470
bool IsPotentialRetainableObjPtr(const Value *Op)
Test whether the given value is possible a retainable object pointer.
bool EnableARCOpts
A handy option to enable/disable all ARC Optimizations.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18