summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-11-10 18:17:28 +0000
committerDan Gohman <gohman@apple.com>2010-11-10 18:17:28 +0000
commit066c1bb1e9d3510029ec82c433667020a7af0e44 (patch)
treeb6fc52fea4c8c93c8d316fd77ca000bc3be94705 /llvm
parent08feef886171032cc854330746aa644023c26c92 (diff)
downloadbcm5719-llvm-066c1bb1e9d3510029ec82c433667020a7af0e44.tar.gz
bcm5719-llvm-066c1bb1e9d3510029ec82c433667020a7af0e44.zip
Add a doesAccessArgPointees helper function, and update code to use
it, and to be consistent. llvm-svn: 118692
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Analysis/AliasAnalysis.h8
-rw-r--r--llvm/lib/Analysis/AliasAnalysis.cpp46
-rw-r--r--llvm/lib/Transforms/IPO/FunctionAttrs.cpp2
3 files changed, 33 insertions, 23 deletions
diff --git a/llvm/include/llvm/Analysis/AliasAnalysis.h b/llvm/include/llvm/Analysis/AliasAnalysis.h
index 12b2090b174..5a1c53cd1fa 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -283,6 +283,14 @@ public:
return !(MRB & Anywhere & ~ArgumentPointees);
}
+ /// doesAccessArgPointees - Return true if functions with the specified
+ /// behavior are known to potentially read or write from objects pointed
+ /// to be their pointer-typed arguments (with arbitrary offsets).
+ ///
+ static bool doesAccessArgPointees(ModRefBehavior MRB) {
+ return (MRB & ModRef) && (MRB & 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.
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index 363da9fcee6..9c0bded3721 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -78,15 +78,15 @@ AliasAnalysis::getModRefInfo(ImmutableCallSite CS,
if (onlyReadsMemory(MRB))
Mask = Ref;
- if (MRB == AccessesArguments ||
- MRB == AccessesArgumentsReadonly) {
+ if (onlyAccessesArgPointees(MRB)) {
bool doesAlias = false;
- for (ImmutableCallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
- AI != AE; ++AI)
- if (!isNoAlias(Location(*AI), Loc)) {
- doesAlias = true;
- break;
- }
+ if (doesAccessArgPointees(MRB))
+ for (ImmutableCallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
+ AI != AE; ++AI)
+ if (!isNoAlias(Location(*AI), Loc)) {
+ doesAlias = true;
+ break;
+ }
if (!doesAlias)
return NoModRef;
@@ -130,27 +130,29 @@ AliasAnalysis::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) {
// If CS2 only access memory through arguments, accumulate the mod/ref
// information from CS1's references to the memory referenced by
// CS2's arguments.
- if (CS2B == AccessesArguments || CS2B == AccessesArgumentsReadonly) {
+ if (onlyAccessesArgPointees(CS2B)) {
AliasAnalysis::ModRefResult R = NoModRef;
- for (ImmutableCallSite::arg_iterator
- I = CS2.arg_begin(), E = CS2.arg_end(); I != E; ++I) {
- R = ModRefResult((R | getModRefInfo(CS1, *I, UnknownSize)) & Mask);
- if (R == Mask)
- break;
- }
+ if (doesAccessArgPointees(CS2B))
+ for (ImmutableCallSite::arg_iterator
+ I = CS2.arg_begin(), E = CS2.arg_end(); I != E; ++I) {
+ R = ModRefResult((R | getModRefInfo(CS1, *I, UnknownSize)) & Mask);
+ if (R == Mask)
+ break;
+ }
return R;
}
// If CS1 only accesses memory through arguments, check if CS2 references
// any of the memory referenced by CS1's arguments. If not, return NoModRef.
- if (CS1B == AccessesArguments || CS1B == AccessesArgumentsReadonly) {
+ if (onlyAccessesArgPointees(CS1B)) {
AliasAnalysis::ModRefResult R = NoModRef;
- for (ImmutableCallSite::arg_iterator
- I = CS1.arg_begin(), E = CS1.arg_end(); I != E; ++I)
- if (getModRefInfo(CS2, *I, UnknownSize) != NoModRef) {
- R = Mask;
- break;
- }
+ if (doesAccessArgPointees(CS1B))
+ for (ImmutableCallSite::arg_iterator
+ I = CS1.arg_begin(), E = CS1.arg_end(); I != E; ++I)
+ if (getModRefInfo(CS2, *I, UnknownSize) != NoModRef) {
+ R = Mask;
+ break;
+ }
if (R == NoModRef)
return R;
}
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index 2e3440066e6..bb3ee465716 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -133,7 +133,7 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) {
// figure out something.
if (AliasAnalysis::onlyAccessesArgPointees(MRB)) {
// If the call does access argument pointees, check each argument.
- if (MRB & AliasAnalysis::AccessesArguments)
+ if (AliasAnalysis::doesAccessArgPointees(MRB))
// Check whether all pointer arguments point to local memory, and
// ignore calls that only access local memory.
for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
OpenPOWER on IntegriCloud