Mod = 2,
/// The access may reference and may modify the value stored in memory.
ModRef = Ref | Mod,
+ LLVM_MARK_AS_BITMASK_ENUM(ModRef),
};
LLVM_NODISCARD inline bool isNoModRef(const ModRefInfo MRI) {
return static_cast<int>(MRI) & static_cast<int>(ModRefInfo::Ref);
}
+[[deprecated("Use operator | instead")]]
LLVM_NODISCARD inline ModRefInfo setMod(const ModRefInfo MRI) {
- return ModRefInfo(static_cast<int>(MRI) | static_cast<int>(ModRefInfo::Mod));
+ return MRI | ModRefInfo::Mod;
}
+[[deprecated("Use operator | instead")]]
LLVM_NODISCARD inline ModRefInfo setRef(const ModRefInfo MRI) {
- return ModRefInfo(static_cast<int>(MRI) | static_cast<int>(ModRefInfo::Ref));
+ return MRI | ModRefInfo::Ref;
}
+[[deprecated("Use operator & instead")]]
LLVM_NODISCARD inline ModRefInfo clearMod(const ModRefInfo MRI) {
- return ModRefInfo(static_cast<int>(MRI) & static_cast<int>(ModRefInfo::Ref));
+ return MRI & ModRefInfo::Ref;
}
+[[deprecated("Use operator & instead")]]
LLVM_NODISCARD inline ModRefInfo clearRef(const ModRefInfo MRI) {
- return ModRefInfo(static_cast<int>(MRI) & static_cast<int>(ModRefInfo::Mod));
+ return MRI & ModRefInfo::Mod;
}
+[[deprecated("Use operator | instead")]]
LLVM_NODISCARD inline ModRefInfo unionModRef(const ModRefInfo MRI1,
const ModRefInfo MRI2) {
- return ModRefInfo(static_cast<int>(MRI1) | static_cast<int>(MRI2));
+ return MRI1 | MRI2;
}
+[[deprecated("Use operator & instead")]]
LLVM_NODISCARD inline ModRefInfo intersectModRef(const ModRefInfo MRI1,
const ModRefInfo MRI2) {
- return ModRefInfo(static_cast<int>(MRI1) & static_cast<int>(MRI2));
+ return MRI1 & MRI2;
}
/// The locations at which a function might access memory.
ModRefInfo Result = ModRefInfo::ModRef;
for (const auto &AA : AAs) {
- Result = intersectModRef(Result, AA->getArgModRefInfo(Call, ArgIdx));
+ Result &= AA->getArgModRefInfo(Call, ArgIdx);
// Early-exit the moment we reach the bottom of the lattice.
if (isNoModRef(Result))
ModRefInfo Result = ModRefInfo::ModRef;
for (const auto &AA : AAs) {
- Result = intersectModRef(Result, AA->getModRefInfo(Call, Loc, AAQI));
+ Result &= AA->getModRefInfo(Call, Loc, AAQI);
// Early-exit the moment we reach the bottom of the lattice.
if (isNoModRef(Result))
return ModRefInfo::NoModRef;
if (onlyReadsMemory(MRB))
- Result = clearMod(Result);
+ Result &= ModRefInfo::Ref;
else if (onlyWritesMemory(MRB))
- Result = clearRef(Result);
+ Result &= ModRefInfo::Mod;
if (onlyAccessesArgPointees(MRB) || onlyAccessesInaccessibleOrArgMem(MRB)) {
ModRefInfo AllArgsMask = ModRefInfo::NoModRef;
MemoryLocation ArgLoc =
MemoryLocation::getForArgument(Call, ArgIdx, TLI);
AliasResult ArgAlias = alias(ArgLoc, Loc, AAQI);
- if (ArgAlias != AliasResult::NoAlias) {
- ModRefInfo ArgMask = getArgModRefInfo(Call, ArgIdx);
- AllArgsMask = unionModRef(AllArgsMask, ArgMask);
- }
+ if (ArgAlias != AliasResult::NoAlias)
+ AllArgsMask |= getArgModRefInfo(Call, ArgIdx);
}
}
// Return NoModRef if no alias found with any argument.
if (isNoModRef(AllArgsMask))
return ModRefInfo::NoModRef;
// Logical & between other AA analyses and argument analysis.
- Result = intersectModRef(Result, AllArgsMask);
+ Result &= AllArgsMask;
}
// If Loc is a constant memory location, the call definitely could not
// modify the memory location.
if (isModSet(Result) && pointsToConstantMemory(Loc, AAQI, /*OrLocal*/ false))
- Result = clearMod(Result);
+ Result &= ModRefInfo::Ref;
return Result;
}
ModRefInfo Result = ModRefInfo::ModRef;
for (const auto &AA : AAs) {
- Result = intersectModRef(Result, AA->getModRefInfo(Call1, Call2, AAQI));
+ Result &= AA->getModRefInfo(Call1, Call2, AAQI);
// Early-exit the moment we reach the bottom of the lattice.
if (isNoModRef(Result))
// If Call1 only reads memory, the only dependence on Call2 can be
// from Call1 reading memory written by Call2.
if (onlyReadsMemory(Call1B))
- Result = clearMod(Result);
+ Result &= ModRefInfo::Ref;
else if (onlyWritesMemory(Call1B))
- Result = clearRef(Result);
+ Result &= ModRefInfo::Mod;
// If Call2 only access memory through arguments, accumulate the mod/ref
// information from Call1's references to the memory referenced by
// ModRefC1 indicates what Call1 might do to Call2ArgLoc, and we use
// above ArgMask to update dependence info.
- ModRefInfo ModRefC1 = getModRefInfo(Call1, Call2ArgLoc, AAQI);
- ArgMask = intersectModRef(ArgMask, ModRefC1);
+ ArgMask &= getModRefInfo(Call1, Call2ArgLoc, AAQI);
- R = intersectModRef(unionModRef(R, ArgMask), Result);
+ R = (R | ArgMask) & Result;
if (R == Result)
break;
}
ModRefInfo ModRefC2 = getModRefInfo(Call2, Call1ArgLoc, AAQI);
if ((isModSet(ArgModRefC1) && isModOrRefSet(ModRefC2)) ||
(isRefSet(ArgModRefC1) && isModSet(ModRefC2)))
- R = intersectModRef(unionModRef(R, ArgModRefC1), Result);
+ R = (R | ArgModRefC1) & Result;
if (R == Result)
break;
++E; // Convert from inclusive to exclusive range.
for (; I != E; ++I) // Check every instruction in range
- if (isModOrRefSet(intersectModRef(getModRefInfo(&*I, Loc), Mode)))
+ if (isModOrRefSet(getModRefInfo(&*I, Loc) & Mode))
return true;
return false;
}
if (AlignedMap *P = Info.getPointer()) {
auto I = P->Map.find(&GV);
if (I != P->Map.end())
- GlobalMRI = unionModRef(GlobalMRI, I->second);
+ GlobalMRI |= I->second;
}
return GlobalMRI;
}
Info.setPointer(P);
}
auto &GlobalMRI = P->Map[&GV];
- GlobalMRI = unionModRef(GlobalMRI, NewMRI);
+ GlobalMRI |= NewMRI;
}
/// Clear a global's ModRef info. Should be used when a global is being
if (const Function *F = Call->getCalledFunction())
if (NonAddressTakenGlobals.count(GV))
if (const FunctionInfo *FI = getFunctionInfo(F))
- Known = unionModRef(FI->getModRefInfoForGlobal(*GV),
- getModRefInfoForArgument(Call, GV, AAQI));
+ Known = FI->getModRefInfoForGlobal(*GV) |
+ getModRefInfoForArgument(Call, GV, AAQI);
return Known;
}