[Bug middle-end/23828] local calling convention not used when using -fwhole-program --combine

2005-09-13 Thread pinskia at gcc dot gnu dot org

--- Additional Comments From pinskia at gcc dot gnu dot org  2005-09-13 
23:02 ---
(In reply to comment #4)
>/* We can't use regparm(3) for nested functions as these use
>   static chain pointer in third argument.  */
>if (local_regparm == 3 && DECL_CONTEXT (decl)
>&& !DECL_NO_STATIC_CHAIN (decl))
>   local_regparm = 2;

Instead of the above check, change it to:
if (local_regparm == 3 &&  DECL_STRUCT_FUNCTION (fn)->static_chain_decl)
  local_regparm = 2;

That should make it work and work better at that too because it would also help 
C++ functions which 
currently have the same issue.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23828


[Bug middle-end/23828] local calling convention not used when using -fwhole-program --combine

2005-09-13 Thread dann at godzilla dot ics dot uci dot edu

--- Additional Comments From dann at godzilla dot ics dot uci dot edu  
2005-09-13 22:57 ---
(In reply to comment #6)
> Maybe a better check would be check in the decl's function struct's 
> field
> static_chain_decl is set.

I am not sure I understand what you mean here... 

Maybe adding a test like this
TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)
should work.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23828


[Bug middle-end/23828] local calling convention not used when using -fwhole-program --combine

2005-09-13 Thread pinskia at physics dot uc dot edu

--- Additional Comments From pinskia at physics dot uc dot edu  2005-09-13 
22:49 ---
Subject: Re:  local calling convention not used when using -fwhole-program 
--combine


On Sep 13, 2005, at 6:36 PM, dann at godzilla dot ics dot uci dot edu 
wrote:

>
> --- Additional Comments From dann at godzilla dot ics dot uci dot 
> edu  2005-09-13 22:36 ---
> It looks like the -fwhole-program version of ClearLeft only passes the
> first 2 arguments to the ClearInLine call in register, the 3rd one is
> passed on the stack.
> The reason for that is this code in i386.c:ix86_function_regparm:

Maybe a better check would be check in the decl's function struct's 
field
static_chain_decl is set.

-- Pinski



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23828


Re: [Bug middle-end/23828] local calling convention not used when using -fwhole-program --combine

2005-09-13 Thread Andrew Pinski


On Sep 13, 2005, at 6:36 PM, dann at godzilla dot ics dot uci dot edu 
wrote:




--- Additional Comments From dann at godzilla dot ics dot uci dot 
edu  2005-09-13 22:36 ---

It looks like the -fwhole-program version of ClearLeft only passes the
first 2 arguments to the ClearInLine call in register, the 3rd one is
passed on the stack.
The reason for that is this code in i386.c:ix86_function_regparm:


Maybe a better check would be check in the decl's function struct's 
field

static_chain_decl is set.

-- Pinski



[Bug middle-end/23828] local calling convention not used when using -fwhole-program --combine

2005-09-13 Thread pinskia at physics dot uc dot edu

--- Additional Comments From pinskia at physics dot uc dot edu  2005-09-13 
22:41 ---
Subject: Re:  local calling convention not used when using -fwhole-program 
--combine


On Sep 13, 2005, at 6:36 PM, dann at godzilla dot ics dot uci dot edu 
wrote:

>
> But the above just fixes the symptoms, it's probably not the correct
> way to test for a nested function.

DECL_NO_STATIC_CHAIN (decl) should be true for this function but
why is it not?


/* In a FUNCTION_DECL with a nonzero DECL_CONTEXT, indicates that a
static chain is not needed.  */
#define DECL_NO_STATIC_CHAIN(NODE) \
   (FUNCTION_DECL_CHECK (NODE)->function_decl.regdecl_flag)

-- Pinski



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23828


Re: [Bug middle-end/23828] local calling convention not used when using -fwhole-program --combine

2005-09-13 Thread Andrew Pinski


On Sep 13, 2005, at 6:36 PM, dann at godzilla dot ics dot uci dot edu 
wrote:




But the above just fixes the symptoms, it's probably not the correct
way to test for a nested function.


DECL_NO_STATIC_CHAIN (decl) should be true for this function but
why is it not?


/* In a FUNCTION_DECL with a nonzero DECL_CONTEXT, indicates that a
   static chain is not needed.  */
#define DECL_NO_STATIC_CHAIN(NODE) \
  (FUNCTION_DECL_CHECK (NODE)->function_decl.regdecl_flag)

-- Pinski



[Bug middle-end/23828] local calling convention not used when using -fwhole-program --combine

2005-09-13 Thread dann at godzilla dot ics dot uci dot edu

--- Additional Comments From dann at godzilla dot ics dot uci dot edu  
2005-09-13 22:36 ---
It looks like the -fwhole-program version of ClearLeft only passes the
first 2 arguments to the ClearInLine call in register, the 3rd one is
passed on the stack. 
The reason for that is this code in i386.c:ix86_function_regparm:

   /* We can't use regparm(3) for nested functions as these use
  static chain pointer in third argument.  */
   if (local_regparm == 3 && DECL_CONTEXT (decl)
   && !DECL_NO_STATIC_CHAIN (decl))
  local_regparm = 2;

The test for nested functions is incorrect, in the -fwhole-program
case DECL_CONTEXT (DECL_for_ClearLeft) is a TRANSLATION_UNIT_DECL so
the test is true even though it should not be.

Changing the code to:

  if (local_regparm == 3
  && DECL_CONTEXT (decl)
  && (TREE_CODE (DECL_CONTEXT (decl)) != TRANSLATION_UNIT_DECL)
  && !DECL_NO_STATIC_CHAIN (decl))
  local_regparm = 2;

fixes the testcase. 

But the above just fixes the symptoms, it's probably not the correct
way to test for a nested function.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23828


[Bug middle-end/23828] local calling convention not used when using -fwhole-program --combine

2005-09-13 Thread rguenth at gcc dot gnu dot org

--- Additional Comments From rguenth at gcc dot gnu dot org  2005-09-13 
10:42 ---
We do not CONFIRM bugs without a small testcase (which would be 2 small files in
this case).  Even if I could "confirm" it (I didn't try to reproduce with the
PR22574 testcase).

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23828


[Bug middle-end/23828] local calling convention not used when using -fwhole-program --combine

2005-09-12 Thread dann at godzilla dot ics dot uci dot edu

--- Additional Comments From dann at godzilla dot ics dot uci dot edu  
2005-09-12 23:30 ---
(In reply to comment #1)
> If it changes calling-conventions
> in single-file compile mode the function must be declared static, so it
> definitely may be changed in whole-program mode, too.

Yep, both ClearLeft and ClearInLine are declared static.
It's interesting that both ClearLeft and ClearInLine appear on the
"Marking local functions:" line in the i00.cgraph dump.

Can you confirm this bug?

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23828


[Bug middle-end/23828] local calling convention not used when using -fwhole-program --combine

2005-09-12 Thread rguenth at gcc dot gnu dot org

--- Additional Comments From rguenth at gcc dot gnu dot org  2005-09-12 
08:10 ---
The testcase is definitely too large and trying to create a simple two-file
based one didn't work out to reproduce the problem.  If it changes
calling-conventions
in single-file compile mode the function must be declared static, so it
definitely may be changed in whole-program mode, too.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23828


[Bug middle-end/23828] local calling convention not used when using -fwhole-program --combine

2005-09-11 Thread pinskia at gcc dot gnu dot org


-- 
   What|Removed |Added

  Component|rtl-optimization|middle-end
   Keywords||missed-optimization


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23828