[llvm-commits] [llvm] r92829 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Analysis/AliasAnalysis.cpp lib/Target/README.txt lib/Transforms/IPO/FunctionAttrs.cpp test/Transforms/FunctionAttrs/2008-10-04-LocalMemory.ll utils/TableGen/IntrinsicEmitter.cpp

Chris Lattner clattner at apple.com
Fri Jan 8 10:24:18 PST 2010


On Jan 6, 2010, at 12:45 AM, Duncan Sands wrote:

> Author: baldrick
> Date: Wed Jan  6 02:45:52 2010
> New Revision: 92829
>
> URL: http://llvm.org/viewvc/llvm-project?rev=92829&view=rev
> Log:
> Partially address a README by having functionattrs consider calls to
> memcpy, memset and other intrinsics that only access their arguments
> to be readnone if the intrinsic's arguments all point to local memory.
> This improves the testcase in the README to readonly, but it could in
> theory be made readnone, however this would involve more sophisticated
> analysis that looks through the memcpy.

Very nice Duncan.  There are two different ways to improve this to  
readnone. First, you could special case memcpy/memset/memcmp/etc in  
function attrs.  Obviously ugly :)

A better way is to call AA->getModRefBehavior() on the call site  
itself instead of calling AliasAnalysis::getModRefBehavior(id).  This  
form of the method takes an optional vector (should be a  
smallvectorimpl, but alas) of PointerAccessInfo.  When  
getModRefBehavior returns 'accesses arguments', it is supposed to fill  
in this vector.  You then loop over each of the results to find out  
how it accesses the arguments allowing the more precise analysis.

The nice thing about this approach is that it means we just teach  
basicaa to implement getModRefBehavior more aggressively for whatever  
builtin functions we want, and all transformations that want to know  
this stuff can reuse the logic.

-Chris



More information about the llvm-commits mailing list