From 42c31a70735e55bf82e66a9315c97d1821c9a798 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 10 Nov 2010 01:02:18 +0000 Subject: Make ModRefBehavior a lattice. Use this to clean up AliasAnalysis chaining and simplify FunctionAttrs' GetModRefBehavior logic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118660 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/AliasAnalysis.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'include/llvm/Analysis/AliasAnalysis.h') diff --git a/include/llvm/Analysis/AliasAnalysis.h b/include/llvm/Analysis/AliasAnalysis.h index 841513b..6b716dd 100644 --- a/include/llvm/Analysis/AliasAnalysis.h +++ b/include/llvm/Analysis/AliasAnalysis.h @@ -175,6 +175,9 @@ public: /// enum ModRefResult { NoModRef = 0, Ref = 1, Mod = 2, ModRef = 3 }; + /// These values define additional bits used to define the + /// ModRefBehavior values. + enum { Nowhere = 0, ArgumentPointees = 4, Anywhere = 8 | ArgumentPointees }; /// ModRefBehavior - Summary of how a function affects memory in the program. /// Loads from constant globals are not considered memory accesses for this @@ -187,20 +190,20 @@ public: /// This property corresponds to the GCC 'const' attribute. /// This property corresponds to the LLVM IR 'readnone' attribute. /// This property corresponds to the IntrNoMem LLVM intrinsic flag. - DoesNotAccessMemory, + DoesNotAccessMemory = Nowhere | NoModRef, /// AccessesArgumentsReadonly - This function loads through function /// arguments and does not perform any non-local stores or volatile /// loads. /// /// This property corresponds to the IntrReadArgMem LLVM intrinsic flag. - AccessesArgumentsReadonly, + AccessesArgumentsReadonly = ArgumentPointees | Ref, /// AccessesArguments - This function accesses function arguments in well /// known (possibly volatile) ways, but does not access any other memory. /// /// This property corresponds to the IntrReadWriteArgMem LLVM intrinsic flag. - AccessesArguments, + AccessesArguments = ArgumentPointees | ModRef, /// OnlyReadsMemory - This function does not perform any non-local stores or /// volatile loads, but may read from any memory location. @@ -208,11 +211,11 @@ public: /// This property corresponds to the GCC 'pure' attribute. /// This property corresponds to the LLVM IR 'readonly' attribute. /// This property corresponds to the IntrReadMem LLVM intrinsic flag. - OnlyReadsMemory, + OnlyReadsMemory = Anywhere | Ref, /// UnknownModRefBehavior - This indicates that the function could not be /// classified into one of the behaviors above. - UnknownModRefBehavior + UnknownModRefBehavior = Anywhere | ModRef }; /// getModRefBehavior - Return the behavior when calling the given call site. @@ -270,12 +273,9 @@ public: /// true. For use when the call site is not known. /// static bool onlyReadsMemory(ModRefBehavior MRB) { - return MRB == DoesNotAccessMemory || - MRB == AccessesArgumentsReadonly || - MRB == OnlyReadsMemory; + return !(MRB & Mod); } - /// 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. -- cgit v1.1