[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.
This commit is contained in:
parent
a5b35dee7a
commit
1a9d9823c5
|
@ -383,10 +383,10 @@ public:
|
|||
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 @@ public:
|
|||
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 @@ public:
|
|||
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 @@ public:
|
|||
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 @@ public:
|
|||
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 @@ public:
|
|||
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,
|
||||
|
|
|
@ -83,12 +83,11 @@ public:
|
|||
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;
|
||||
|
|
|
@ -104,7 +104,7 @@ public:
|
|||
/// 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);
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
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,
|
||||
|
|
|
@ -42,9 +42,8 @@ public:
|
|||
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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue