[llvm-commits] [llvm] r63718 - in /llvm/trunk: lib/Analysis/AliasAnalysis.cpp lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/cas.ll

Chris Lattner clattner at apple.com
Wed Feb 4 13:45:04 PST 2009


On Feb 3, 2009, at 9:16 PM, Owen Anderson wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=63718&view=rev
> Log:
> Finish making AliasAnalysis aware of the fact that most atomic  
> intrinsics only dereference their arguments, and enhance
> BasicAA to make use of this fact when computing ModRef info.

Hi Owen, thanks for working on this.

> @@ -150,6 +150,27 @@
> AliasAnalysis::ModRefBehavior
> AliasAnalysis::getModRefBehavior(Function *F,
>                                  std::vector<PointerAccessInfo>  
> *Info) {
>
> +  if (F->isIntrinsic()) {
> +    switch (F->getIntrinsicID()) {

Handling of specific intrinsics like this should go into basicaa, not  
AliasAnalysis.  You also duplicate the same code into two methods,  
please don't do this.  Intead, add a static isCASBuiltin(ID) function  
or something.

> +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Tue Feb  3  
> 23:16:46 2009
> @@ -256,6 +256,22 @@
> //
> AliasAnalysis::ModRefResult
> BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned  
> Size) {
> +  // If the function only accesses its arguments, it suffices to  
> check that
> +  // P does not alias any of those arguments.
> +  if (AliasAnalysis::getModRefBehavior(CS, 0) ==
> +      AliasAnalysis::AccessesArguments) {
> +    bool doesAlias = false;
> +    for (CallSite::arg_iterator AI = CS.arg_begin(), AE =  
> CS.arg_end();
> +         AI != AE; ++AI)
> +      if (alias(*AI, ~0U, P, Size) != NoAlias) {
> +        doesAlias = true;
> +        break;
> +      }
> +
> +    if (!doesAlias)
> +      return NoModRef;
> +  }

This code is general and independent of the AA impl, it should go into  
AliasAnalysis, not basicaa.

-Chris




More information about the llvm-commits mailing list