Path: blob/main/contrib/llvm-project/llvm/lib/Transforms/ObjCARC/DependencyAnalysis.h
35266 views
//===- DependencyAnalysis.h - ObjC ARC Optimization ---*- C++ -*-----------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7/// \file8///9/// This file declares special dependency analysis routines used in Objective C10/// ARC Optimizations.11///12/// WARNING: This file knows about certain library functions. It recognizes them13/// by name, and hardwires knowledge of their semantics.14///15/// WARNING: This file knows about how certain Objective-C library functions are16/// used. Naive LLVM IR transformations which would otherwise be17/// behavior-preserving may break these assumptions.18///19//===----------------------------------------------------------------------===//2021#ifndef LLVM_LIB_TRANSFORMS_OBJCARC_DEPENDENCYANALYSIS_H22#define LLVM_LIB_TRANSFORMS_OBJCARC_DEPENDENCYANALYSIS_H2324#include "llvm/Analysis/ObjCARCInstKind.h"2526namespace llvm {27class BasicBlock;28class Instruction;29class Value;30}3132namespace llvm {33namespace objcarc {3435class ProvenanceAnalysis;3637/// \enum DependenceKind38/// Defines different dependence kinds among various ARC constructs.39///40/// There are several kinds of dependence-like concepts in use here.41///42enum DependenceKind {43NeedsPositiveRetainCount,44AutoreleasePoolBoundary,45CanChangeRetainCount,46RetainAutoreleaseDep, ///< Blocks objc_retainAutorelease.47RetainAutoreleaseRVDep ///< Blocks objc_retainAutoreleaseReturnValue.48};4950/// Find dependent instructions. If there is exactly one dependent instruction,51/// return it. Otherwise, return null.52llvm::Instruction *findSingleDependency(DependenceKind Flavor, const Value *Arg,53BasicBlock *StartBB,54Instruction *StartInst,55ProvenanceAnalysis &PA);5657bool58Depends(DependenceKind Flavor, Instruction *Inst, const Value *Arg,59ProvenanceAnalysis &PA);6061/// Test whether the given instruction can "use" the given pointer's object in a62/// way that requires the reference count to be positive.63bool CanUse(const Instruction *Inst, const Value *Ptr, ProvenanceAnalysis &PA,64ARCInstKind Class);6566/// Test whether the given instruction can result in a reference count67/// modification (positive or negative) for the pointer's object.68bool CanAlterRefCount(const Instruction *Inst, const Value *Ptr,69ProvenanceAnalysis &PA, ARCInstKind Class);7071/// Returns true if we can not conservatively prove that Inst can not decrement72/// the reference count of Ptr. Returns false if we can.73bool CanDecrementRefCount(const Instruction *Inst, const Value *Ptr,74ProvenanceAnalysis &PA, ARCInstKind Class);7576static inline bool CanDecrementRefCount(const Instruction *Inst,77const Value *Ptr,78ProvenanceAnalysis &PA) {79return CanDecrementRefCount(Inst, Ptr, PA, GetARCInstKind(Inst));80}8182} // namespace objcarc83} // namespace llvm8485#endif868788