[llvm-commits] [llvm] r118687 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Transforms/IPO/FunctionAttrs.cpp
Dan Gohman
gohman at apple.com
Wed Nov 10 09:34:04 PST 2010
Author: djg
Date: Wed Nov 10 11:34:04 2010
New Revision: 118687
URL: http://llvm.org/viewvc/llvm-project?rev=118687&view=rev
Log:
Factor out the code for testing whether a function accesses
arbitrary memory into a helper function, and adjust some comments.
Modified:
llvm/trunk/include/llvm/Analysis/AliasAnalysis.h
llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
Modified: llvm/trunk/include/llvm/Analysis/AliasAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/AliasAnalysis.h?rev=118687&r1=118686&r2=118687&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/AliasAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/AliasAnalysis.h Wed Nov 10 11:34:04 2010
@@ -268,14 +268,21 @@
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.
Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=118687&r1=118686&r2=118687&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Wed Nov 10 11:34:04 2010
@@ -131,9 +131,8 @@
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.
More information about the llvm-commits
mailing list