[llvm-commits] [llvm] r92853 - in /llvm/trunk/lib/Transforms: InstCombine/InstCombineCalls.cpp Scalar/SimplifyLibCalls.cpp

Chris Lattner clattner at apple.com
Fri Jan 8 10:16:29 PST 2010


On Jan 6, 2010, at 12:04 PM, Eric Christopher wrote:
> Author: echristo
> Date: Wed Jan  6 14:04:44 2010
> New Revision: 92853
>
> URL: http://llvm.org/viewvc/llvm-project?rev=92853&view=rev
> Log:
> Move the object size intrinsic optimization to inst-combine and make
> it work for any integer size return type.

Thanks Eric,

> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Wed  
> Jan  6 14:04:44 2010
> @@ -632,6 +632,18 @@
>       return EraseInstFromFunction(CI);
>     break;
>   }
> +  case Intrinsic::objectsize: {
> +    ConstantInt *Const = dyn_cast<ConstantInt>(II->getOperand(2));
> +
> +    if (!Const) return 0;

LangRef requires this to be a constantint, so you can use cast<> and  
drop the check for null.

> +
> +    const Type *Ty = CI.getType();
> +
> +    if (Const->getZExtValue() == 0)
> +      return ReplaceInstUsesWith(CI, Constant::getAllOnesValue(Ty));
> +    else
> +      return ReplaceInstUsesWith(CI, ConstantInt::get(Ty, 0));

I still don't "get" this.  The idea of objectsize is that we want to  
propagate it to CodeGenPrepare (which happens right before isel).  CGP  
should be doing this to remove the intrinsics.  Instead of zapping  
them, instcombine should be trying to infer the size of the object and  
replacing them with a real answer.  With your current implementation,  
I don't see how it is any better than folding it to "don't know" in  
the front-end.

-Chris




More information about the llvm-commits mailing list