Bug creation and email sending has been disabled, file new bugs at gcc.gnu.org/bugzilla

Bug 37

Summary: Inlining fails for functions with const parameters
Product: GDC Reporter: Johannes Pfau <johannespfau>
Component: gdcAssignee: Iain Buclaw <ibuclaw>
Status: RESOLVED FIXED    
Severity: minor    
Priority: ---    
Version: development   
Hardware: x86_64   
OS: Linux   

Description Johannes Pfau 2013-02-19 08:33:03 CET
gdc/gcc fails to inline bar in this example:

> struct S
> {
>      int bar(const S s)
>      {
>          return 0;
>      }
> }
> 
> int foo()
> {
>      S s;
>      return s.bar(s);
> }

compile with -c -O3 -finline-functions -frelease

When forcing inlining, this is the error message:
error: inlining failed in call to always_inline ?main.Julia!(float).ComplexStruct.squarePlusMag?: mismatched arguments

Reported by jerro in the gdc newsgroup.
Comment 1 Iain Buclaw 2013-02-19 09:24:42 CET
When you say force inlining, I take it you mean you are doing some trickery in the debugger. :-)
Comment 2 Johannes Pfau 2013-02-19 11:43:55 CET
No, that error message was also reported by jerro and he added some pragma(always_inline) implementation to his copy of gdc.

The error is reported either from ipa-inline.c or from ipa-inline-analysis.c, grep for "CIF_MISMATCHED_ARGUMENTS". Both check for call_stmt_cannot_inline_p which is probably set in ipa-inline.c:

if (edge->callee->symbol.decl
  && !gimple_check_call_matching_types 
      (edge->call_stmt,	edge->callee->symbol.decl))
  edge->call_stmt_cannot_inline_p = true;

gimple_check_call_matching_types is declared in gimple-low.c
Comment 3 Iain Buclaw 2013-02-19 12:59:31 CET
That's lovely.  always_inline attribute has been removed from the set of available pragmas.  Actually I might remove all gcc-related pragmas in the near future and replace with @attributes instead.  But that's open for discussion on how best to proceed.