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

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).