diff options
author | Dan Gohman <gohman@apple.com> | 2010-11-09 19:56:27 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-11-09 19:56:27 +0000 |
commit | 40b6a19daa0efa5131a56aa15cc8694d3cf6171e (patch) | |
tree | 8bbf40588cb4347611b3e17d80aab8e74e0173c4 /lib/Transforms/IPO/FunctionAttrs.cpp | |
parent | e33daaaaf9d67f30b141430bffc34bbda93063d1 (diff) |
Teach FunctionAttrs about AccessesArgumentsReadonly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118617 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/FunctionAttrs.cpp')
-rw-r--r-- | lib/Transforms/IPO/FunctionAttrs.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp index a2173933ef..71671d6fe9 100644 --- a/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/lib/Transforms/IPO/FunctionAttrs.cpp @@ -152,6 +152,25 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) { } // Only reads and writes local memory. continue; + case AliasAnalysis::AccessesArgumentsReadonly: + // 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(); + CI != CE; ++CI) { + Value *Arg = *CI; + if (Arg->getType()->isPointerTy()) { + AliasAnalysis::Location Loc(Arg, + AliasAnalysis::UnknownSize, + I->getMetadata(LLVMContext::MD_tbaa)); + if (!AA->pointsToConstantMemory(Loc, /*OrLocal=*/true)) { + // Reads non-local memory. + ReadsMemory = true; + break; + } + } + } + // Only reads memory. + continue; default: // Otherwise, be conservative. break; |