bool MayReadAnyGlobal;
unsigned getInfoForGlobal(const GlobalValue *GV) const {
- unsigned Effect = MayReadAnyGlobal ? AliasAnalysis::Ref : 0;
+ unsigned Effect = MayReadAnyGlobal ? MRI_Ref : 0;
std::map<const GlobalValue *, unsigned>::const_iterator I =
GlobalInfo.find(GV);
if (I != GlobalInfo.end())
AU.setPreservesAll(); // Does not transform code
}
+ /// getAdjustedAnalysisPointer - This method is used when a pass implements
+ /// an analysis interface through multiple inheritance. If needed, it
+ /// should override this to adjust the this pointer as needed for the
+ /// specified pass info.
+ void *getAdjustedAnalysisPointer(AnalysisID PI) override {
+ if (PI == &AliasAnalysis::ID)
+ return (AliasAnalysis *)this;
+ return this;
+ }
+
//------------------------------------------------
// Implement the AliasAnalysis API
//
AliasResult alias(const MemoryLocation &LocA,
const MemoryLocation &LocB) override;
- ModRefResult getModRefInfo(ImmutableCallSite CS,
- const MemoryLocation &Loc) override;
- ModRefResult getModRefInfo(ImmutableCallSite CS1,
- ImmutableCallSite CS2) override {
+ ModRefInfo getModRefInfo(ImmutableCallSite CS,
+ const MemoryLocation &Loc) override;
+ ModRefInfo getModRefInfo(ImmutableCallSite CS1,
+ ImmutableCallSite CS2) override {
return AliasAnalysis::getModRefInfo(CS1, CS2);
}
/// getModRefBehavior - Return the behavior of the specified function if
/// called from the specified call site. The call site may be null in which
/// case the most generic behavior of this function should be returned.
- ModRefBehavior getModRefBehavior(const Function *F) override {
- ModRefBehavior Min = UnknownModRefBehavior;
+ FunctionModRefBehavior getModRefBehavior(const Function *F) override {
+ FunctionModRefBehavior Min = FMRB_UnknownModRefBehavior;
if (FunctionRecord *FR = getFunctionInfo(F)) {
if (FR->FunctionEffect == 0)
- Min = DoesNotAccessMemory;
- else if ((FR->FunctionEffect & Mod) == 0)
- Min = OnlyReadsMemory;
+ Min = FMRB_DoesNotAccessMemory;
+ else if ((FR->FunctionEffect & MRI_Mod) == 0)
+ Min = FMRB_OnlyReadsMemory;
}
- return ModRefBehavior(AliasAnalysis::getModRefBehavior(F) & Min);
+ return FunctionModRefBehavior(AliasAnalysis::getModRefBehavior(F) & Min);
}
/// getModRefBehavior - Return the behavior of the specified function if
/// called from the specified call site. The call site may be null in which
/// case the most generic behavior of this function should be returned.
- ModRefBehavior getModRefBehavior(ImmutableCallSite CS) override {
- ModRefBehavior Min = UnknownModRefBehavior;
+ FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS) override {
+ FunctionModRefBehavior Min = FMRB_UnknownModRefBehavior;
if (const Function *F = CS.getCalledFunction())
if (FunctionRecord *FR = getFunctionInfo(F)) {
if (FR->FunctionEffect == 0)
- Min = DoesNotAccessMemory;
- else if ((FR->FunctionEffect & Mod) == 0)
- Min = OnlyReadsMemory;
+ Min = FMRB_DoesNotAccessMemory;
+ else if ((FR->FunctionEffect & MRI_Mod) == 0)
+ Min = FMRB_OnlyReadsMemory;
}
- return ModRefBehavior(AliasAnalysis::getModRefBehavior(CS) & Min);
- }
-
- /// getAdjustedAnalysisPointer - This method is used when a pass implements
- /// an analysis interface through multiple inheritance. If needed, it
- /// should override this to adjust the this pointer as needed for the
- /// specified pass info.
- void *getAdjustedAnalysisPointer(AnalysisID PI) override {
- if (PI == &AliasAnalysis::ID)
- return (AliasAnalysis *)this;
- return this;
+ return FunctionModRefBehavior(AliasAnalysis::getModRefBehavior(CS) & Min);
}
private:
Handles.front().I = Handles.begin();
for (Function *Reader : Readers)
- FunctionInfo[Reader].GlobalInfo[&GV] |= Ref;
+ FunctionInfo[Reader].GlobalInfo[&GV] |= MRI_Ref;
if (!GV.isConstant()) // No need to keep track of writers to constants
for (Function *Writer : Writers)
- FunctionInfo[Writer].GlobalInfo[&GV] |= Mod;
+ FunctionInfo[Writer].GlobalInfo[&GV] |= MRI_Mod;
++NumNonAddrTakenGlobalVars;
// If this global holds a pointer type, see if it is an indirect global.
if (F->doesNotAccessMemory()) {
// Can't do better than that!
} else if (F->onlyReadsMemory()) {
- FunctionEffect |= Ref;
+ FunctionEffect |= MRI_Ref;
if (!F->isIntrinsic())
// This function might call back into the module and read a global -
// consider every global as possibly being read by this function.
FR.MayReadAnyGlobal = true;
} else {
- FunctionEffect |= ModRef;
+ FunctionEffect |= MRI_ModRef;
// Can't say anything useful unless it's an intrinsic - they don't
// read or write global variables of the kind considered here.
KnowNothing = !F->isIntrinsic();
// Scan the function bodies for explicit loads or stores.
for (auto *Node : SCC) {
- if (FunctionEffect == ModRef)
+ if (FunctionEffect == MRI_ModRef)
break; // The mod/ref lattice saturates here.
for (Instruction &I : inst_range(Node->getFunction())) {
- if (FunctionEffect == ModRef)
+ if (FunctionEffect == MRI_ModRef)
break; // The mod/ref lattice saturates here.
// We handle calls specially because the graph-relevant aspects are
if (isAllocationFn(&I, TLI) || isFreeCall(&I, TLI)) {
// FIXME: It is completely unclear why this is necessary and not
// handled by the above graph code.
- FunctionEffect |= ModRef;
+ FunctionEffect |= MRI_ModRef;
} else if (Function *Callee = CS.getCalledFunction()) {
// The callgraph doesn't include intrinsic calls.
if (Callee->isIntrinsic()) {
- ModRefBehavior Behaviour =
+ FunctionModRefBehavior Behaviour =
AliasAnalysis::getModRefBehavior(Callee);
- FunctionEffect |= (Behaviour & ModRef);
+ FunctionEffect |= (Behaviour & MRI_ModRef);
}
}
continue;
// All non-call instructions we use the primary predicates for whether
// thay read or write memory.
if (I.mayReadFromMemory())
- FunctionEffect |= Ref;
+ FunctionEffect |= MRI_Ref;
if (I.mayWriteToMemory())
- FunctionEffect |= Mod;
+ FunctionEffect |= MRI_Mod;
}
}
- if ((FunctionEffect & Mod) == 0)
+ if ((FunctionEffect & MRI_Mod) == 0)
++NumReadMemFunctions;
if (FunctionEffect == 0)
++NumNoMemFunctions;
return AliasAnalysis::alias(LocA, LocB);
}
-AliasAnalysis::ModRefResult
-GlobalsModRef::getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc) {
- unsigned Known = ModRef;
+ModRefInfo GlobalsModRef::getModRefInfo(ImmutableCallSite CS,
+ const MemoryLocation &Loc) {
+ unsigned Known = MRI_ModRef;
// If we are asking for mod/ref info of a direct call with a pointer to a
// global we are tracking, return information if we have it.
if (const FunctionRecord *FR = getFunctionInfo(F))
Known = FR->getInfoForGlobal(GV);
- if (Known == NoModRef)
- return NoModRef; // No need to query other mod/ref analyses
- return ModRefResult(Known & AliasAnalysis::getModRefInfo(CS, Loc));
+ if (Known == MRI_NoModRef)
+ return MRI_NoModRef; // No need to query other mod/ref analyses
+ return ModRefInfo(Known & AliasAnalysis::getModRefInfo(CS, Loc));
}