------- 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

Reply via email to