62 #define DEBUG_TYPE "cfl-steens-aa" 102 if (isa<Constant>(Val)) {
106 bool CanStoreMutableData = isa<GlobalValue>(Val) ||
107 isa<ConstantExpr>(Val) ||
108 isa<ConstantAggregate>(Val);
109 return !CanStoreMutableData;
118 : Sets(
std::move(S)) {
133 auto AddToRetParamRelations = [&](
unsigned InterfaceIndex,
139 auto Itr = InterfaceMap.
find(SetIndex);
140 if (Itr != InterfaceMap.
end()) {
141 if (CurrValue != Itr->second)
142 Summary.RetParamRelations.push_back(
148 InterfaceMap.
insert(std::make_pair(SetIndex, CurrValue));
150 if (ExternalAttrs.any())
151 Summary.RetParamAttributes.push_back(
154 if (!
Link.hasBelow())
158 SetIndex =
Link.Below;
163 for (
auto *RetVal : RetVals) {
164 assert(RetVal !=
nullptr);
165 assert(RetVal->getType()->isPointerTy());
167 if (RetInfo.hasValue())
168 AddToRetParamRelations(0, RetInfo->Index);
173 for (
auto &Param : Fn.
args()) {
174 if (Param.getType()->isPointerTy()) {
176 if (ParamInfo.hasValue())
177 AddToRetParamRelations(I + 1, ParamInfo->Index);
190 for (
const auto &Mapping : Graph.value_mappings()) {
191 auto Val = Mapping.first;
200 for (
unsigned I = 0,
E =
ValueInfo.getNumLevels() - 1;
I <
E; ++
I) {
203 ValueInfo.getNodeInfoAtLevel(I + 1).Attr);
210 for (
const auto &Mapping : Graph.value_mappings()) {
211 auto Val = Mapping.first;
218 for (
auto &Edge :
ValueInfo.getNodeInfoAtLevel(I).Edges)
219 SetBuilder.
addWith(Src, Edge.Other);
229 assert(InsertPair.second &&
230 "Trying to scan a function that has already been cached");
235 auto FunInfo = buildSetsFrom(Fn);
236 Cache[Fn] = std::move(FunInfo);
238 Handles.emplace_front(Fn,
this);
241 void CFLSteensAAResult::evict(
Function *Fn) { Cache.erase(Fn); }
247 auto Iter = Cache.find(Fn);
248 if (Iter == Cache.end()) {
250 Iter = Cache.find(Fn);
251 assert(Iter != Cache.end());
252 assert(Iter->second.hasValue());
258 auto &FunInfo = ensureCached(&Fn);
259 if (FunInfo.hasValue())
260 return &FunInfo->getAliasSummary();
267 auto *ValA =
const_cast<Value *
>(LocA.
Ptr);
268 auto *ValB =
const_cast<Value *
>(LocB.
Ptr);
270 if (!ValA->getType()->isPointerTy() || !ValB->getType()->isPointerTy())
276 if (!MaybeFnA && !MaybeFnB) {
281 <<
"CFLSteensAA: could not extract parent function information.\n");
287 assert((!MaybeFnB || MaybeFnB == MaybeFnA) &&
288 "Interprocedural queries not supported");
294 auto &MaybeInfo = ensureCached(Fn);
295 assert(MaybeInfo.hasValue());
297 auto &Sets = MaybeInfo->getStratifiedSets();
299 if (!MaybeA.hasValue())
303 if (!MaybeB.hasValue())
308 auto AttrsA = Sets.getLink(SetA.Index).Attrs;
309 auto AttrsB = Sets.getLink(SetB.Index).Attrs;
321 if (SetA.Index == SetB.Index)
323 if (AttrsA.none() || AttrsB.none())
340 "Unification-Based CFL Alias Analysis",
false,
true)
351 auto &TLIWP = getAnalysis<TargetLibraryInfoWrapperPass>();
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class represents lattice values for constants.
We use ExternalRelation to describe an externally visible aliasing relations between parameters/retur...
StratifiedSets< T > build()
Builds a StratifiedSet from the information we've been given since either construction or the prior b...
This is the result of instantiating InterfaceValue at a particular callsite.
The two locations do not alias at all.
We use ExternalAttribute to describe an externally visible AliasAttrs for parameters/return value...
We use InterfaceValue to describe parameters/return value, as well as potential memory locations that...
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
AnalysisUsage & addRequired()
bool addWith(const T &Main, const T &ToAdd)
A CRTP-driven "mixin" base class to help implement the function alias analysis results concept...
Legacy wrapper pass to provide the CFLSteensAAResult object.
AliasResult
The possible results of an alias query.
iterator find(const_arg_type_t< KeyT > Val)
This is the interface for LLVM's unification-based alias analysis implemented with CFL graph reachabi...
const StratifiedLink & getLink(StratifiedIndex Index) const
void initializePass() override
initializePass - This method may be overriden by immutable passes to allow them to perform various in...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Represent the analysis usage information of a pass.
INITIALIZE_PASS(CFLSteensAAWrapperPass, "cfl-steens-aa", "Unification-Based CFL Alias Analysis", false, true) ImmutablePass *llvm
const AliasSummary & getAliasSummary() const
const SmallVector< Value *, 4 > & getReturnValues() const
bool isGlobalOrArgAttr(AliasAttrs Attr)
Struct that holds a reference to a particular GUID in a global value summary.
The two locations may or may not alias. This is the least precise result.
const Value * Ptr
The address of the start of the location.
Representation for a specific memory location.
ImmutablePass class - This class is used to provide information that does not need to be run...
AliasAttrs getExternallyVisibleAttrs(AliasAttrs Attr)
Given an AliasAttrs, return a new AliasAttrs that only contains attributes meaningful to the caller...
A builder class used to create CFLGraph instance from a given function The CFL-AA that uses this buil...
Provides information about what library functions are available for the current target.
static bool canSkipAddingToSets(Value *Val)
Determines whether it would be pointless to add the given Value to our sets.
bool addBelow(const T &Main, const T &ToAdd)
Restructures the stratified sets as necessary to make "ToAdd" in a set below "Main".
Alias summary information.
This file defines various utility types and functions useful to summary-based alias analysis...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Information we have about a function and would like to keep around.
void setPreservesAll()
Set by analyses that do not transform their input at all.
This file defines CFLGraph, an auxiliary data structure used by CFL-based alias analysis.
amdgpu Simplify well known AMD library false Value Value * Arg
FunctionInfo(Function &Fn, const SmallVectorImpl< Value *> &RetVals, StratifiedSets< InstantiatedValue > S)
CFLSteensAAResult(const TargetLibraryInfo &TLI)
static const int64_t UnknownOffset
bool hasUnknownOrCallerAttr(AliasAttrs Attr)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
ImmutablePass * createCFLSteensAAWrapperPass()
Analysis pass providing the TargetLibraryInfo.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void initializeCFLSteensAAWrapperPassPass(PassRegistry &)
static const Function * parentFunctionOfValue(const Value *Val)
Generic Builder class that produces StratifiedSets instances.
LLVM Value Representation.
const CFLGraph & getCFLGraph() const
static const unsigned MaxSupportedArgsInSummary
The maximum number of arguments we can put into a summary.
A container for analyses that lazily runs them and caches their results.
const StratifiedSets< InstantiatedValue > & getStratifiedSets() const
A special type used by analysis passes to provide an address that identifies that particular analysis...
static Expected< BitVector > scan(StringRef &S, StringRef Original)
void noteAttributes(const T &Main, AliasAttrs NewAttrs)
iterator_range< arg_iterator > args()
Optional< StratifiedInfo > find(const T &Elem) const