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] improve C++ code by changing fold-const.c


On Fri, 21 May 2004, Andrew Pinski wrote:
> Here is a C example of where this can happen
> #include <stdio.h>
>
> static char* funk() {
>   return "Hello World.\n";
> }
>
> static void funky(char*(*func)()) {
>   printf("%s", func());
> }
>
> void main() {
>   funky(funk);
> }
>
> Note that before this patch there is a cast in there which causes the
> function call to be outputted as an indirect call at first and then
> converted by combine to be an direct call (because of your 2004-03-12
> patch).  Now with my patch the call to funk is converted into direct
> call as there is no cast in there.

Is this a platform specific problem or could it have been fixed recently?
On i686-pc-linux-gnu, both the C and C++ versions of your example program
contain a direct call to funk (or _Z4funkv) in .01.rtl using mainline
CVS.  This is clearly long before we reach combine.

.t10.gimple contains:

    char * (*<T263>) () func;

    func = (char * (*<T263>) ())funk;
    {
      char * T.0;

      T.0 = func ();
      printf ("%s", T.0);
    }

by .t13.lower we have:

  func = funk;
  T.0 = func ();
  printf ("%s", T.0);

and then by .t23.dce2 we have:

  T.0_2 = funk ();
  printf ("%s", T.0_2);


Perhaps, there's a better example to demonstrate this issue?
Or perhaps I'm still misunderstanding the problem?

Roger
--


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