[llvm-commits] [llvm] r45913 - in /llvm/trunk: include/llvm/Instructions.h lib/VMCore/Instructions.cpp

Chris Lattner clattner at apple.com
Sat Jan 12 11:00:48 PST 2008


> URL: http://llvm.org/viewvc/llvm-project?rev=45913&view=rev
> Log:
> Add hasByValArgument() to test if a call instruction has byval  
> argument(s).

Ok.

> +/// @brief Determine if any call argument is an aggregate passed by  
> value.
> +bool CallInst::hasByValArgument() const {
> +  const Value *Callee = getCalledValue();
> +  const PointerType *CalleeTy = cast<PointerType>(Callee->getType());
> +  const FunctionType *FTy = cast<FunctionType>(CalleeTy- 
> >getElementType());
> +  for (unsigned i = 1, e = FTy->getNumParams()+1; i != e; ++i)

Instead of walking from 1 .. FTy->getNumParams(), you should walk from  
1 .. CI->getNumOperands().  This handles varargs right and is simpler.

-Chris

>
> +    if (paramHasAttr(i, ParamAttr::ByVal))
> +      return true;
> +  return false;
> +}
> +
> void CallInst::setDoesNotThrow(bool doesNotThrow) {
>   const ParamAttrsList *PAL = getParamAttrs();
>   if (doesNotThrow)
>
>
> _______________________________________________
> 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