public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/113291] New: [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above
@ 2024-01-09 14:00 zsojka at seznam dot cz
  2024-01-09 17:55 ` [Bug ipa/113291] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: zsojka at seznam dot cz @ 2024-01-09 14:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113291

            Bug ID: 113291
           Summary: [14 Regression] compilation never (?) finishes with
                    recursive always_inline functions at -O and above
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu

Created attachment 57015
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57015&action=edit
reduced testcase

Compiler output:
$ time x86_64-pc-linux-gnu-gcc -O testcase.c -Wall -W
testcase.c:13:1: warning: 'always_inline' function might not be inlinable
[-Wattributes]
   13 | f1 (void)
      | ^~
testcase.c:6:1: warning: 'always_inline' function might not be inlinable
[-Wattributes]
    6 | f0 (void)
      | ^~
testcase.c: In function 'f0':
testcase.c:6:1: warning: infinite recursion detected [-Winfinite-recursion]
In function 'f1',
    inlined from 'f0' at testcase.c:8:3:
testcase.c:16:3: note: recursive call
   16 |   f0 ();
      |   ^~~~~
testcase.c: In function 'f1':
testcase.c:13:1: warning: infinite recursion detected [-Winfinite-recursion]
   13 | f1 (void)
      | ^~
testcase.c:15:3: note: recursive call
   15 |   f1 ();
      |   ^~~~~
^C

real    1m21.533s
user    0m0.002s
sys     0m0.000s


$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r14-7023-20240109134751-gab6224dfe12-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--disable-bootstrap --with-cloog --with-ppl --with-isl
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r14-7023-20240109134751-gab6224dfe12-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.0 20240109 (experimental) (GCC)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug ipa/113291] [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above
  2024-01-09 14:00 [Bug ipa/113291] New: [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above zsojka at seznam dot cz
@ 2024-01-09 17:55 ` pinskia at gcc dot gnu.org
  2024-01-09 18:38 ` pinskia at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-09 17:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113291

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug ipa/113291] [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above
  2024-01-09 14:00 [Bug ipa/113291] New: [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above zsojka at seznam dot cz
  2024-01-09 17:55 ` [Bug ipa/113291] " pinskia at gcc dot gnu.org
@ 2024-01-09 18:38 ` pinskia at gcc dot gnu.org
  2024-01-10 13:15 ` [Bug ipa/113291] [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above since r14-2172 jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-09 18:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113291

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-01-09
     Ever confirmed|0                           |1
           Keywords|                            |needs-bisection
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, GCC 13 used to reject this:
```

<source>: In function 'f1':
<source>:6:1: error: inlining failed in call to 'always_inline' 'f0': function
not inlinable
<source>:16:3: note: called from here
   16 |   f0 ();
      |   ^~~~~
```

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug ipa/113291] [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above since r14-2172
  2024-01-09 14:00 [Bug ipa/113291] New: [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above zsojka at seznam dot cz
  2024-01-09 17:55 ` [Bug ipa/113291] " pinskia at gcc dot gnu.org
  2024-01-09 18:38 ` pinskia at gcc dot gnu.org
@ 2024-01-10 13:15 ` jakub at gcc dot gnu.org
  2024-01-11 12:14 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-01-10 13:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113291

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |
                 CC|                            |hubicka at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org
            Summary|[14 Regression] compilation |[14 Regression] compilation
                   |never (?) finishes with     |never (?) finishes with
                   |recursive always_inline     |recursive always_inline
                   |functions at -O and above   |functions at -O and above
                   |                            |since r14-2172
           Priority|P3                          |P1

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r14-2172-gd88fd2e1d0720e6f892da9ff48e9a301a7ad0ad4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug ipa/113291] [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above since r14-2172
  2024-01-09 14:00 [Bug ipa/113291] New: [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2024-01-10 13:15 ` [Bug ipa/113291] [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above since r14-2172 jakub at gcc dot gnu.org
@ 2024-01-11 12:14 ` rguenth at gcc dot gnu.org
  2024-02-14 16:07 ` hubicka at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-11 12:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113291

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
We're endlessly inlining during IPA.  Honza, please have a look.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug ipa/113291] [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above since r14-2172
  2024-01-09 14:00 [Bug ipa/113291] New: [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2024-01-11 12:14 ` rguenth at gcc dot gnu.org
@ 2024-02-14 16:07 ` hubicka at gcc dot gnu.org
  2024-02-14 16:26 ` hubicka at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hubicka at gcc dot gnu.org @ 2024-02-14 16:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113291

--- Comment #4 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
There is a cap in want_inline_self_recursive_call_p which gives up on inlining
after reaching max recursive inlining depth of 8. Problem is that the tree here
is too wide. After early inlining f0 contains 4 calls to f1 and

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug ipa/113291] [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above since r14-2172
  2024-01-09 14:00 [Bug ipa/113291] New: [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2024-02-14 16:07 ` hubicka at gcc dot gnu.org
@ 2024-02-14 16:26 ` hubicka at gcc dot gnu.org
  2024-02-14 17:14 ` hubicka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hubicka at gcc dot gnu.org @ 2024-02-14 16:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113291

--- Comment #5 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
There is a cap in want_inline_self_recursive_call_p which gives up on inlining
after reaching max recursive inlining depth of 8. Problem is that the tree here
is too wide. After early inlining f0 contains 4 calls to f1 and 3 calls to f0.
Similarly for f0, so we have something like (9+3*9)^8 as a cap on number of
inlines that takes a while to converge.

One may want to limit number of copies of function A within function B rather
than depth, but that number can be large even for sane code.

I am making patch to make inliner to ignore always_inline on all self-recrusive
inline decisions.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug ipa/113291] [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above since r14-2172
  2024-01-09 14:00 [Bug ipa/113291] New: [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2024-02-14 16:26 ` hubicka at gcc dot gnu.org
@ 2024-02-14 17:14 ` hubicka at gcc dot gnu.org
  2024-03-26 10:41 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hubicka at gcc dot gnu.org @ 2024-02-14 17:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113291

--- Comment #6 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Created attachment 57427
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57427&action=edit
patch

The patch makes compilation to finish in reasonable time.
I ended up in need to dropping DISREGARD_INLINE_LIMITS in late inlining for
functions with self recursive always inlines, since these grow large quick and
even non-recursive inlining is too slow.  We also end up with quite ugly
diagnostics of form:

tt.c:13:1: error: inlining failed in call to ‘always_inline’ ‘f1’: --param
max-inline-insns-auto limit reached
   13 | f1 (void)
      | ^~
tt.c:17:3: note: called from here
   17 |   f1 ();
      |   ^~~~~
tt.c:6:1: error: inlining failed in call to ‘always_inline’ ‘f0’: --param
max-inline-insns-auto limit reached
    6 | f0 (void)
      | ^~
tt.c:16:3: note: called from here
   16 |   f0 ();
      |   ^~~~~
tt.c:13:1: error: inlining failed in call to ‘always_inline’ ‘f1’: --param
max-inline-insns-auto limit reached
   13 | f1 (void)
      | ^~
tt.c:15:3: note: called from here
   15 |   f1 ();
      |   ^~~~~
In function ‘f1’,
    inlined from ‘f0’ at tt.c:8:3,


which is quite large so I can not add it to a testuiste.  I will see if I can
reduce this even more.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug ipa/113291] [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above since r14-2172
  2024-01-09 14:00 [Bug ipa/113291] New: [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above zsojka at seznam dot cz
                   ` (6 preceding siblings ...)
  2024-02-14 17:14 ` hubicka at gcc dot gnu.org
@ 2024-03-26 10:41 ` rguenth at gcc dot gnu.org
  2024-04-09  9:50 ` hubicka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-26 10:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113291

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |hubicka at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Honza is working on this.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug ipa/113291] [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above since r14-2172
  2024-01-09 14:00 [Bug ipa/113291] New: [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above zsojka at seznam dot cz
                   ` (7 preceding siblings ...)
  2024-03-26 10:41 ` rguenth at gcc dot gnu.org
@ 2024-04-09  9:50 ` hubicka at gcc dot gnu.org
  2024-04-18 13:42 ` law at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: hubicka at gcc dot gnu.org @ 2024-04-09  9:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113291

--- Comment #8 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
I am not sure this ought to be P1:
 - the compilation technically is finite, but not in reasonable time
 - it is possible to adjust the testcas (do early inlining manually) and get
same infinite build on release branches
 - if you ask for inline bomb, you get it.

But after some more testing, I do not see reasonably easy way to get better
diagnostics. So I will retest the patch fro #6 and go ahead with it.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug ipa/113291] [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above since r14-2172
  2024-01-09 14:00 [Bug ipa/113291] New: [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above zsojka at seznam dot cz
                   ` (8 preceding siblings ...)
  2024-04-09  9:50 ` hubicka at gcc dot gnu.org
@ 2024-04-18 13:42 ` law at gcc dot gnu.org
  2024-05-07  7:43 ` [Bug ipa/113291] [14/15 " rguenth at gcc dot gnu.org
  2024-05-14 10:59 ` cvs-commit at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: law at gcc dot gnu.org @ 2024-04-18 13:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113291

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2
                 CC|                            |law at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug ipa/113291] [14/15 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above since r14-2172
  2024-01-09 14:00 [Bug ipa/113291] New: [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above zsojka at seznam dot cz
                   ` (9 preceding siblings ...)
  2024-04-18 13:42 ` law at gcc dot gnu.org
@ 2024-05-07  7:43 ` rguenth at gcc dot gnu.org
  2024-05-14 10:59 ` cvs-commit at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-07  7:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113291

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|14.0                        |14.2

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 14.1 is being released, retargeting bugs to GCC 14.2.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug ipa/113291] [14/15 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above since r14-2172
  2024-01-09 14:00 [Bug ipa/113291] New: [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above zsojka at seznam dot cz
                   ` (10 preceding siblings ...)
  2024-05-07  7:43 ` [Bug ipa/113291] [14/15 " rguenth at gcc dot gnu.org
@ 2024-05-14 10:59 ` cvs-commit at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-14 10:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113291

--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jan Hubicka <hubicka@gcc.gnu.org>:

https://gcc.gnu.org/g:1ec49897253e093e1ef6261eb104ac0c111bac83

commit r15-482-g1ec49897253e093e1ef6261eb104ac0c111bac83
Author: Jan Hubicka <jh@suse.cz>
Date:   Tue May 14 12:58:56 2024 +0200

    Reduce recursive inlining of always_inline functions

    this patch tames down inliner on (mutiply) self-recursive always_inline
functions.
    While we already have caps on recursive inlning, the testcase combines
early inliner
    and late inliner to get very wide recursive inlining tree.  The basic idea
is to
    ignore DISREGARD_INLINE_LIMITS when deciding on inlining self recursive
functions
    (so we cut on function being large) and clear the flag once it is detected.

    I did not include the testcase since it still produces a lot of code and
would
    slow down testing.  It also outputs many inlining failed messages that is
not
    very nice, but it is hard to detect self recursin cycles in full generality
    when indirect calls and other tricks may happen.

    gcc/ChangeLog:

            PR ipa/113291

            * ipa-inline.cc (enum can_inline_edge_by_limits_flags): New enum.
            (can_inline_edge_by_limits_p): Take flags instead of multiple
bools; add flag
            for forcing inlinie limits.
            (can_early_inline_edge_p): Update.
            (want_inline_self_recursive_call_p): Update; use FORCE_LIMITS mode.
            (check_callers): Update.
            (update_caller_keys): Update.
            (update_callee_keys): Update.
            (recursive_inlining): Update.
            (add_new_edges_to_heap): Update.
            (speculation_useful_p): Update.
            (inline_small_functions): Clear DECL_DISREGARD_INLINE_LIMITS on
self recursion.
            (flatten_function): Update.
            (inline_to_all_callers_1): Update.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-05-14 10:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-09 14:00 [Bug ipa/113291] New: [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above zsojka at seznam dot cz
2024-01-09 17:55 ` [Bug ipa/113291] " pinskia at gcc dot gnu.org
2024-01-09 18:38 ` pinskia at gcc dot gnu.org
2024-01-10 13:15 ` [Bug ipa/113291] [14 Regression] compilation never (?) finishes with recursive always_inline functions at -O and above since r14-2172 jakub at gcc dot gnu.org
2024-01-11 12:14 ` rguenth at gcc dot gnu.org
2024-02-14 16:07 ` hubicka at gcc dot gnu.org
2024-02-14 16:26 ` hubicka at gcc dot gnu.org
2024-02-14 17:14 ` hubicka at gcc dot gnu.org
2024-03-26 10:41 ` rguenth at gcc dot gnu.org
2024-04-09  9:50 ` hubicka at gcc dot gnu.org
2024-04-18 13:42 ` law at gcc dot gnu.org
2024-05-07  7:43 ` [Bug ipa/113291] [14/15 " rguenth at gcc dot gnu.org
2024-05-14 10:59 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).