public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/113996] New: ICE with LTO and full optimizations
@ 2024-02-19 16:14 jcmoyer32 at gmail dot com
  2024-02-19 21:41 ` [Bug ipa/113996] [11/12/13/14 Regression] ICE with LTO at -O2 and above with some Ada code pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jcmoyer32 at gmail dot com @ 2024-02-19 16:14 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113996
           Summary: ICE with LTO and full optimizations
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jcmoyer32 at gmail dot com
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

Building the following program with `gnatmake example.adb -O2 -gnatp -flto`
causes an ICE:

--------------------------------

with Ada.Containers.Hashed_Maps;
with Ada.Strings.Hash;

procedure example is
   subtype Node_Name is String (1 .. 4);

   package Node_Maps is new Ada.Containers.Hashed_Maps
     (Key_Type        => Node_Name,
      Element_Type    => Integer,
      Hash            => Ada.Strings.Hash,
      Equivalent_Keys => "=");
begin
   null;
end example;

--------------------------------

[x@arch ~]# gnatmake -f example.adb -O2 -gnatp -flto
gcc -c -O2 -gnatp -flto example.adb
gnatbind -x example.ali
gnatlink example.ali -O2 -flto
during IPA pass: inline
In function ‘example__node_maps__find_equal_key’,
    inlined from ‘example__node_maps__is_equal’ at
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/adainclude/a-chtgop.adb:410:20,
    inlined from ‘example__node_maps__Oeq__3’ at
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/adainclude/a-cohama.adb:128:14:
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/adainclude/a-cohama.adb:500:46:
internal compiler error: in initialize_inlined_parameters, at
tree-inline.cc:3659
  500 |       R_Index : constant Hash_Type := Key_Ops.Index (R_HT, L_Node.Key);
      |                                              ^
0x1851644 internal_error(char const*, ...)
        ???:0
0x67856f fancy_abort(char const*, int, char const*)
        ???:0
0xc20fe1 optimize_inline_calls(tree_node*)
        ???:0
0x9629cb inline_transform(cgraph_node*)
        ???:0
0xaf423f execute_all_ipa_transforms(bool)
        ???:0
0x76c19e cgraph_node::expand()
        ???:0
0x6d86f3 lto_main()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.archlinux.org/> for instructions.
lto-wrapper: fatal error: /usr/bin/gcc returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
gnatlink: error when calling /usr/bin/gcc
gnatmake: *** link failed.

--------------------------------

I've tested this on:

- Arch Linux 6.5.9 + gcc 13.2.1: ICE
- Windows 10 + gcc 13.2.0 from MSYS2-mingw64: ICE
- godbolt: all versions of gnat from 9.x onwards: ICE; 8.x successfully
compiles

There are several workarounds I've found; each of these produces a successful
compile:

- Provide my own hash function
- Copy the implementation of Ada.Strings.Hash to my source file and use that
one
- Drop the optimization level from -O2 to -O1
- Remove -gnatp
- Remove -flto (replacing it with -gnatn also works)

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

* [Bug ipa/113996] [11/12/13/14 Regression] ICE with LTO at -O2 and above with some Ada code
  2024-02-19 16:14 [Bug ada/113996] New: ICE with LTO and full optimizations jcmoyer32 at gmail dot com
@ 2024-02-19 21:41 ` pinskia at gcc dot gnu.org
  2024-02-20  8:10 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-19 21:41 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
      Known to work|                            |8.1.0
            Summary|ICE with LTO and full       |[11/12/13/14 Regression]
                   |optimizations               |ICE with LTO at -O2 and
                   |                            |above with some Ada code
          Component|ada                         |ipa
   Target Milestone|---                         |11.5
      Known to fail|                            |9.1.0

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

* [Bug ipa/113996] [11/12/13/14 Regression] ICE with LTO at -O2 and above with some Ada code
  2024-02-19 16:14 [Bug ada/113996] New: ICE with LTO and full optimizations jcmoyer32 at gmail dot com
  2024-02-19 21:41 ` [Bug ipa/113996] [11/12/13/14 Regression] ICE with LTO at -O2 and above with some Ada code pinskia at gcc dot gnu.org
@ 2024-02-20  8:10 ` rguenth at gcc dot gnu.org
  2024-02-20 14:35 ` jcmoyer32 at gmail dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-02-20  8:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |lto

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
You could also try whether -fwhole-program instead of -flto reproduces the
issue.

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

* [Bug ipa/113996] [11/12/13/14 Regression] ICE with LTO at -O2 and above with some Ada code
  2024-02-19 16:14 [Bug ada/113996] New: ICE with LTO and full optimizations jcmoyer32 at gmail dot com
  2024-02-19 21:41 ` [Bug ipa/113996] [11/12/13/14 Regression] ICE with LTO at -O2 and above with some Ada code pinskia at gcc dot gnu.org
  2024-02-20  8:10 ` rguenth at gcc dot gnu.org
@ 2024-02-20 14:35 ` jcmoyer32 at gmail dot com
  2024-02-26 10:32 ` ebotcazou at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jcmoyer32 at gmail dot com @ 2024-02-20 14:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from J.C. Moyer <jcmoyer32 at gmail dot com> ---
(In reply to Richard Biener from comment #1)
> You could also try whether -fwhole-program instead of -flto reproduces the
> issue.

-fwhole-program also works.

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

* [Bug ipa/113996] [11/12/13/14 Regression] ICE with LTO at -O2 and above with some Ada code
  2024-02-19 16:14 [Bug ada/113996] New: ICE with LTO and full optimizations jcmoyer32 at gmail dot com
                   ` (2 preceding siblings ...)
  2024-02-20 14:35 ` jcmoyer32 at gmail dot com
@ 2024-02-26 10:32 ` ebotcazou at gcc dot gnu.org
  2024-03-07 20:39 ` law at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-02-26 10:32 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu.org
   Last reconfirmed|                            |2024-02-26
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
A good reason not to compile with -gnatp. ;-)  It's this assertion:

  /* Initialize the static chain.  */
  p = DECL_STRUCT_FUNCTION (fn)->static_chain_decl;
  gcc_assert (fn != current_function_decl);
  if (p)
    {
      /* No static chain?  Seems like a bug in tree-nested.cc.  */
      gcc_assert (static_chain);

      setup_one_parameter (id, p, static_chain, fn, bb, &vars);
    }

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

* [Bug ipa/113996] [11/12/13/14 Regression] ICE with LTO at -O2 and above with some Ada code
  2024-02-19 16:14 [Bug ada/113996] New: ICE with LTO and full optimizations jcmoyer32 at gmail dot com
                   ` (3 preceding siblings ...)
  2024-02-26 10:32 ` ebotcazou at gcc dot gnu.org
@ 2024-03-07 20:39 ` law at gcc dot gnu.org
  2024-03-08 14:04 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-07 20:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug ipa/113996] [11/12/13/14 Regression] ICE with LTO at -O2 and above with some Ada code
  2024-02-19 16:14 [Bug ada/113996] New: ICE with LTO and full optimizations jcmoyer32 at gmail dot com
                   ` (4 preceding siblings ...)
  2024-03-07 20:39 ` law at gcc dot gnu.org
@ 2024-03-08 14:04 ` jakub at gcc dot gnu.org
  2024-03-08 18:46 ` ebotcazou at gcc dot gnu.org
  2024-03-20 23:23 ` [Bug ipa/113996] [11/12/13/14 regression] ICE with LTO at -O2 on " ebotcazou at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-03-08 14:04 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Ada is not primary FE and this is not a recent regression.

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

* [Bug ipa/113996] [11/12/13/14 Regression] ICE with LTO at -O2 and above with some Ada code
  2024-02-19 16:14 [Bug ada/113996] New: ICE with LTO and full optimizations jcmoyer32 at gmail dot com
                   ` (5 preceding siblings ...)
  2024-03-08 14:04 ` jakub at gcc dot gnu.org
@ 2024-03-08 18:46 ` ebotcazou at gcc dot gnu.org
  2024-03-20 23:23 ` [Bug ipa/113996] [11/12/13/14 regression] ICE with LTO at -O2 on " ebotcazou at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-03-08 18:46 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

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

--- Comment #5 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
I'll have a look.

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

* [Bug ipa/113996] [11/12/13/14 regression] ICE with LTO at -O2 on Ada code
  2024-02-19 16:14 [Bug ada/113996] New: ICE with LTO and full optimizations jcmoyer32 at gmail dot com
                   ` (6 preceding siblings ...)
  2024-03-08 18:46 ` ebotcazou at gcc dot gnu.org
@ 2024-03-20 23:23 ` ebotcazou at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-03-20 23:23 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

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

--- Comment #6 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Discussion at https://gcc.gnu.org/pipermail/gcc-patches/2024-March/647571.html

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

end of thread, other threads:[~2024-03-20 23:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19 16:14 [Bug ada/113996] New: ICE with LTO and full optimizations jcmoyer32 at gmail dot com
2024-02-19 21:41 ` [Bug ipa/113996] [11/12/13/14 Regression] ICE with LTO at -O2 and above with some Ada code pinskia at gcc dot gnu.org
2024-02-20  8:10 ` rguenth at gcc dot gnu.org
2024-02-20 14:35 ` jcmoyer32 at gmail dot com
2024-02-26 10:32 ` ebotcazou at gcc dot gnu.org
2024-03-07 20:39 ` law at gcc dot gnu.org
2024-03-08 14:04 ` jakub at gcc dot gnu.org
2024-03-08 18:46 ` ebotcazou at gcc dot gnu.org
2024-03-20 23:23 ` [Bug ipa/113996] [11/12/13/14 regression] ICE with LTO at -O2 on " ebotcazou 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).