return onlyReadsMemory(getModRefBehavior(F));
}
- /// onlyReadsMemory - If the functions with the specified behavior are known
- /// to only read from non-volatile memory (or not access memory at all), return
- /// true. For use when the call site is not known.
+ /// onlyReadsMemory - Return true if functions with the specified behavior are
+ /// known to only read from non-volatile memory (or not access memory at all).
///
static bool onlyReadsMemory(ModRefBehavior MRB) {
return !(MRB & Mod);
}
+ /// onlyAccessesArgPointees - Return true if functions with the specified
+ /// behavior are known to read at most from objects pointed to by their
+ /// pointer-typed arguments (with arbitrary offsets).
+ ///
+ static bool onlyAccessesArgPointees(ModRefBehavior MRB) {
+ return !(MRB & Anywhere & ~ArgumentPointees);
+ }
+
/// getModRefInfo - Return information about whether or not an instruction may
/// read or write the specified memory location. An instruction
/// that doesn't read or write memory may be trivially LICM'd for example.
AliasAnalysis::ModRefBehavior MRB = AA->getModRefBehavior(CS);
// If the call doesn't access arbitrary memory, we may be able to
// figure out something.
- if (!(MRB & AliasAnalysis::Anywhere &
- ~AliasAnalysis::ArgumentPointees)) {
- // If the call accesses argument pointees, check each argument.
+ if (AliasAnalysis::onlyAccessesArgPointees(MRB)) {
+ // If the call does access argument pointees, check each argument.
if (MRB & AliasAnalysis::AccessesArguments)
// Check whether all pointer arguments point to local memory, and
// ignore calls that only access local memory.