[llvm-commits] [llvm] r84175 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

Chris Lattner clattner at apple.com
Sat Oct 17 17:04:33 PDT 2009


On Oct 15, 2009, at 12:11 AM, Nick Lewycky wrote:

> Author: nicholas
> Date: Thu Oct 15 02:11:24 2009
> New Revision: 84175
>
> URL: http://llvm.org/viewvc/llvm-project?rev=84175&view=rev
> Log:
> Teach basicaa about memcpy/memmove/memset. The length argument can  
> be used to
> improve alias results if constant, and the source pointer can't be  
> modified.

Hi Nick,

Please write some testcases that fail without this and pass with it.   
I added a placeholder in r84383.  I'm pretty sure that this is already  
handled by logic in AliasAnalysis that knows that memset only looks at  
its arguments:

   else if (MRB == 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;
   }

If this code isn't needed, please remove it.

-Chris

>
> Modified:
>    llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
>
> Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=84175&r1=84174&r2=84175&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
> +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Thu Oct 15  
> 02:11:24 2009
> @@ -310,6 +310,28 @@
>     if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(CS.getInstruction 
> ())) {
>       switch (II->getIntrinsicID()) {
>       default: break;
> +      case Intrinsic::memcpy:
> +      case Intrinsic::memmove: {
> +        unsigned Len = ~0U;
> +        if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II- 
> >getOperand(3)))
> +          Len = LenCI->getZExtValue();
> +        Value *Dest = II->getOperand(1);
> +        Value *Src = II->getOperand(2);
> +        if (alias(Dest, Len, P, Size) == NoAlias) {
> +          if (alias(Src, Len, P, Size) == NoAlias)
> +            return NoModRef;
> +          return Ref;
> +        }
> +        }
> +        break;
> +      case Intrinsic::memset:
> +        if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II- 
> >getOperand(3))) {
> +          unsigned Len = LenCI->getZExtValue();
> +          Value *Dest = II->getOperand(1);
> +          if (alias(Dest, Len, P, Size) == NoAlias)
> +            return NoModRef;
> +        }
> +        break;
>       case Intrinsic::atomic_cmp_swap:
>       case Intrinsic::atomic_swap:
>       case Intrinsic::atomic_load_add:
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list