62 #define DEBUG_TYPE "cfl-steens-aa" 103 if (isa<Constant>(Val)) {
107 bool CanStoreMutableData = isa<GlobalValue>(Val) ||
108 isa<ConstantExpr>(Val) ||
109 isa<ConstantAggregate>(Val);
110 return !CanStoreMutableData;
119 : Sets(
std::move(S)) {
134 auto AddToRetParamRelations = [&](
unsigned InterfaceIndex,
140 auto Itr = InterfaceMap.
find(SetIndex);
141 if (Itr != InterfaceMap.
end()) {
142 if (CurrValue != Itr->second)
143 Summary.RetParamRelations.push_back(
149 InterfaceMap.
insert(std::make_pair(SetIndex, CurrValue));
151 if (ExternalAttrs.any())
152 Summary.RetParamAttributes.push_back(
155 if (!
Link.hasBelow())
159 SetIndex =
Link.Below;
164 for (
auto *RetVal : RetVals) {
165 assert(RetVal !=
nullptr);
166 assert(RetVal->getType()->isPointerTy());
168 if (RetInfo.hasValue())
169 AddToRetParamRelations(0, RetInfo->Index);
174 for (
auto &Param : Fn.
args()) {
175 if (Param.getType()->isPointerTy()) {
177 if (ParamInfo.hasValue())
178 AddToRetParamRelations(I + 1, ParamInfo->Index);
191 for (
const auto &Mapping : Graph.value_mappings()) {
192 auto Val = Mapping.first;
201 for (
unsigned I = 0,
E =
ValueInfo.getNumLevels() - 1;
I <
E; ++
I) {
204 ValueInfo.getNodeInfoAtLevel(I + 1).Attr);
211 for (
const auto &Mapping : Graph.value_mappings()) {
212 auto Val = Mapping.first;
219 for (
auto &Edge :
ValueInfo.getNodeInfoAtLevel(I).Edges)
220 SetBuilder.
addWith(Src, Edge.Other);
230 assert(InsertPair.second &&
231 "Trying to scan a function that has already been cached");
236 auto FunInfo = buildSetsFrom(Fn);
237 Cache[Fn] = std::move(FunInfo);
239 Handles.emplace_front(Fn,
this);
242 void CFLSteensAAResult::evict(
Function *Fn) { Cache.erase(Fn); }
248 auto Iter = Cache.find(Fn);
249 if (Iter == Cache.end()) {
251 Iter = Cache.find(Fn);
252 assert(Iter != Cache.end());
253 assert(Iter->second.hasValue());
259 auto &FunInfo = ensureCached(&Fn);
260 if (FunInfo.hasValue())
261 return &FunInfo->getAliasSummary();
268 auto *ValA =
const_cast<Value *
>(LocA.
Ptr);
269 auto *ValB =
const_cast<Value *
>(LocB.
Ptr);
271 if (!ValA->getType()->isPointerTy() || !ValB->getType()->isPointerTy())
277 if (!MaybeFnA && !MaybeFnB) {
282 <<
"CFLSteensAA: could not extract parent function information.\n");
288 assert((!MaybeFnB || MaybeFnB == MaybeFnA) &&
289 "Interprocedural queries not supported");
295 auto &MaybeInfo = ensureCached(Fn);
296 assert(MaybeInfo.hasValue());
298 auto &Sets = MaybeInfo->getStratifiedSets();
300 if (!MaybeA.hasValue())
304 if (!MaybeB.hasValue())
309 auto AttrsA = Sets.getLink(SetA.Index).Attrs;
310 auto AttrsB = Sets.getLink(SetB.Index).Attrs;
322 if (SetA.Index == SetB.Index)
324 if (AttrsA.none() || AttrsB.none())
344 "Unification-Based CFL Alias Analysis",
false,
true)
356 return this->getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
F);
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
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 call.
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...
static void query(const MachineInstr &MI, AliasAnalysis &AA, bool &Read, bool &Write, bool &Effects, bool &StackPointer)
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.
CFLSteensAAResult(std::function< const TargetLibraryInfo &(Function &)> GetTLI)
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.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
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...
Align max(MaybeAlign Lhs, Align Rhs)
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.
FunctionInfo(Function &Fn, const SmallVectorImpl< Value *> &RetVals, StratifiedSets< InstantiatedValue > S)
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.
print Print MemDeps of function
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