This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] fix PR middle-end/44204
On Fri, May 21, 2010 at 05:42:57AM -0700, Nathan Froyd wrote:
> On Fri, May 21, 2010 at 11:12:52AM +0200, Richard Guenther wrote:
> > On Thu, May 20, 2010 at 10:27 PM, Nathan Froyd <froydnj@codesourcery.com> wrote:
> > No. Please fix the caller(s).
>
> OK, lone caller adjusted. Tested on x86_64-unknown-linux-gnu. OK to
> commit?
That means md builtins with zero arguments can't be folded. Not sure if any
targets has them, but if yes, it should have the possibility to fold them.
So, IMHO for nargs == 0 you should instead call fold_builtin target hook
with a pointer to some tree, like &error_mark_node. The folder can't
dereference it nor change it obviously.
So
return targetm.fold_builtin (fndecl, nargs,
nargs > 0
? gimple_call_arg_ptr (stmt, 0)
: &error_mark_node, ignore);
>
> -Nathan
>
> PR middle-end/44204
> * builtins.c (fold_call_stmt): Don't try to fold zero-argument
> gimple_calls.
>
> Index: builtins.c
> ===================================================================
> --- builtins.c (revision 159635)
> +++ builtins.c (working copy)
> @@ -13698,8 +13698,12 @@ fold_call_stmt (gimple stmt, bool ignore
> return NULL_TREE;
> if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
> {
> - return targetm.fold_builtin (fndecl, nargs,
> - gimple_call_arg_ptr (stmt, 0), ignore);
> + if (nargs > 0)
> + return targetm.fold_builtin (fndecl, nargs,
> + gimple_call_arg_ptr (stmt, 0),
> + ignore);
> + else
> + return NULL_TREE;
> }
> else
> {
> Index: ChangeLog
> ===================================================================
Jakub