This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix ICE with undeclared memcmp called with long long last argument (PR middle-end/40291)


On Fri, May 29, 2009 at 05:19:58PM +0200, Richard Guenther wrote:
> On Fri, May 29, 2009 at 5:00 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> > --- gcc/builtins.c.jj ? 2009-05-21 15:59:15.000000000 +0200
> > +++ gcc/builtins.c ? ? ?2009-05-29 14:43:21.000000000 +0200
> > @@ -4189,7 +4189,7 @@ expand_builtin_memcmp (tree exp, rtx tar
> >
> > ? ? arg1_rtx = get_memory_rtx (arg1, len);
> > ? ? arg2_rtx = get_memory_rtx (arg2, len);
> > - ? ?arg3_rtx = expand_normal (len);
> > + ? ?arg3_rtx = expand_normal (fold_convert (sizetype, len));
> 
> shouldn't that be size_type_node?  Why do we register the function with
> the wrong/missing prototype as builtin at all?

Does it matter?  I've used sizetype, because expand_builtin_strncmp does
as well and because even expand_builtin_memcmp uses it a few lines below:
      emit_library_call_value (memcmp_libfunc, result, LCT_PURE,
                               TYPE_MODE (integer_type_node), 3,
                               XEXP (arg1_rtx, 0), Pmode,
                               XEXP (arg2_rtx, 0), Pmode,
                               convert_to_mode (TYPE_MODE (sizetype), arg3_rtx,
                                                TYPE_UNSIGNED (sizetype)),
                               TYPE_MODE (sizetype));
As to why we register this as a builtin even without prototype, I guess the
reason is primarily that whether something is or is not builtin is a
property of a FUNCTION_DECL (which should be just one for each function),
not of the caller, and builtins have initially FUNCTION_DECLs built from
builtins.def with BUILT_IN_NORMAL which are waiting for duplicate_decls that
merge them with a prototype.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]