003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/lib/Analysis
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
lib
/
Analysis
/
📁
..
📄
AliasAnalysis.cpp
(33.55 KB)
📄
AliasAnalysisEvaluator.cpp
(15.64 KB)
📄
AliasAnalysisSummary.cpp
(3.49 KB)
📄
AliasAnalysisSummary.h
(10.17 KB)
📄
AliasSetTracker.cpp
(25.86 KB)
📄
Analysis.cpp
(5.29 KB)
📄
AssumeBundleQueries.cpp
(7.96 KB)
📄
AssumptionCache.cpp
(10.94 KB)
📄
BasicAliasAnalysis.cpp
(85.81 KB)
📄
BlockFrequencyInfo.cpp
(12.39 KB)
📄
BlockFrequencyInfoImpl.cpp
(28.6 KB)
📄
BranchProbabilityInfo.cpp
(43.48 KB)
📄
CFG.cpp
(9.9 KB)
📄
CFGPrinter.cpp
(11.2 KB)
📄
CFLAndersAliasAnalysis.cpp
(33.01 KB)
📄
CFLGraph.h
(21.23 KB)
📄
CFLSteensAliasAnalysis.cpp
(13.24 KB)
📄
CGSCCPassManager.cpp
(31.2 KB)
📄
CallGraph.cpp
(12.86 KB)
📄
CallGraphSCCPass.cpp
(26.31 KB)
📄
CallPrinter.cpp
(9.48 KB)
📄
CaptureTracking.cpp
(15.38 KB)
📄
CmpInstAnalysis.cpp
(4.63 KB)
📄
CodeMetrics.cpp
(6.99 KB)
📄
ConstantFolding.cpp
(105.15 KB)
📄
CostModel.cpp
(3.87 KB)
📄
DDG.cpp
(11.29 KB)
📄
Delinearization.cpp
(4.49 KB)
📄
DemandedBits.cpp
(16.27 KB)
📄
DependenceAnalysis.cpp
(150.78 KB)
📄
DependenceGraphBuilder.cpp
(19.24 KB)
📄
DivergenceAnalysis.cpp
(15.59 KB)
📄
DomPrinter.cpp
(9.67 KB)
📄
DomTreeUpdater.cpp
(15.21 KB)
📄
DominanceFrontier.cpp
(3.2 KB)
📄
EHPersonalities.cpp
(5.89 KB)
📄
GlobalsModRef.cpp
(41 KB)
📄
GuardUtils.cpp
(3.27 KB)
📄
HeatUtils.cpp
(2.85 KB)
📄
IVDescriptors.cpp
(42.28 KB)
📄
IVUsers.cpp
(16.12 KB)
📄
IndirectCallPromotionAnalysis.cpp
(4.33 KB)
📄
InlineAdvisor.cpp
(15.28 KB)
📄
InlineCost.cpp
(99.47 KB)
📄
InlineFeaturesAnalysis.cpp
(1.59 KB)
📄
InlineSizeEstimatorAnalysis.cpp
(10.95 KB)
📄
InstCount.cpp
(2.45 KB)
📄
InstructionPrecedenceTracking.cpp
(4.8 KB)
📄
InstructionSimplify.cpp
(216.91 KB)
📄
Interval.cpp
(1.78 KB)
📄
IntervalPartition.cpp
(4.5 KB)
📄
LazyBlockFrequencyInfo.cpp
(2.81 KB)
📄
LazyBranchProbabilityInfo.cpp
(2.96 KB)
📄
LazyCallGraph.cpp
(67.33 KB)
📄
LazyValueInfo.cpp
(76.38 KB)
📄
LegacyDivergenceAnalysis.cpp
(14.82 KB)
📄
Lint.cpp
(29.07 KB)
📄
Loads.cpp
(20.6 KB)
📄
LoopAccessAnalysis.cpp
(88.02 KB)
📄
LoopAnalysisManager.cpp
(6.6 KB)
📄
LoopCacheAnalysis.cpp
(23.53 KB)
📄
LoopInfo.cpp
(37.15 KB)
📄
LoopNestAnalysis.cpp
(10.62 KB)
📄
LoopPass.cpp
(12.89 KB)
📄
LoopUnrollAnalyzer.cpp
(7.26 KB)
📄
MLInlineAdvisor.cpp
(11.36 KB)
📄
MemDepPrinter.cpp
(5.13 KB)
📄
MemDerefPrinter.cpp
(2.53 KB)
📄
MemoryBuiltins.cpp
(41.14 KB)
📄
MemoryDependenceAnalysis.cpp
(69.89 KB)
📄
MemoryLocation.cpp
(7.92 KB)
📄
MemorySSA.cpp
(90.16 KB)
📄
MemorySSAUpdater.cpp
(57.9 KB)
📄
ModuleDebugInfoPrinter.cpp
(4.02 KB)
📄
ModuleSummaryAnalysis.cpp
(38.13 KB)
📄
MustExecute.cpp
(31.18 KB)
📄
ObjCARCAliasAnalysis.cpp
(5.81 KB)
📄
ObjCARCAnalysisUtils.cpp
(1.07 KB)
📄
ObjCARCInstKind.cpp
(23.15 KB)
📄
OptimizationRemarkEmitter.cpp
(4.23 KB)
📄
PHITransAddr.cpp
(16.05 KB)
📄
PhiValues.cpp
(8.4 KB)
📄
PostDominators.cpp
(3.59 KB)
📄
ProfileSummaryInfo.cpp
(18.07 KB)
📄
PtrUseVisitor.cpp
(1.28 KB)
📄
RegionInfo.cpp
(6.5 KB)
📄
RegionPass.cpp
(9.23 KB)
📄
RegionPrinter.cpp
(8.61 KB)
📄
ReleaseModeModelRunner.cpp
(2.83 KB)
📄
ScalarEvolution.cpp
(475.26 KB)
📄
ScalarEvolutionAliasAnalysis.cpp
(5.96 KB)
📄
ScalarEvolutionDivision.cpp
(7.51 KB)
📄
ScalarEvolutionNormalization.cpp
(4.59 KB)
📄
ScopedNoAliasAA.cpp
(7.38 KB)
📄
StackLifetime.cpp
(12.22 KB)
📄
StackSafetyAnalysis.cpp
(31.81 KB)
📄
StratifiedSets.h
(18.67 KB)
📄
SyncDependenceAnalysis.cpp
(12.97 KB)
📄
SyntheticCountsUtils.cpp
(3.81 KB)
📄
TFUtils.cpp
(8.99 KB)
📄
TargetLibraryInfo.cpp
(58.98 KB)
📄
TargetTransformInfo.cpp
(48.15 KB)
📄
Trace.cpp
(1.8 KB)
📄
TypeBasedAliasAnalysis.cpp
(26.04 KB)
📄
TypeMetadataUtils.cpp
(5.93 KB)
📄
VFABIDemangling.cpp
(16.46 KB)
📄
ValueLattice.cpp
(1.19 KB)
📄
ValueLatticeUtils.cpp
(1.53 KB)
📄
ValueTracking.cpp
(243.08 KB)
📄
VectorUtils.cpp
(48.57 KB)
📁
models
Editing: AliasAnalysisSummary.h
//=====- CFLSummary.h - Abstract stratified sets implementation. --------=====// // // 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 various utility types and functions useful to /// summary-based alias analysis. /// /// Summary-based analysis, also known as bottom-up analysis, is a style of /// interprocedrual static analysis that tries to analyze the callees before the /// callers get analyzed. The key idea of summary-based analysis is to first /// process each function independently, outline its behavior in a condensed /// summary, and then instantiate the summary at the callsite when the said /// function is called elsewhere. This is often in contrast to another style /// called top-down analysis, in which callers are always analyzed first before /// the callees. /// /// In a summary-based analysis, functions must be examined independently and /// out-of-context. We have no information on the state of the memory, the /// arguments, the global values, and anything else external to the function. To /// carry out the analysis conservative assumptions have to be made about those /// external states. In exchange for the potential loss of precision, the /// summary we obtain this way is highly reusable, which makes the analysis /// easier to scale to large programs even if carried out context-sensitively. /// /// Currently, all CFL-based alias analyses adopt the summary-based approach /// and therefore heavily rely on this header. /// //===----------------------------------------------------------------------===// #ifndef LLVM_ANALYSIS_ALIASANALYSISSUMMARY_H #define LLVM_ANALYSIS_ALIASANALYSISSUMMARY_H #include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include <bitset> namespace llvm { class CallBase; class Value; namespace cflaa { //===----------------------------------------------------------------------===// // AliasAttr related stuffs //===----------------------------------------------------------------------===// /// The number of attributes that AliasAttr should contain. Attributes are /// described below, and 32 was an arbitrary choice because it fits nicely in 32 /// bits (because we use a bitset for AliasAttr). static const unsigned NumAliasAttrs = 32; /// These are attributes that an alias analysis can use to mark certain special /// properties of a given pointer. Refer to the related functions below to see /// what kinds of attributes are currently defined. typedef std::bitset<NumAliasAttrs> AliasAttrs; /// Attr represent whether the said pointer comes from an unknown source /// (such as opaque memory or an integer cast). AliasAttrs getAttrNone(); /// AttrUnknown represent whether the said pointer comes from a source not known /// to alias analyses (such as opaque memory or an integer cast). AliasAttrs getAttrUnknown(); bool hasUnknownAttr(AliasAttrs); /// AttrCaller represent whether the said pointer comes from a source not known /// to the current function but known to the caller. Values pointed to by the /// arguments of the current function have this attribute set AliasAttrs getAttrCaller(); bool hasCallerAttr(AliasAttrs); bool hasUnknownOrCallerAttr(AliasAttrs); /// AttrEscaped represent whether the said pointer comes from a known source but /// escapes to the unknown world (e.g. casted to an integer, or passed as an /// argument to opaque function). Unlike non-escaped pointers, escaped ones may /// alias pointers coming from unknown sources. AliasAttrs getAttrEscaped(); bool hasEscapedAttr(AliasAttrs); /// AttrGlobal represent whether the said pointer is a global value. /// AttrArg represent whether the said pointer is an argument, and if so, what /// index the argument has. AliasAttrs getGlobalOrArgAttrFromValue(const Value &); bool isGlobalOrArgAttr(AliasAttrs); /// Given an AliasAttrs, return a new AliasAttrs that only contains attributes /// meaningful to the caller. This function is primarily used for /// interprocedural analysis /// Currently, externally visible AliasAttrs include AttrUnknown, AttrGlobal, /// and AttrEscaped AliasAttrs getExternallyVisibleAttrs(AliasAttrs); //===----------------------------------------------------------------------===// // Function summary related stuffs //===----------------------------------------------------------------------===// /// The maximum number of arguments we can put into a summary. static const unsigned MaxSupportedArgsInSummary = 50; /// We use InterfaceValue to describe parameters/return value, as well as /// potential memory locations that are pointed to by parameters/return value, /// of a function. /// Index is an integer which represents a single parameter or a return value. /// When the index is 0, it refers to the return value. Non-zero index i refers /// to the i-th parameter. /// DerefLevel indicates the number of dereferences one must perform on the /// parameter/return value to get this InterfaceValue. struct InterfaceValue { unsigned Index; unsigned DerefLevel; }; inline bool operator==(InterfaceValue LHS, InterfaceValue RHS) { return LHS.Index == RHS.Index && LHS.DerefLevel == RHS.DerefLevel; } inline bool operator!=(InterfaceValue LHS, InterfaceValue RHS) { return !(LHS == RHS); } inline bool operator<(InterfaceValue LHS, InterfaceValue RHS) { return LHS.Index < RHS.Index || (LHS.Index == RHS.Index && LHS.DerefLevel < RHS.DerefLevel); } inline bool operator>(InterfaceValue LHS, InterfaceValue RHS) { return RHS < LHS; } inline bool operator<=(InterfaceValue LHS, InterfaceValue RHS) { return !(RHS < LHS); } inline bool operator>=(InterfaceValue LHS, InterfaceValue RHS) { return !(LHS < RHS); } // We use UnknownOffset to represent pointer offsets that cannot be determined // at compile time. Note that MemoryLocation::UnknownSize cannot be used here // because we require a signed value. static const int64_t UnknownOffset = INT64_MAX; inline int64_t addOffset(int64_t LHS, int64_t RHS) { if (LHS == UnknownOffset || RHS == UnknownOffset) return UnknownOffset; // FIXME: Do we need to guard against integer overflow here? return LHS + RHS; } /// We use ExternalRelation to describe an externally visible aliasing relations /// between parameters/return value of a function. struct ExternalRelation { InterfaceValue From, To; int64_t Offset; }; inline bool operator==(ExternalRelation LHS, ExternalRelation RHS) { return LHS.From == RHS.From && LHS.To == RHS.To && LHS.Offset == RHS.Offset; } inline bool operator!=(ExternalRelation LHS, ExternalRelation RHS) { return !(LHS == RHS); } inline bool operator<(ExternalRelation LHS, ExternalRelation RHS) { if (LHS.From < RHS.From) return true; if (LHS.From > RHS.From) return false; if (LHS.To < RHS.To) return true; if (LHS.To > RHS.To) return false; return LHS.Offset < RHS.Offset; } inline bool operator>(ExternalRelation LHS, ExternalRelation RHS) { return RHS < LHS; } inline bool operator<=(ExternalRelation LHS, ExternalRelation RHS) { return !(RHS < LHS); } inline bool operator>=(ExternalRelation LHS, ExternalRelation RHS) { return !(LHS < RHS); } /// We use ExternalAttribute to describe an externally visible AliasAttrs /// for parameters/return value. struct ExternalAttribute { InterfaceValue IValue; AliasAttrs Attr; }; /// AliasSummary is just a collection of ExternalRelation and ExternalAttribute struct AliasSummary { // RetParamRelations is a collection of ExternalRelations. SmallVector<ExternalRelation, 8> RetParamRelations; // RetParamAttributes is a collection of ExternalAttributes. SmallVector<ExternalAttribute, 8> RetParamAttributes; }; /// This is the result of instantiating InterfaceValue at a particular call struct InstantiatedValue { Value *Val; unsigned DerefLevel; }; Optional<InstantiatedValue> instantiateInterfaceValue(InterfaceValue IValue, CallBase &Call); inline bool operator==(InstantiatedValue LHS, InstantiatedValue RHS) { return LHS.Val == RHS.Val && LHS.DerefLevel == RHS.DerefLevel; } inline bool operator!=(InstantiatedValue LHS, InstantiatedValue RHS) { return !(LHS == RHS); } inline bool operator<(InstantiatedValue LHS, InstantiatedValue RHS) { return std::less<Value *>()(LHS.Val, RHS.Val) || (LHS.Val == RHS.Val && LHS.DerefLevel < RHS.DerefLevel); } inline bool operator>(InstantiatedValue LHS, InstantiatedValue RHS) { return RHS < LHS; } inline bool operator<=(InstantiatedValue LHS, InstantiatedValue RHS) { return !(RHS < LHS); } inline bool operator>=(InstantiatedValue LHS, InstantiatedValue RHS) { return !(LHS < RHS); } /// This is the result of instantiating ExternalRelation at a particular /// callsite struct InstantiatedRelation { InstantiatedValue From, To; int64_t Offset; }; Optional<InstantiatedRelation> instantiateExternalRelation(ExternalRelation ERelation, CallBase &Call); /// This is the result of instantiating ExternalAttribute at a particular /// callsite struct InstantiatedAttr { InstantiatedValue IValue; AliasAttrs Attr; }; Optional<InstantiatedAttr> instantiateExternalAttribute(ExternalAttribute EAttr, CallBase &Call); } template <> struct DenseMapInfo<cflaa::InstantiatedValue> { static inline cflaa::InstantiatedValue getEmptyKey() { return cflaa::InstantiatedValue{DenseMapInfo<Value *>::getEmptyKey(), DenseMapInfo<unsigned>::getEmptyKey()}; } static inline cflaa::InstantiatedValue getTombstoneKey() { return cflaa::InstantiatedValue{DenseMapInfo<Value *>::getTombstoneKey(), DenseMapInfo<unsigned>::getTombstoneKey()}; } static unsigned getHashValue(const cflaa::InstantiatedValue &IV) { return DenseMapInfo<std::pair<Value *, unsigned>>::getHashValue( std::make_pair(IV.Val, IV.DerefLevel)); } static bool isEqual(const cflaa::InstantiatedValue &LHS, const cflaa::InstantiatedValue &RHS) { return LHS.Val == RHS.Val && LHS.DerefLevel == RHS.DerefLevel; } }; } #endif
Upload File
Create Folder