Teach AliasAnalysis about AccessesArgumentsReadonly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118621 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2010-11-09 20:06:55 +00:00
parent cd93f3bbb9
commit c07661c1fa

View File

@ -75,9 +75,11 @@ AliasAnalysis::getModRefInfo(ImmutableCallSite CS,
return NoModRef; return NoModRef;
ModRefResult Mask = ModRef; ModRefResult Mask = ModRef;
if (MRB == OnlyReadsMemory) if (onlyReadsMemory(MRB))
Mask = Ref; Mask = Ref;
else if (MRB == AliasAnalysis::AccessesArguments) {
if (MRB == AccessesArguments ||
MRB == AccessesArgumentsReadonly) {
bool doesAlias = false; bool doesAlias = false;
for (ImmutableCallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end(); for (ImmutableCallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
AI != AE; ++AI) AI != AE; ++AI)
@ -115,20 +117,20 @@ AliasAnalysis::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) {
if (CS2B == DoesNotAccessMemory) return NoModRef; if (CS2B == DoesNotAccessMemory) return NoModRef;
// If they both only read from memory, there is no dependence. // If they both only read from memory, there is no dependence.
if (CS1B == OnlyReadsMemory && CS2B == OnlyReadsMemory) if (onlyReadsMemory(CS1B) && onlyReadsMemory(CS2B))
return NoModRef; return NoModRef;
AliasAnalysis::ModRefResult Mask = ModRef; AliasAnalysis::ModRefResult Mask = ModRef;
// If CS1 only reads memory, the only dependence on CS2 can be // If CS1 only reads memory, the only dependence on CS2 can be
// from CS1 reading memory written by CS2. // from CS1 reading memory written by CS2.
if (CS1B == OnlyReadsMemory) if (onlyReadsMemory(CS1B))
Mask = ModRefResult(Mask & Ref); Mask = ModRefResult(Mask & Ref);
// If CS2 only access memory through arguments, accumulate the mod/ref // If CS2 only access memory through arguments, accumulate the mod/ref
// information from CS1's references to the memory referenced by // information from CS1's references to the memory referenced by
// CS2's arguments. // CS2's arguments.
if (CS2B == AccessesArguments) { if (CS2B == AccessesArguments || CS2B == AccessesArgumentsReadonly) {
AliasAnalysis::ModRefResult R = NoModRef; AliasAnalysis::ModRefResult R = NoModRef;
for (ImmutableCallSite::arg_iterator for (ImmutableCallSite::arg_iterator
I = CS2.arg_begin(), E = CS2.arg_end(); I != E; ++I) { I = CS2.arg_begin(), E = CS2.arg_end(); I != E; ++I) {
@ -141,7 +143,7 @@ AliasAnalysis::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) {
// If CS1 only accesses memory through arguments, check if CS2 references // If CS1 only accesses memory through arguments, check if CS2 references
// any of the memory referenced by CS1's arguments. If not, return NoModRef. // any of the memory referenced by CS1's arguments. If not, return NoModRef.
if (CS1B == AccessesArguments) { if (CS1B == AccessesArguments || CS1B == AccessesArgumentsReadonly) {
AliasAnalysis::ModRefResult R = NoModRef; AliasAnalysis::ModRefResult R = NoModRef;
for (ImmutableCallSite::arg_iterator for (ImmutableCallSite::arg_iterator
I = CS1.arg_begin(), E = CS1.arg_end(); I != E; ++I) I = CS1.arg_begin(), E = CS1.arg_end(); I != E; ++I)