003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/include/llvm/Analysis
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
include
/
llvm
/
Analysis
/
📁
..
📄
AliasAnalysis.h
(51.98 KB)
📄
AliasAnalysisEvaluator.h
(2.7 KB)
📄
AliasSetTracker.h
(15.42 KB)
📄
AssumeBundleQueries.h
(6.66 KB)
📄
AssumptionCache.h
(8.39 KB)
📄
BasicAliasAnalysis.h
(10.2 KB)
📄
BlockFrequencyInfo.h
(5.59 KB)
📄
BlockFrequencyInfoImpl.h
(56.46 KB)
📄
BranchProbabilityInfo.h
(10.1 KB)
📄
CFG.h
(7.76 KB)
📄
CFGPrinter.h
(9.31 KB)
📄
CFLAliasAnalysisUtils.h
(1.66 KB)
📄
CFLAndersAliasAnalysis.h
(3.97 KB)
📄
CFLSteensAliasAnalysis.h
(4.58 KB)
📄
CGSCCPassManager.h
(41.2 KB)
📄
CallGraph.h
(18.88 KB)
📄
CallGraphSCCPass.h
(5.01 KB)
📄
CallPrinter.h
(799 B)
📄
CaptureTracking.h
(4.78 KB)
📄
CmpInstAnalysis.h
(2.57 KB)
📄
CodeMetrics.h
(3.15 KB)
📄
ConstantFolding.h
(8.01 KB)
📄
DDG.h
(19.15 KB)
📄
DOTGraphTraitsPass.h
(5.5 KB)
📄
DemandedBits.h
(4.07 KB)
📄
DependenceAnalysis.h
(41.83 KB)
📄
DependenceGraphBuilder.h
(7.74 KB)
📄
DivergenceAnalysis.h
(7.38 KB)
📄
DomPrinter.h
(1.04 KB)
📄
DomTreeUpdater.h
(13.2 KB)
📄
DominanceFrontier.h
(6.63 KB)
📄
DominanceFrontierImpl.h
(7.12 KB)
📄
EHPersonalities.h
(3.22 KB)
📄
GlobalsModRef.h
(5.96 KB)
📄
GuardUtils.h
(2.11 KB)
📄
HeatUtils.h
(1.16 KB)
📄
IVDescriptors.h
(14.56 KB)
📄
IVUsers.h
(6.07 KB)
📄
IndirectCallPromotionAnalysis.h
(2.61 KB)
📄
IndirectCallVisitor.h
(1.16 KB)
📄
InlineAdvisor.h
(8.71 KB)
📄
InlineCost.h
(11.33 KB)
📄
InlineFeaturesAnalysis.h
(1.5 KB)
📄
InlineModelFeatureMaps.h
(3.41 KB)
📄
InlineSizeEstimatorAnalysis.h
(1.07 KB)
📄
InstructionPrecedenceTracking.h
(5.9 KB)
📄
InstructionSimplify.h
(13.36 KB)
📄
Interval.h
(4.84 KB)
📄
IntervalIterator.h
(10.64 KB)
📄
IntervalPartition.h
(4.05 KB)
📄
IteratedDominanceFrontier.h
(2.62 KB)
📄
LazyBlockFrequencyInfo.h
(4.34 KB)
📄
LazyBranchProbabilityInfo.h
(4.21 KB)
📄
LazyCallGraph.h
(50.13 KB)
📄
LazyValueInfo.h
(5.4 KB)
📄
LegacyDivergenceAnalysis.h
(2.53 KB)
📄
Lint.h
(1.35 KB)
📄
Loads.h
(7.86 KB)
📄
LoopAccessAnalysis.h
(29.75 KB)
📄
LoopAnalysisManager.h
(5.83 KB)
📄
LoopCacheAnalysis.h
(11.91 KB)
📄
LoopInfo.h
(48.27 KB)
📄
LoopInfoImpl.h
(27.14 KB)
📄
LoopIterator.h
(8.83 KB)
📄
LoopNestAnalysis.h
(5.61 KB)
📄
LoopPass.h
(4.29 KB)
📄
LoopUnrollAnalyzer.h
(3.42 KB)
📄
MLInlineAdvisor.h
(3.48 KB)
📄
MLModelRunner.h
(1.16 KB)
📄
MemoryBuiltins.h
(13.42 KB)
📄
MemoryDependenceAnalysis.h
(20.82 KB)
📄
MemoryLocation.h
(10.99 KB)
📄
MemorySSA.h
(45.92 KB)
📄
MemorySSAUpdater.h
(14.55 KB)
📄
ModuleSummaryAnalysis.h
(3.44 KB)
📄
MustExecute.h
(20.2 KB)
📄
ObjCARCAliasAnalysis.h
(3.35 KB)
📄
ObjCARCAnalysisUtils.h
(10.22 KB)
📄
ObjCARCInstKind.h
(4.87 KB)
📄
OptimizationRemarkEmitter.h
(5.93 KB)
📄
PHITransAddr.h
(4.77 KB)
📄
Passes.h
(3.88 KB)
📄
PhiValues.h
(5.25 KB)
📄
PostDominators.h
(3.41 KB)
📄
ProfileSummaryInfo.h
(9.3 KB)
📄
PtrUseVisitor.h
(9.96 KB)
📄
RegionInfo.h
(35.23 KB)
📄
RegionInfoImpl.h
(25.16 KB)
📄
RegionIterator.h
(14.07 KB)
📄
RegionPass.h
(4.05 KB)
📄
RegionPrinter.h
(2.25 KB)
📄
ScalarEvolution.h
(89.21 KB)
📄
ScalarEvolutionAliasAnalysis.h
(2.09 KB)
📄
ScalarEvolutionDivision.h
(2.48 KB)
📄
ScalarEvolutionExpressions.h
(28.61 KB)
📄
ScalarEvolutionNormalization.h
(2.47 KB)
📄
ScopedNoAliasAA.h
(2.83 KB)
📄
SparsePropagation.h
(19.43 KB)
📄
StackLifetime.h
(6.16 KB)
📄
StackSafetyAnalysis.h
(4.91 KB)
📄
SyncDependenceAnalysis.h
(2.85 KB)
📄
SyntheticCountsUtils.h
(1.85 KB)
📄
TargetFolder.h
(11.04 KB)
📄
TargetLibraryInfo.def
(55.35 KB)
📄
TargetLibraryInfo.h
(16.86 KB)
📄
TargetTransformInfo.h
(96.51 KB)
📄
TargetTransformInfoImpl.h
(37.63 KB)
📄
Trace.h
(4.1 KB)
📄
TypeBasedAliasAnalysis.h
(3.05 KB)
📄
TypeMetadataUtils.h
(1.94 KB)
📁
Utils
📄
ValueLattice.h
(15.14 KB)
📄
ValueLatticeUtils.h
(1.66 KB)
📄
ValueTracking.h
(35.82 KB)
📄
VecFuncs.def
(10.94 KB)
📄
VectorUtils.h
(37.26 KB)
Editing: ObjCARCAnalysisUtils.h
//===- ObjCARCAnalysisUtils.h - ObjC ARC Analysis Utilities -----*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// \file /// This file defines common analysis utilities used by the ObjC ARC Optimizer. /// ARC stands for Automatic Reference Counting and is a system for managing /// reference counts for objects in Objective C. /// /// WARNING: This file knows about certain library functions. It recognizes them /// by name, and hardwires knowledge of their semantics. /// /// WARNING: This file knows about how certain Objective-C library functions are /// used. Naive LLVM IR transformations which would otherwise be /// behavior-preserving may break these assumptions. /// //===----------------------------------------------------------------------===// #ifndef LLVM_LIB_ANALYSIS_OBJCARCANALYSISUTILS_H #define LLVM_LIB_ANALYSIS_OBJCARCANALYSISUTILS_H #include "llvm/ADT/Optional.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/ObjCARCInstKind.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Module.h" #include "llvm/IR/ValueHandle.h" namespace llvm { namespace objcarc { /// A handy option to enable/disable all ARC Optimizations. extern bool EnableARCOpts; /// Test if the given module looks interesting to run ARC optimization /// on. inline bool ModuleHasARC(const Module &M) { return M.getNamedValue("llvm.objc.retain") || M.getNamedValue("llvm.objc.release") || M.getNamedValue("llvm.objc.autorelease") || M.getNamedValue("llvm.objc.retainAutoreleasedReturnValue") || M.getNamedValue("llvm.objc.unsafeClaimAutoreleasedReturnValue") || M.getNamedValue("llvm.objc.retainBlock") || M.getNamedValue("llvm.objc.autoreleaseReturnValue") || M.getNamedValue("llvm.objc.autoreleasePoolPush") || M.getNamedValue("llvm.objc.loadWeakRetained") || M.getNamedValue("llvm.objc.loadWeak") || M.getNamedValue("llvm.objc.destroyWeak") || M.getNamedValue("llvm.objc.storeWeak") || M.getNamedValue("llvm.objc.initWeak") || M.getNamedValue("llvm.objc.moveWeak") || M.getNamedValue("llvm.objc.copyWeak") || M.getNamedValue("llvm.objc.retainedObject") || M.getNamedValue("llvm.objc.unretainedObject") || M.getNamedValue("llvm.objc.unretainedPointer") || M.getNamedValue("llvm.objc.clang.arc.use"); } /// This is a wrapper around getUnderlyingObject which also knows how to /// look through objc_retain and objc_autorelease calls, which we know to return /// their argument verbatim. inline const Value *GetUnderlyingObjCPtr(const Value *V, const DataLayout &DL) { for (;;) { V = GetUnderlyingObject(V, DL); if (!IsForwarding(GetBasicARCInstKind(V))) break; V = cast<CallInst>(V)->getArgOperand(0); } return V; } /// A wrapper for GetUnderlyingObjCPtr used for results memoization. inline const Value * GetUnderlyingObjCPtrCached(const Value *V, const DataLayout &DL, DenseMap<const Value *, WeakTrackingVH> &Cache) { if (auto InCache = Cache.lookup(V)) return InCache; const Value *Computed = GetUnderlyingObjCPtr(V, DL); Cache[V] = const_cast<Value *>(Computed); return Computed; } /// The RCIdentity root of a value \p V is a dominating value U for which /// retaining or releasing U is equivalent to retaining or releasing V. In other /// words, ARC operations on \p V are equivalent to ARC operations on \p U. /// /// We use this in the ARC optimizer to make it easier to match up ARC /// operations by always mapping ARC operations to RCIdentityRoots instead of /// pointers themselves. /// /// The two ways that we see RCIdentical values in ObjC are via: /// /// 1. PointerCasts /// 2. Forwarding Calls that return their argument verbatim. /// /// Thus this function strips off pointer casts and forwarding calls. *NOTE* /// This implies that two RCIdentical values must alias. inline const Value *GetRCIdentityRoot(const Value *V) { for (;;) { V = V->stripPointerCasts(); if (!IsForwarding(GetBasicARCInstKind(V))) break; V = cast<CallInst>(V)->getArgOperand(0); } return V; } /// Helper which calls const Value *GetRCIdentityRoot(const Value *V) and just /// casts away the const of the result. For documentation about what an /// RCIdentityRoot (and by extension GetRCIdentityRoot is) look at that /// function. inline Value *GetRCIdentityRoot(Value *V) { return const_cast<Value *>(GetRCIdentityRoot((const Value *)V)); } /// Assuming the given instruction is one of the special calls such as /// objc_retain or objc_release, return the RCIdentity root of the argument of /// the call. inline Value *GetArgRCIdentityRoot(Value *Inst) { return GetRCIdentityRoot(cast<CallInst>(Inst)->getArgOperand(0)); } inline bool IsNullOrUndef(const Value *V) { return isa<ConstantPointerNull>(V) || isa<UndefValue>(V); } inline bool IsNoopInstruction(const Instruction *I) { return isa<BitCastInst>(I) || (isa<GetElementPtrInst>(I) && cast<GetElementPtrInst>(I)->hasAllZeroIndices()); } /// Test whether the given value is possible a retainable object pointer. inline bool IsPotentialRetainableObjPtr(const Value *Op) { // Pointers to static or stack storage are not valid retainable object // pointers. if (isa<Constant>(Op) || isa<AllocaInst>(Op)) return false; // Special arguments can not be a valid retainable object pointer. if (const Argument *Arg = dyn_cast<Argument>(Op)) if (Arg->hasPassPointeeByValueAttr() || Arg->hasNestAttr() || Arg->hasStructRetAttr()) return false; // Only consider values with pointer types. // // It seemes intuitive to exclude function pointer types as well, since // functions are never retainable object pointers, however clang occasionally // bitcasts retainable object pointers to function-pointer type temporarily. PointerType *Ty = dyn_cast<PointerType>(Op->getType()); if (!Ty) return false; // Conservatively assume anything else is a potential retainable object // pointer. return true; } inline bool IsPotentialRetainableObjPtr(const Value *Op, AliasAnalysis &AA) { // First make the rudimentary check. if (!IsPotentialRetainableObjPtr(Op)) return false; // Objects in constant memory are not reference-counted. if (AA.pointsToConstantMemory(Op)) return false; // Pointers in constant memory are not pointing to reference-counted objects. if (const LoadInst *LI = dyn_cast<LoadInst>(Op)) if (AA.pointsToConstantMemory(LI->getPointerOperand())) return false; // Otherwise assume the worst. return true; } /// Helper for GetARCInstKind. Determines what kind of construct CS /// is. inline ARCInstKind GetCallSiteClass(const CallBase &CB) { for (auto I = CB.arg_begin(), E = CB.arg_end(); I != E; ++I) if (IsPotentialRetainableObjPtr(*I)) return CB.onlyReadsMemory() ? ARCInstKind::User : ARCInstKind::CallOrUser; return CB.onlyReadsMemory() ? ARCInstKind::None : ARCInstKind::Call; } /// Return true if this value refers to a distinct and identifiable /// object. /// /// This is similar to AliasAnalysis's isIdentifiedObject, except that it uses /// special knowledge of ObjC conventions. inline bool IsObjCIdentifiedObject(const Value *V) { // Assume that call results and arguments have their own "provenance". // Constants (including GlobalVariables) and Allocas are never // reference-counted. if (isa<CallInst>(V) || isa<InvokeInst>(V) || isa<Argument>(V) || isa<Constant>(V) || isa<AllocaInst>(V)) return true; if (const LoadInst *LI = dyn_cast<LoadInst>(V)) { const Value *Pointer = GetRCIdentityRoot(LI->getPointerOperand()); if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(Pointer)) { // A constant pointer can't be pointing to an object on the heap. It may // be reference-counted, but it won't be deleted. if (GV->isConstant()) return true; StringRef Name = GV->getName(); // These special variables are known to hold values which are not // reference-counted pointers. if (Name.startswith("\01l_objc_msgSend_fixup_")) return true; StringRef Section = GV->getSection(); if (Section.find("__message_refs") != StringRef::npos || Section.find("__objc_classrefs") != StringRef::npos || Section.find("__objc_superrefs") != StringRef::npos || Section.find("__objc_methname") != StringRef::npos || Section.find("__cstring") != StringRef::npos) return true; } } return false; } enum class ARCMDKindID { ImpreciseRelease, CopyOnEscape, NoObjCARCExceptions, }; /// A cache of MDKinds used by various ARC optimizations. class ARCMDKindCache { Module *M; /// The Metadata Kind for clang.imprecise_release metadata. llvm::Optional<unsigned> ImpreciseReleaseMDKind; /// The Metadata Kind for clang.arc.copy_on_escape metadata. llvm::Optional<unsigned> CopyOnEscapeMDKind; /// The Metadata Kind for clang.arc.no_objc_arc_exceptions metadata. llvm::Optional<unsigned> NoObjCARCExceptionsMDKind; public: void init(Module *Mod) { M = Mod; ImpreciseReleaseMDKind = NoneType::None; CopyOnEscapeMDKind = NoneType::None; NoObjCARCExceptionsMDKind = NoneType::None; } unsigned get(ARCMDKindID ID) { switch (ID) { case ARCMDKindID::ImpreciseRelease: if (!ImpreciseReleaseMDKind) ImpreciseReleaseMDKind = M->getContext().getMDKindID("clang.imprecise_release"); return *ImpreciseReleaseMDKind; case ARCMDKindID::CopyOnEscape: if (!CopyOnEscapeMDKind) CopyOnEscapeMDKind = M->getContext().getMDKindID("clang.arc.copy_on_escape"); return *CopyOnEscapeMDKind; case ARCMDKindID::NoObjCARCExceptions: if (!NoObjCARCExceptionsMDKind) NoObjCARCExceptionsMDKind = M->getContext().getMDKindID("clang.arc.no_objc_arc_exceptions"); return *NoObjCARCExceptionsMDKind; } llvm_unreachable("Covered switch isn't covered?!"); } }; } // end namespace objcarc } // end namespace llvm #endif
Upload File
Create Folder