Bug creation and email sending has been disabled, file new bugs at gcc.gnu.org/bugzilla
Bug 37 - Inlining fails for functions with const parameters
Summary: Inlining fails for functions with const parameters
Status: RESOLVED FIXED
Alias: None
Product: GDC
Classification: Unclassified
Component: gdc (show other bugs)
Version: development
Hardware: x86_64 Linux
: --- minor
Assignee: Iain Buclaw
URL:
Depends on:
Blocks:
 
Reported: 2013-02-19 08:33 CET by Johannes Pfau
Modified: 2013-03-04 13:07 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.