LLVM
15.0.0git
lib
Analysis
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
15
#include "
llvm/Analysis/ObjCARCAnalysisUtils.h
"
16
#include "
llvm/Analysis/AliasAnalysis.h
"
17
#include "
llvm/Support/CommandLine.h
"
18
19
using namespace
llvm
;
20
using namespace
llvm::objcarc
;
21
22
/// A handy option to enable/disable all ARC Optimizations.
23
bool
llvm::objcarc::EnableARCOpts
;
24
static
cl::opt<bool, true>
EnableARCOptimizations
(
25
"enable-objc-arc-opts"
,
cl::desc
(
"enable/disable all ARC Optimizations"
),
26
cl::location
(
EnableARCOpts
),
cl::init
(
true
),
cl::Hidden
);
27
28
bool
llvm::objcarc::IsPotentialRetainableObjPtr
(
const
Value
*
Op
,
29
AAResults
&
AA
) {
30
// First make the rudimentary check.
31
if
(!
IsPotentialRetainableObjPtr
(
Op
))
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
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:17
llvm::cl::location
LocationClass< Ty > location(Ty &L)
Definition:
CommandLine.h:447
llvm::cl::Hidden
@ Hidden
Definition:
CommandLine.h:139
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:146
llvm::AAResults
Definition:
AliasAnalysis.h:511
llvm::cl::opt
Definition:
CommandLine.h:1392
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition:
CommandLine.h:432
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:176
ObjCARCAnalysisUtils.h
llvm::AMDGPU::SendMsg::Op
Op
Definition:
SIDefines.h:338
AA
llvm::cl::desc
Definition:
CommandLine.h:405
llvm::Value
LLVM Value Representation.
Definition:
Value.h:74
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)
Generated on Wed May 18 2022 09:19:55 for LLVM by
1.8.17