[llvm] 1a9d982 - [AA] Rename uses of FunctionModRefBehavior (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 19 01:55:14 PDT 2022
Author: Nikita Popov
Date: 2022-10-19T10:54:47+02:00
New Revision: 1a9d9823c5feb6336adb6d0ad1042b81350e4e20
URL: https://github.com/llvm/llvm-project/commit/1a9d9823c5feb6336adb6d0ad1042b81350e4e20
DIFF: https://github.com/llvm/llvm-project/commit/1a9d9823c5feb6336adb6d0ad1042b81350e4e20.diff
LOG: [AA] Rename uses of FunctionModRefBehavior (NFC)
Followup to D135962 to rename remaining uses of
FunctionModRefBehavior to MemoryEffects. Does not touch API names
yet, but also updates variables names FMRB/MRB to ME, to match the
new type name.
Added:
Modified:
llvm/include/llvm/Analysis/AliasAnalysis.h
llvm/include/llvm/Analysis/BasicAliasAnalysis.h
llvm/include/llvm/Analysis/GlobalsModRef.h
llvm/include/llvm/Analysis/ObjCARCAliasAnalysis.h
llvm/include/llvm/Analysis/TypeBasedAliasAnalysis.h
llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
llvm/lib/Analysis/AliasAnalysis.cpp
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/lib/Analysis/GlobalsModRef.cpp
llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp
llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp
llvm/lib/Transforms/Scalar/LICM.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/unittests/Analysis/GlobalsModRefTest.cpp
polly/lib/Analysis/ScopBuilder.cpp
polly/lib/Analysis/ScopDetection.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/AliasAnalysis.h b/llvm/include/llvm/Analysis/AliasAnalysis.h
index 51d4b2185e5ef..7e6aba3d1682e 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -383,10 +383,10 @@ class AAResults {
ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx);
/// Return the behavior of the given call site.
- FunctionModRefBehavior getModRefBehavior(const CallBase *Call);
+ MemoryEffects getModRefBehavior(const CallBase *Call);
/// Return the behavior when calling the given function.
- FunctionModRefBehavior getModRefBehavior(const Function *F);
+ MemoryEffects getModRefBehavior(const Function *F);
/// Checks if the specified call is known to never read or write memory.
///
@@ -645,8 +645,7 @@ class AAResults {
ModRefInfo callCapturesBefore(const Instruction *I,
const MemoryLocation &MemLoc, DominatorTree *DT,
AAQueryInfo &AAQIP);
- FunctionModRefBehavior getModRefBehavior(const CallBase *Call,
- AAQueryInfo &AAQI);
+ MemoryEffects getModRefBehavior(const CallBase *Call, AAQueryInfo &AAQI);
private:
class Concept;
@@ -701,7 +700,7 @@ class BatchAAResults {
ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
return AA.getArgModRefInfo(Call, ArgIdx);
}
- FunctionModRefBehavior getModRefBehavior(const CallBase *Call) {
+ MemoryEffects getModRefBehavior(const CallBase *Call) {
return AA.getModRefBehavior(Call, AAQI);
}
bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
@@ -766,11 +765,11 @@ class AAResults::Concept {
unsigned ArgIdx) = 0;
/// Return the behavior of the given call site.
- virtual FunctionModRefBehavior getModRefBehavior(const CallBase *Call,
- AAQueryInfo &AAQI) = 0;
+ virtual MemoryEffects getModRefBehavior(const CallBase *Call,
+ AAQueryInfo &AAQI) = 0;
/// Return the behavior when calling the given function.
- virtual FunctionModRefBehavior getModRefBehavior(const Function *F) = 0;
+ virtual MemoryEffects getModRefBehavior(const Function *F) = 0;
/// getModRefInfo (for call sites) - Return information about whether
/// a particular call site modifies or reads the specified memory location.
@@ -814,12 +813,12 @@ template <typename AAResultT> class AAResults::Model final : public Concept {
return Result.getArgModRefInfo(Call, ArgIdx);
}
- FunctionModRefBehavior getModRefBehavior(const CallBase *Call,
- AAQueryInfo &AAQI) override {
+ MemoryEffects getModRefBehavior(const CallBase *Call,
+ AAQueryInfo &AAQI) override {
return Result.getModRefBehavior(Call, AAQI);
}
- FunctionModRefBehavior getModRefBehavior(const Function *F) override {
+ MemoryEffects getModRefBehavior(const Function *F) override {
return Result.getModRefBehavior(F);
}
@@ -869,13 +868,12 @@ class AAResultBase {
return ModRefInfo::ModRef;
}
- FunctionModRefBehavior getModRefBehavior(const CallBase *Call,
- AAQueryInfo &AAQI) {
- return FunctionModRefBehavior::unknown();
+ MemoryEffects getModRefBehavior(const CallBase *Call, AAQueryInfo &AAQI) {
+ return MemoryEffects::unknown();
}
- FunctionModRefBehavior getModRefBehavior(const Function *F) {
- return FunctionModRefBehavior::unknown();
+ MemoryEffects getModRefBehavior(const Function *F) {
+ return MemoryEffects::unknown();
}
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
diff --git a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
index 0dddddf817642..21f46dc268df1 100644
--- a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
@@ -83,12 +83,11 @@ class BasicAAResult : public AAResultBase {
ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx);
/// Returns the behavior when calling the given call site.
- FunctionModRefBehavior getModRefBehavior(const CallBase *Call,
- AAQueryInfo &AAQI);
+ MemoryEffects getModRefBehavior(const CallBase *Call, AAQueryInfo &AAQI);
/// Returns the behavior when calling the given function. For use when the
/// call site is not known.
- FunctionModRefBehavior getModRefBehavior(const Function *Fn);
+ MemoryEffects getModRefBehavior(const Function *Fn);
private:
struct DecomposedGEP;
diff --git a/llvm/include/llvm/Analysis/GlobalsModRef.h b/llvm/include/llvm/Analysis/GlobalsModRef.h
index 4747fb49d343b..479b8041fc460 100644
--- a/llvm/include/llvm/Analysis/GlobalsModRef.h
+++ b/llvm/include/llvm/Analysis/GlobalsModRef.h
@@ -104,7 +104,7 @@ class GlobalsAAResult : public AAResultBase {
/// 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.
- FunctionModRefBehavior getModRefBehavior(const Function *F);
+ MemoryEffects getModRefBehavior(const Function *F);
private:
FunctionInfo *getFunctionInfo(const Function *F);
diff --git a/llvm/include/llvm/Analysis/ObjCARCAliasAnalysis.h b/llvm/include/llvm/Analysis/ObjCARCAliasAnalysis.h
index 7b81e910546dc..8bc7fccff92fa 100644
--- a/llvm/include/llvm/Analysis/ObjCARCAliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/ObjCARCAliasAnalysis.h
@@ -56,7 +56,7 @@ class ObjCARCAAResult : public AAResultBase {
bool OrLocal);
using AAResultBase::getModRefBehavior;
- FunctionModRefBehavior getModRefBehavior(const Function *F);
+ MemoryEffects getModRefBehavior(const Function *F);
using AAResultBase::getModRefInfo;
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
diff --git a/llvm/include/llvm/Analysis/TypeBasedAliasAnalysis.h b/llvm/include/llvm/Analysis/TypeBasedAliasAnalysis.h
index e631f1587507d..7d74b9a02b555 100644
--- a/llvm/include/llvm/Analysis/TypeBasedAliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/TypeBasedAliasAnalysis.h
@@ -42,9 +42,8 @@ class TypeBasedAAResult : public AAResultBase {
AAQueryInfo &AAQI);
bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI,
bool OrLocal);
- FunctionModRefBehavior getModRefBehavior(const CallBase *Call,
- AAQueryInfo &AAQI);
- FunctionModRefBehavior getModRefBehavior(const Function *F);
+ MemoryEffects getModRefBehavior(const CallBase *Call, AAQueryInfo &AAQI);
+ MemoryEffects getModRefBehavior(const Function *F);
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
AAQueryInfo &AAQI);
ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
diff --git a/llvm/include/llvm/Transforms/IPO/FunctionAttrs.h b/llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
index bcb75025f8e57..fc7cca83496b0 100644
--- a/llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
+++ b/llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
@@ -29,8 +29,7 @@ class Module;
class Pass;
/// Returns the memory access properties of this copy of the function.
-FunctionModRefBehavior computeFunctionBodyMemoryAccess(Function &F,
- AAResults &AAR);
+MemoryEffects computeFunctionBodyMemoryAccess(Function &F, AAResults &AAR);
/// Propagate function attributes for function summaries along the index's
/// callgraph during thinlink
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index c21cf865a8c36..bf724b318d62d 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -226,14 +226,13 @@ ModRefInfo AAResults::getModRefInfo(const CallBase *Call,
// We can completely ignore inaccessible memory here, because MemoryLocations
// can only reference accessible memory.
- auto MRB = getModRefBehavior(Call, AAQI).getWithoutLoc(
- FunctionModRefBehavior::InaccessibleMem);
- if (MRB.doesNotAccessMemory())
+ auto ME = getModRefBehavior(Call, AAQI)
+ .getWithoutLoc(MemoryEffects::InaccessibleMem);
+ if (ME.doesNotAccessMemory())
return ModRefInfo::NoModRef;
- ModRefInfo ArgMR = MRB.getModRef(FunctionModRefBehavior::ArgMem);
- ModRefInfo OtherMR =
- MRB.getWithoutLoc(FunctionModRefBehavior::ArgMem).getModRef();
+ ModRefInfo ArgMR = ME.getModRef(MemoryEffects::ArgMem);
+ ModRefInfo OtherMR = ME.getWithoutLoc(MemoryEffects::ArgMem).getModRef();
if ((ArgMR | OtherMR) != OtherMR) {
// Refine the modref info for argument memory. We only bother to do this
// if ArgMR is not a subset of OtherMR, otherwise this won't have an impact
@@ -375,9 +374,9 @@ ModRefInfo AAResults::getModRefInfo(const CallBase *Call1,
return Result;
}
-FunctionModRefBehavior AAResults::getModRefBehavior(const CallBase *Call,
- AAQueryInfo &AAQI) {
- FunctionModRefBehavior Result = FunctionModRefBehavior::unknown();
+MemoryEffects AAResults::getModRefBehavior(const CallBase *Call,
+ AAQueryInfo &AAQI) {
+ MemoryEffects Result = MemoryEffects::unknown();
for (const auto &AA : AAs) {
Result &= AA->getModRefBehavior(Call, AAQI);
@@ -390,13 +389,13 @@ FunctionModRefBehavior AAResults::getModRefBehavior(const CallBase *Call,
return Result;
}
-FunctionModRefBehavior AAResults::getModRefBehavior(const CallBase *Call) {
+MemoryEffects AAResults::getModRefBehavior(const CallBase *Call) {
SimpleAAQueryInfo AAQI(*this);
return getModRefBehavior(Call, AAQI);
}
-FunctionModRefBehavior AAResults::getModRefBehavior(const Function *F) {
- FunctionModRefBehavior Result = FunctionModRefBehavior::unknown();
+MemoryEffects AAResults::getModRefBehavior(const Function *F) {
+ MemoryEffects Result = MemoryEffects::unknown();
for (const auto &AA : AAs) {
Result &= AA->getModRefBehavior(F);
@@ -447,21 +446,20 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, ModRefInfo MR) {
return OS;
}
-raw_ostream &llvm::operator<<(raw_ostream &OS, FunctionModRefBehavior FMRB) {
- for (FunctionModRefBehavior::Location Loc :
- FunctionModRefBehavior::locations()) {
+raw_ostream &llvm::operator<<(raw_ostream &OS, MemoryEffects ME) {
+ for (MemoryEffects::Location Loc : MemoryEffects::locations()) {
switch (Loc) {
- case FunctionModRefBehavior::ArgMem:
+ case MemoryEffects::ArgMem:
OS << "ArgMem: ";
break;
- case FunctionModRefBehavior::InaccessibleMem:
+ case MemoryEffects::InaccessibleMem:
OS << "InaccessibleMem: ";
break;
- case FunctionModRefBehavior::Other:
+ case MemoryEffects::Other:
OS << "Other: ";
break;
}
- OS << FMRB.getModRef(Loc) << ", ";
+ OS << ME.getModRef(Loc) << ", ";
}
return OS;
}
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 7b6b6f739667a..dc64a0d9bf6b8 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -740,9 +740,9 @@ static bool isIntrinsicCall(const CallBase *Call, Intrinsic::ID IID) {
return II && II->getIntrinsicID() == IID;
}
-static FunctionModRefBehavior getModRefBehaviorFromAttrs(AttributeSet Attrs) {
+static MemoryEffects getModRefBehaviorFromAttrs(AttributeSet Attrs) {
if (Attrs.hasAttribute(Attribute::ReadNone))
- return FunctionModRefBehavior::none();
+ return MemoryEffects::none();
ModRefInfo MR = ModRefInfo::ModRef;
if (Attrs.hasAttribute(Attribute::ReadOnly))
@@ -751,29 +751,29 @@ static FunctionModRefBehavior getModRefBehaviorFromAttrs(AttributeSet Attrs) {
MR = ModRefInfo::Mod;
if (Attrs.hasAttribute(Attribute::ArgMemOnly))
- return FunctionModRefBehavior::argMemOnly(MR);
+ return MemoryEffects::argMemOnly(MR);
if (Attrs.hasAttribute(Attribute::InaccessibleMemOnly))
- return FunctionModRefBehavior::inaccessibleMemOnly(MR);
+ return MemoryEffects::inaccessibleMemOnly(MR);
if (Attrs.hasAttribute(Attribute::InaccessibleMemOrArgMemOnly))
- return FunctionModRefBehavior::inaccessibleOrArgMemOnly(MR);
- return FunctionModRefBehavior(MR);
+ return MemoryEffects::inaccessibleOrArgMemOnly(MR);
+ return MemoryEffects(MR);
}
/// Returns the behavior when calling the given call site.
-FunctionModRefBehavior BasicAAResult::getModRefBehavior(const CallBase *Call,
- AAQueryInfo &AAQI) {
- FunctionModRefBehavior Min =
+MemoryEffects BasicAAResult::getModRefBehavior(const CallBase *Call,
+ AAQueryInfo &AAQI) {
+ MemoryEffects Min =
getModRefBehaviorFromAttrs(Call->getAttributes().getFnAttrs());
if (const Function *F = dyn_cast<Function>(Call->getCalledOperand())) {
- FunctionModRefBehavior FMRB = AAQI.AAR.getModRefBehavior(F);
+ MemoryEffects FuncME = AAQI.AAR.getModRefBehavior(F);
// Operand bundles on the call may also read or write memory, in addition
// to the behavior of the called function.
if (Call->hasReadingOperandBundles())
- FMRB |= FunctionModRefBehavior::readOnly();
+ FuncME |= MemoryEffects::readOnly();
if (Call->hasClobberingOperandBundles())
- FMRB |= FunctionModRefBehavior::writeOnly();
- Min &= FMRB;
+ FuncME |= MemoryEffects::writeOnly();
+ Min &= FuncME;
}
return Min;
@@ -781,14 +781,14 @@ FunctionModRefBehavior BasicAAResult::getModRefBehavior(const CallBase *Call,
/// Returns the behavior when calling the given function. For use when the call
/// site is not known.
-FunctionModRefBehavior BasicAAResult::getModRefBehavior(const Function *F) {
+MemoryEffects BasicAAResult::getModRefBehavior(const Function *F) {
switch (F->getIntrinsicID()) {
case Intrinsic::experimental_guard:
case Intrinsic::experimental_deoptimize:
// These intrinsics can read arbitrary memory, and additionally modref
// inaccessible memory to model control dependence.
- return FunctionModRefBehavior::readOnly() |
- FunctionModRefBehavior::inaccessibleMemOnly(ModRefInfo::ModRef);
+ return MemoryEffects::readOnly() |
+ MemoryEffects::inaccessibleMemOnly(ModRefInfo::ModRef);
}
return getModRefBehaviorFromAttrs(F->getAttributes().getFnAttrs());
diff --git a/llvm/lib/Analysis/GlobalsModRef.cpp b/llvm/lib/Analysis/GlobalsModRef.cpp
index 5e175aa87eaa0..bfa8e55e54576 100644
--- a/llvm/lib/Analysis/GlobalsModRef.cpp
+++ b/llvm/lib/Analysis/GlobalsModRef.cpp
@@ -238,9 +238,9 @@ void GlobalsAAResult::DeletionCallbackHandle::deleted() {
// This object is now destroyed!
}
-FunctionModRefBehavior GlobalsAAResult::getModRefBehavior(const Function *F) {
+MemoryEffects GlobalsAAResult::getModRefBehavior(const Function *F) {
if (FunctionInfo *FI = getFunctionInfo(F))
- return FunctionModRefBehavior(FI->getModRefInfo());
+ return MemoryEffects(FI->getModRefInfo());
return AAResultBase::getModRefBehavior(F);
}
@@ -577,8 +577,7 @@ void GlobalsAAResult::AnalyzeCallGraph(CallGraph &CG, Module &M) {
// Don't let dbg intrinsics affect alias info.
continue;
- FunctionModRefBehavior Behaviour =
- AAResultBase::getModRefBehavior(Callee);
+ MemoryEffects Behaviour = AAResultBase::getModRefBehavior(Callee);
FI.addModRefInfo(Behaviour.getModRef());
}
}
diff --git a/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp b/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp
index 30eb1bea07e6f..3c742af4b3759 100644
--- a/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/ObjCARCAliasAnalysis.cpp
@@ -92,13 +92,13 @@ bool ObjCARCAAResult::pointsToConstantMemory(const MemoryLocation &Loc,
return false;
}
-FunctionModRefBehavior ObjCARCAAResult::getModRefBehavior(const Function *F) {
+MemoryEffects ObjCARCAAResult::getModRefBehavior(const Function *F) {
if (!EnableARCOpts)
return AAResultBase::getModRefBehavior(F);
switch (GetFunctionClass(F)) {
case ARCInstKind::NoopCast:
- return FunctionModRefBehavior::none();
+ return MemoryEffects::none();
default:
break;
}
diff --git a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
index d2d7044962de7..abc8a6f1fbead 100644
--- a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
@@ -404,9 +404,8 @@ bool TypeBasedAAResult::pointsToConstantMemory(const MemoryLocation &Loc,
return AAResultBase::pointsToConstantMemory(Loc, AAQI, OrLocal);
}
-FunctionModRefBehavior
-TypeBasedAAResult::getModRefBehavior(const CallBase *Call,
- AAQueryInfo &AAQI) {
+MemoryEffects TypeBasedAAResult::getModRefBehavior(const CallBase *Call,
+ AAQueryInfo &AAQI) {
if (!EnableTBAA)
return AAResultBase::getModRefBehavior(Call, AAQI);
@@ -414,12 +413,12 @@ TypeBasedAAResult::getModRefBehavior(const CallBase *Call,
if (const MDNode *M = Call->getMetadata(LLVMContext::MD_tbaa))
if ((!isStructPathTBAA(M) && TBAANode(M).isTypeImmutable()) ||
(isStructPathTBAA(M) && TBAAStructTagNode(M).isTypeImmutable()))
- return FunctionModRefBehavior::none();
+ return MemoryEffects::none();
return AAResultBase::getModRefBehavior(Call, AAQI);
}
-FunctionModRefBehavior TypeBasedAAResult::getModRefBehavior(const Function *F) {
+MemoryEffects TypeBasedAAResult::getModRefBehavior(const Function *F) {
// Functions don't have metadata. Just chain to the next implementation.
return AAResultBase::getModRefBehavior(F);
}
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index 007d84a702fa9..ca277d39ba894 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -122,22 +122,22 @@ using SCCNodeSet = SmallSetVector<Function *, 8>;
/// result will be based only on AA results for the function declaration; it
/// will be assumed that some other (perhaps less optimized) version of the
/// function may be selected at link time.
-static FunctionModRefBehavior
-checkFunctionMemoryAccess(Function &F, bool ThisBody, AAResults &AAR,
- const SCCNodeSet &SCCNodes) {
- FunctionModRefBehavior OrigMRB = AAR.getModRefBehavior(&F);
- if (OrigMRB.doesNotAccessMemory())
+static MemoryEffects checkFunctionMemoryAccess(Function &F, bool ThisBody,
+ AAResults &AAR,
+ const SCCNodeSet &SCCNodes) {
+ MemoryEffects OrigME = AAR.getModRefBehavior(&F);
+ if (OrigME.doesNotAccessMemory())
// Already perfect!
- return OrigMRB;
+ return OrigME;
if (!ThisBody)
- return OrigMRB;
+ return OrigME;
- FunctionModRefBehavior MRB = FunctionModRefBehavior::none();
+ MemoryEffects ME = MemoryEffects::none();
// Inalloca and preallocated arguments are always clobbered by the call.
if (F.getAttributes().hasAttrSomewhere(Attribute::InAlloca) ||
F.getAttributes().hasAttrSomewhere(Attribute::Preallocated))
- MRB |= FunctionModRefBehavior::argMemOnly(ModRefInfo::ModRef);
+ ME |= MemoryEffects::argMemOnly(ModRefInfo::ModRef);
// Returns true if Ptr is not based on a function argument.
auto IsArgumentOrAlloca = [](const Value *Ptr) {
@@ -156,10 +156,10 @@ checkFunctionMemoryAccess(Function &F, bool ThisBody, AAResults &AAR,
if (!Call->hasOperandBundles() && Call->getCalledFunction() &&
SCCNodes.count(Call->getCalledFunction()))
continue;
- FunctionModRefBehavior CallMRB = AAR.getModRefBehavior(Call);
+ MemoryEffects CallME = AAR.getModRefBehavior(Call);
// If the call doesn't access memory, we're done.
- if (CallMRB.doesNotAccessMemory())
+ if (CallME.doesNotAccessMemory())
continue;
// A pseudo probe call shouldn't change any function attribute since it
@@ -169,17 +169,17 @@ checkFunctionMemoryAccess(Function &F, bool ThisBody, AAResults &AAR,
if (isa<PseudoProbeInst>(I))
continue;
- MRB |= CallMRB.getWithoutLoc(FunctionModRefBehavior::ArgMem);
+ ME |= CallME.getWithoutLoc(MemoryEffects::ArgMem);
// If the call accesses captured memory (currently part of "other") and
// an argument is captured (currently not tracked), then it may also
// access argument memory.
- ModRefInfo OtherMR = CallMRB.getModRef(FunctionModRefBehavior::Other);
- MRB |= FunctionModRefBehavior::argMemOnly(OtherMR);
+ ModRefInfo OtherMR = CallME.getModRef(MemoryEffects::Other);
+ ME |= MemoryEffects::argMemOnly(OtherMR);
// Check whether all pointer arguments point to local memory, and
// ignore calls that only access local memory.
- ModRefInfo ArgMR = CallMRB.getModRef(FunctionModRefBehavior::ArgMem);
+ ModRefInfo ArgMR = CallME.getModRef(MemoryEffects::ArgMem);
if (ArgMR != ModRefInfo::NoModRef) {
for (const Use &U : Call->args()) {
const Value *Arg = U;
@@ -193,9 +193,9 @@ checkFunctionMemoryAccess(Function &F, bool ThisBody, AAResults &AAR,
if (AAR.pointsToConstantMemory(Loc, /*OrLocal=*/true))
continue;
- MRB |= FunctionModRefBehavior::argMemOnly(ArgMR);
+ ME |= MemoryEffects::argMemOnly(ArgMR);
if (!IsArgumentOrAlloca(Loc.Ptr))
- MRB |= FunctionModRefBehavior(FunctionModRefBehavior::Other, ArgMR);
+ ME |= MemoryEffects(MemoryEffects::Other, ArgMR);
}
}
continue;
@@ -213,7 +213,7 @@ checkFunctionMemoryAccess(Function &F, bool ThisBody, AAResults &AAR,
if (!Loc) {
// If no location is known, conservatively assume anything can be
// accessed.
- MRB |= FunctionModRefBehavior(MR);
+ ME |= MemoryEffects(MR);
continue;
}
@@ -223,16 +223,16 @@ checkFunctionMemoryAccess(Function &F, bool ThisBody, AAResults &AAR,
// The accessed location can be either only argument memory, or
// argument & other memory, but never inaccessible memory.
- MRB |= FunctionModRefBehavior::argMemOnly(MR);
+ ME |= MemoryEffects::argMemOnly(MR);
if (!IsArgumentOrAlloca(Loc->Ptr))
- MRB |= FunctionModRefBehavior(FunctionModRefBehavior::Other, MR);
+ ME |= MemoryEffects(MemoryEffects::Other, MR);
}
- return OrigMRB & MRB;
+ return OrigME & ME;
}
-FunctionModRefBehavior llvm::computeFunctionBodyMemoryAccess(Function &F,
- AAResults &AAR) {
+MemoryEffects llvm::computeFunctionBodyMemoryAccess(Function &F,
+ AAResults &AAR) {
return checkFunctionMemoryAccess(F, /*ThisBody=*/true, AAR, {});
}
@@ -240,28 +240,27 @@ FunctionModRefBehavior llvm::computeFunctionBodyMemoryAccess(Function &F,
template <typename AARGetterT>
static void addMemoryAttrs(const SCCNodeSet &SCCNodes, AARGetterT &&AARGetter,
SmallSet<Function *, 8> &Changed) {
- FunctionModRefBehavior FMRB = FunctionModRefBehavior::none();
+ MemoryEffects ME = MemoryEffects::none();
for (Function *F : SCCNodes) {
// Call the callable parameter to look up AA results for this function.
AAResults &AAR = AARGetter(*F);
// Non-exact function definitions may not be selected at link time, and an
// alternative version that writes to memory may be selected. See the
// comment on GlobalValue::isDefinitionExact for more details.
- FMRB |= checkFunctionMemoryAccess(*F, F->hasExactDefinition(), AAR,
- SCCNodes);
+ ME |= checkFunctionMemoryAccess(*F, F->hasExactDefinition(), AAR, SCCNodes);
// Reached bottom of the lattice, we will not be able to improve the result.
- if (FMRB == FunctionModRefBehavior::unknown())
+ if (ME == MemoryEffects::unknown())
return;
}
- ModRefInfo MR = FMRB.getModRef();
+ ModRefInfo MR = ME.getModRef();
for (Function *F : SCCNodes) {
if (F->doesNotAccessMemory())
// Already perfect!
continue;
- if (FMRB.doesNotAccessMemory()) {
+ if (ME.doesNotAccessMemory()) {
// For readnone, remove all other memory attributes.
AttributeMask AttrsToRemove;
AttrsToRemove.addAttribute(Attribute::ReadOnly);
@@ -283,20 +282,20 @@ static void addMemoryAttrs(const SCCNodeSet &SCCNodes, AARGetterT &&AARGetter,
AttrsToRemove.addAttribute(Attribute::ArgMemOnly);
AttrsToRemove.addAttribute(Attribute::InaccessibleMemOnly);
AttrsToRemove.addAttribute(Attribute::InaccessibleMemOrArgMemOnly);
- if (FMRB.onlyAccessesArgPointees()) {
+ if (ME.onlyAccessesArgPointees()) {
if (!F->onlyAccessesArgMemory()) {
NumArgMemOnly++;
F->removeFnAttrs(AttrsToRemove);
F->addFnAttr(Attribute::ArgMemOnly);
Changed.insert(F);
}
- } else if (FMRB.onlyAccessesInaccessibleMem()) {
+ } else if (ME.onlyAccessesInaccessibleMem()) {
if (!F->onlyAccessesInaccessibleMemory()) {
F->removeFnAttrs(AttrsToRemove);
F->addFnAttr(Attribute::InaccessibleMemOnly);
Changed.insert(F);
}
- } else if (FMRB.onlyAccessesInaccessibleOrArgMem() &&
+ } else if (ME.onlyAccessesInaccessibleOrArgMem() &&
!F->onlyAccessesInaccessibleMemOrArgMem()) {
F->removeFnAttrs(AttrsToRemove);
F->addFnAttr(Attribute::InaccessibleMemOrArgMemOnly);
diff --git a/llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp b/llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp
index 4a96f58997776..12c4bf38a4fe0 100644
--- a/llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp
+++ b/llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp
@@ -48,10 +48,10 @@ bool llvm::objcarc::CanAlterRefCount(const Instruction *Inst, const Value *Ptr,
const auto *Call = cast<CallBase>(Inst);
// See if AliasAnalysis can help us with the call.
- FunctionModRefBehavior MRB = PA.getAA()->getModRefBehavior(Call);
- if (MRB.onlyReadsMemory())
+ MemoryEffects ME = PA.getAA()->getModRefBehavior(Call);
+ if (ME.onlyReadsMemory())
return false;
- if (MRB.onlyAccessesArgPointees()) {
+ if (ME.onlyAccessesArgPointees()) {
for (const Value *Op : Call->args()) {
if (IsPotentialRetainableObjPtr(Op, *PA.getAA()) && PA.related(Ptr, Op))
return true;
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index edd7017941af9..208d6a1b56a51 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -1212,7 +1212,7 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT,
return true;
// Handle simple cases by querying alias analysis.
- FunctionModRefBehavior Behavior = AA->getModRefBehavior(CI);
+ MemoryEffects Behavior = AA->getModRefBehavior(CI);
if (Behavior.doesNotAccessMemory())
return true;
if (Behavior.onlyReadsMemory()) {
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index da1ce85a54103..ad1a001eb7fc0 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1233,13 +1233,13 @@ static void AddAliasScopeMetadata(CallBase &CB, ValueToValueMapTy &VMap,
IsFuncCall = true;
if (CalleeAAR) {
- FunctionModRefBehavior MRB = CalleeAAR->getModRefBehavior(Call);
+ MemoryEffects ME = CalleeAAR->getModRefBehavior(Call);
// We'll retain this knowledge without additional metadata.
- if (MRB.onlyAccessesInaccessibleMem())
+ if (ME.onlyAccessesInaccessibleMem())
continue;
- if (MRB.onlyAccessesArgPointees())
+ if (ME.onlyAccessesArgPointees())
IsArgMemOnlyCall = true;
}
diff --git a/llvm/unittests/Analysis/GlobalsModRefTest.cpp b/llvm/unittests/Analysis/GlobalsModRefTest.cpp
index 821180c713d82..457b31729d820 100644
--- a/llvm/unittests/Analysis/GlobalsModRefTest.cpp
+++ b/llvm/unittests/Analysis/GlobalsModRefTest.cpp
@@ -52,7 +52,7 @@ TEST(GlobalsModRef, OptNone) {
auto AAR = GlobalsAAResult::analyzeModule(*M, GetTLI, CG);
- EXPECT_EQ(FunctionModRefBehavior::unknown(), AAR.getModRefBehavior(&F1));
- EXPECT_EQ(FunctionModRefBehavior::none(), AAR.getModRefBehavior(&F2));
- EXPECT_EQ(FunctionModRefBehavior::readOnly(), AAR.getModRefBehavior(&F3));
+ EXPECT_EQ(MemoryEffects::unknown(), AAR.getModRefBehavior(&F1));
+ EXPECT_EQ(MemoryEffects::none(), AAR.getModRefBehavior(&F2));
+ EXPECT_EQ(MemoryEffects::readOnly(), AAR.getModRefBehavior(&F3));
}
diff --git a/polly/lib/Analysis/ScopBuilder.cpp b/polly/lib/Analysis/ScopBuilder.cpp
index 0f36d2423b5de..9f6f9200bd8a5 100644
--- a/polly/lib/Analysis/ScopBuilder.cpp
+++ b/polly/lib/Analysis/ScopBuilder.cpp
@@ -1636,12 +1636,12 @@ bool ScopBuilder::buildAccessCallInst(MemAccInst Inst, ScopStmt *Stmt) {
auto *AF = SE.getConstant(IntegerType::getInt64Ty(CI->getContext()), 0);
auto *CalledFunction = CI->getCalledFunction();
- FunctionModRefBehavior FMRB = AA.getModRefBehavior(CalledFunction);
- if (FMRB.doesNotAccessMemory())
+ MemoryEffects ME = AA.getModRefBehavior(CalledFunction);
+ if (ME.doesNotAccessMemory())
return true;
- if (FMRB.onlyAccessesArgPointees()) {
- ModRefInfo ArgMR = FMRB.getModRef(FunctionModRefBehavior::ArgMem);
+ if (ME.onlyAccessesArgPointees()) {
+ ModRefInfo ArgMR = ME.getModRef(MemoryEffects::ArgMem);
auto AccType =
!isModSet(ArgMR) ? MemoryAccess::READ : MemoryAccess::MAY_WRITE;
Loop *L = LI.getLoopFor(Inst->getParent());
@@ -1665,7 +1665,7 @@ bool ScopBuilder::buildAccessCallInst(MemAccInst Inst, ScopStmt *Stmt) {
return true;
}
- if (FMRB.onlyReadsMemory()) {
+ if (ME.onlyReadsMemory()) {
GlobalReads.emplace_back(Stmt, CI);
return true;
}
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 7c80a74040c48..dbdde2986ac83 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -708,8 +708,8 @@ bool ScopDetection::isValidCallInst(CallInst &CI,
}
if (AllowModrefCall) {
- FunctionModRefBehavior FMRB = AA.getModRefBehavior(CalledFunction);
- if (FMRB.onlyAccessesArgPointees()) {
+ MemoryEffects ME = AA.getModRefBehavior(CalledFunction);
+ if (ME.onlyAccessesArgPointees()) {
for (const auto &Arg : CI.args()) {
if (!Arg->getType()->isPointerTy())
continue;
@@ -735,7 +735,7 @@ bool ScopDetection::isValidCallInst(CallInst &CI,
return true;
}
- if (FMRB.onlyReadsMemory()) {
+ if (ME.onlyReadsMemory()) {
// Implicitly disable delinearization since we have an unknown
// accesses with an unknown access function.
Context.HasUnknownAccess = true;
More information about the llvm-commits
mailing list