Print this page
Implement -fstrict-calling-conventions
Stock GCC is overly willing to violate the ABI when calling local functions,
such that it passes arguments in registers on i386.  This hampers debugging
with anything other than a fully-aware DWARF debugger, and is generally not
something we desire.
Implement a flag which disables this behaviour, enabled by default.  The flag is
global, though only effective on i386, to more easily allow its globalization
later which, given the odds, is likely to be necessary.

Split Close
Expand all
Collapse all
          --- old/gcc/config/i386/i386.c
          +++ new/gcc/config/i386/i386.c
↓ open down ↓ 4395 lines elided ↑ open up ↑
4396 4396        return regparm;
4397 4397      }
4398 4398  
4399 4399    if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (type)))
4400 4400      return 2;
4401 4401  
4402 4402    /* Use register calling convention for local functions when possible.  */
4403 4403    if (decl
4404 4404        && TREE_CODE (decl) == FUNCTION_DECL
4405 4405        && optimize
     4406 +      && (TARGET_64BIT || !flag_strict_calling_conventions)
4406 4407        && !profile_flag)
4407 4408      {
4408 4409        /* FIXME: remove this CONST_CAST when cgraph.[ch] is constified.  */
4409 4410        struct cgraph_local_info *i = cgraph_local_info (CONST_CAST_TREE(decl));
4410 4411        if (i && i->local)
4411 4412          {
4412 4413            int local_regparm, globals = 0, regno;
4413 4414            struct function *f;
4414 4415  
4415 4416            /* Make sure no regparm register is taken by a
↓ open down ↓ 64 lines elided ↑ open up ↑
4480 4481                         "SSE/SSE2 enabled", type);
4481 4482              }
4482 4483            return 0;
4483 4484          }
4484 4485  
4485 4486        return 2;
4486 4487      }
4487 4488  
4488 4489    /* For local functions, pass up to SSE_REGPARM_MAX SFmode
4489 4490       (and DFmode for SSE2) arguments in SSE registers.  */
4490      -  if (decl && TARGET_SSE_MATH && optimize && !profile_flag)
     4491 +  if (decl && TARGET_SSE_MATH && optimize && !profile_flag &&
     4492 +    (TARGET_64BIT || !flag_strict_calling_conventions))
4491 4493      {
4492 4494        /* FIXME: remove this CONST_CAST when cgraph.[ch] is constified.  */
4493 4495        struct cgraph_local_info *i = cgraph_local_info (CONST_CAST_TREE(decl));
4494 4496        if (i && i->local)
4495 4497          return TARGET_SSE2 ? 2 : 1;
4496 4498      }
4497 4499  
4498 4500    return 0;
4499 4501  }
4500 4502  
↓ open down ↓ 25541 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX