[llvm-commits] PR2765 Patch

Matthijs Kooijman matthijs at stdin.nl
Tue Oct 7 14:02:48 PDT 2008


Hi Andrew,

> +    for (Function::const_arg_iterator I = OldFunc->arg_begin(),
> +           E = OldFunc->arg_end(); I != E; ++I)
> +      if (Argument* Anew = dyn_cast<Argument>(ValueMap[I]))
What does ValueMap[I] return when the argument is removed? I would expect
NULL, but in that case you should be using dyn_cast_or_null IIRC?

> +        Anew->addAttr( OldFunc->getAttributes()
> +                       .getParamAttributes(I->getArgNo() + 1));
> +    NewFunc->setAttributes(NewFunc->getAttributes()
> +                           .addAttr(0, OldFunc->getAttributes()
> +                                     .getRetAttributes()));
> +    NewFunc->setAttributes(NewFunc->getAttributes()
> +                           .addAttr(~0, OldFunc->getAttributes()
> +                                     .getFnAttributes()));
There is also a Function::addAttribute. Any particular reason not to use it?
For the ~0 case, using Function::addFnAttr might be even better, since it
prevents the use of the ~0 magic number.

Perhaps there should be a addReturnAttr as well? I can't find it, so perhaps
you could add it as well (probably submit that as a separate patch).
Alternatively, I guess Devang should have a look at this, since he was working
on this.

Gr.

Matthijs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20081007/192ab361/attachment.sig>


More information about the llvm-commits mailing list