public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0
@ 2024-05-10 15:44 reiter.christoph at gmail dot com
  2024-05-11 12:15 ` [Bug target/115038] " reiter.christoph at gmail dot com
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: reiter.christoph at gmail dot com @ 2024-05-10 15:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115038
           Summary: ICE in seh_cfa_offset since 14.1.0
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: reiter.christoph at gmail dot com
  Target Milestone: ---

Downstream issue: https://github.com/msys2/MINGW-packages/issues/20861

The following code using GCC 14.1.0 on Windows targeting x86_64-w64-mingw32:

```
// gcc -c -fno-omit-frame-pointer -O2 repro.cpp
template <typename a> void b(a, a);
template <typename a> void c(a, a, float);
float d;
void e() {
  float f;
  c(f, f, d);
  b(0.0f, f);
}
```

results in

```
repro.cpp: In function 'void e()':
repro.cpp:8:1: internal compiler error: in seh_cfa_offset, at
config/i386/winnt.cc:1137
    8 | }
      | ^
```

* Replacing "-O2" with "-O1" fixes the issue
* Removing "-fno-omit-frame-pointer" fixes the issue
* Downgrading to GCC 13.2.0 fixes the issue

If there is any other information I can provide, let me know.

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

* [Bug target/115038] ICE in seh_cfa_offset since 14.1.0
  2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
@ 2024-05-11 12:15 ` reiter.christoph at gmail dot com
  2024-05-12 15:42 ` [Bug target/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer ebotcazou at gcc dot gnu.org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: reiter.christoph at gmail dot com @ 2024-05-11 12:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Christoph Reiter <reiter.christoph at gmail dot com> ---
Another downstream report with the same error:
https://github.com/msys2/MINGW-packages/issues/20864

I've c-reduced that as well to:

```
// gcc -c -fno-omit-frame-pointer -O2 repro.cpp
struct d {
  d();
};
struct e {
  e() : c(1.0) {}
  float c;
};
struct j {
  using ad = d;
};
class k : j {
  d g;
  e h;
};
template <typename, typename, typename, typename> using i = k;
class {
  i<int, int, int, int> f;
} a;
k b;
```

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

* [Bug target/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
  2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
  2024-05-11 12:15 ` [Bug target/115038] " reiter.christoph at gmail dot com
@ 2024-05-12 15:42 ` ebotcazou at gcc dot gnu.org
  2024-05-12 16:00 ` ebotcazou at gcc dot gnu.org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-05-12 15:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu.org
   Target Milestone|---                         |14.2
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-05-12
            Summary|ICE in seh_cfa_offset since |[14/15 regression] internal
                   |14.1.0                      |error in seh_cfa_offset
                   |                            |with -O2
                   |                            |-fno-omit-frame-pointer

--- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
I can reproduce.

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

* [Bug target/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
  2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
  2024-05-11 12:15 ` [Bug target/115038] " reiter.christoph at gmail dot com
  2024-05-12 15:42 ` [Bug target/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer ebotcazou at gcc dot gnu.org
@ 2024-05-12 16:00 ` ebotcazou at gcc dot gnu.org
  2024-05-12 16:33 ` ebotcazou at gcc dot gnu.org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-05-12 16:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
It's the -ffold-mem-offsets pass messing up with the prologue and the
frame-related instructions (so -fno-fold-mem-offsets is a workaround).

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

* [Bug target/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
  2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
                   ` (2 preceding siblings ...)
  2024-05-12 16:00 ` ebotcazou at gcc dot gnu.org
@ 2024-05-12 16:33 ` ebotcazou at gcc dot gnu.org
  2024-05-12 18:15 ` reiter.christoph at gmail dot com
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-05-12 16:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Tentative fixlet:

diff --git a/gcc/fold-mem-offsets.cc b/gcc/fold-mem-offsets.cc
index 2e15b05529e..84b9623058b 100644
--- a/gcc/fold-mem-offsets.cc
+++ b/gcc/fold-mem-offsets.cc
@@ -491,7 +491,7 @@ fold_offsets (rtx_insn *insn, rtx reg, bool analyze, bitmap
foldable_insns)
 {
   rtx_insn *def = get_single_def_in_bb (insn, reg);

-  if (!def || GET_CODE (PATTERN (def)) != SET)
+  if (!def || RTX_FRAME_RELATED_P (def) || GET_CODE (PATTERN (def)) != SET)
     return 0;

   rtx dest = SET_DEST (PATTERN (def));

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

* [Bug target/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
  2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
                   ` (3 preceding siblings ...)
  2024-05-12 16:33 ` ebotcazou at gcc dot gnu.org
@ 2024-05-12 18:15 ` reiter.christoph at gmail dot com
  2024-05-13  5:45 ` reiter.christoph at gmail dot com
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: reiter.christoph at gmail dot com @ 2024-05-12 18:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Christoph Reiter <reiter.christoph at gmail dot com> ---
Thanks! I can confirm that "-fno-fold-mem-offsets" works around the issue. I'll
test the proposed patch tomorrow.

In the meantime we've reduced another instance of this when building emacs, but
this time with "simpler" C code and without -fno-omit-frame-pointer:

```
// gcc -c -O2 repro.c -> internal compiler error: in seh_cfa_offset
// gcc -c -g3 -O2 -gdwarf-2 repro.c -> internal compiler error: in
dwarf2out_frame_debug_expr
void a() {
    __builtin_unwind_init();
}
```

Adding this here for completeness.

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

* [Bug target/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
  2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
                   ` (4 preceding siblings ...)
  2024-05-12 18:15 ` reiter.christoph at gmail dot com
@ 2024-05-13  5:45 ` reiter.christoph at gmail dot com
  2024-05-13  9:35 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: reiter.christoph at gmail dot com @ 2024-05-13  5:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Christoph Reiter <reiter.christoph at gmail dot com> ---
I can confirm that the patch from comment 4 fixes all the above cases, and also
emacs builds again.

Thanks again

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

* [Bug target/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
  2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
                   ` (5 preceding siblings ...)
  2024-05-13  5:45 ` reiter.christoph at gmail dot com
@ 2024-05-13  9:35 ` rguenth at gcc dot gnu.org
  2024-05-20  6:25 ` [Bug rtl-optimization/115038] " ebotcazou at gcc dot gnu.org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-13  9:35 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
             Target|X86_64-mingw32              |x86_64-mingw32
      Known to work|                            |13.2.0

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

* [Bug rtl-optimization/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
  2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
                   ` (6 preceding siblings ...)
  2024-05-13  9:35 ` rguenth at gcc dot gnu.org
@ 2024-05-20  6:25 ` ebotcazou at gcc dot gnu.org
  2024-05-20  7:12 ` ebotcazou at gcc dot gnu.org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-05-20  6:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|target                      |rtl-optimization
           Keywords|EH                          |

--- Comment #7 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Recategorizing.

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

* [Bug rtl-optimization/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
  2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
                   ` (7 preceding siblings ...)
  2024-05-20  6:25 ` [Bug rtl-optimization/115038] " ebotcazou at gcc dot gnu.org
@ 2024-05-20  7:12 ` ebotcazou at gcc dot gnu.org
  2024-05-22 14:48 ` law at gcc dot gnu.org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-05-20  7:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

* [Bug rtl-optimization/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
  2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
                   ` (8 preceding siblings ...)
  2024-05-20  7:12 ` ebotcazou at gcc dot gnu.org
@ 2024-05-22 14:48 ` law at gcc dot gnu.org
  2024-05-22 16:04 ` ebotcazou at gcc dot gnu.org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: law at gcc dot gnu.org @ 2024-05-22 14:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Yea, I would think we want to avoid anything marked as frame related. 
Otherwise we have to go back and fixup the CFI nodes and such.

Eric, do you want to handle the final bootstrap+regression test?  Or do you
want me to take it from here?

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

* [Bug rtl-optimization/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
  2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
                   ` (9 preceding siblings ...)
  2024-05-22 14:48 ` law at gcc dot gnu.org
@ 2024-05-22 16:04 ` ebotcazou at gcc dot gnu.org
  2024-05-22 16:14 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-05-22 16:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> Eric, do you want to handle the final bootstrap+regression test?  Or do you
> want me to take it from here?

I can do it right now.

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

* [Bug rtl-optimization/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
  2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
                   ` (10 preceding siblings ...)
  2024-05-22 16:04 ` ebotcazou at gcc dot gnu.org
@ 2024-05-22 16:14 ` cvs-commit at gcc dot gnu.org
  2024-05-22 18:54 ` cvs-commit at gcc dot gnu.org
  2024-05-22 18:55 ` ebotcazou at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-22 16:14 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:f14ef5cfd4c1ba1d34afda9174935e40d3c0a3ce

commit r15-776-gf14ef5cfd4c1ba1d34afda9174935e40d3c0a3ce
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Wed May 22 18:10:39 2024 +0200

    Fix internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer

    The problem directly comes from the -ffold-mem-offsets pass messing up with
    the prologue and the frame-related instructions, which is a no-no with SEH,
    so the fix simply disconnects the pass in these circumstances.

    gcc/
            PR rtl-optimization/115038
            * fold-mem-offsets.cc (fold_offsets): Return 0 if the defining
            instruction of the register is frame related.

    gcc/testsuite/
            * g++.dg/opt/fmo1.C: New test.

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

* [Bug rtl-optimization/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
  2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
                   ` (11 preceding siblings ...)
  2024-05-22 16:14 ` cvs-commit at gcc dot gnu.org
@ 2024-05-22 18:54 ` cvs-commit at gcc dot gnu.org
  2024-05-22 18:55 ` ebotcazou at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-22 18:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Eric Botcazou
<ebotcazou@gcc.gnu.org>:

https://gcc.gnu.org/g:2f0e0862406a17bb8bf4ad948ae22916bae092a0

commit r14-10233-g2f0e0862406a17bb8bf4ad948ae22916bae092a0
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Wed May 22 18:10:39 2024 +0200

    Fix internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer

    The problem directly comes from the -ffold-mem-offsets pass messing up with
    the prologue and the frame-related instructions, which is a no-no with SEH,
    so the fix simply disconnects the pass in these circumstances.

    gcc/
            PR rtl-optimization/115038
            * fold-mem-offsets.cc (fold_offsets): Return 0 if the defining
            instruction of the register is frame related.

    gcc/testsuite/
            * g++.dg/opt/fmo1.C: New test.

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

* [Bug rtl-optimization/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer
  2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
                   ` (12 preceding siblings ...)
  2024-05-22 18:54 ` cvs-commit at gcc dot gnu.org
@ 2024-05-22 18:55 ` ebotcazou at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-05-22 18:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #12 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Thanks for reporting the problem.

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

end of thread, other threads:[~2024-05-22 18:55 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-10 15:44 [Bug c++/115038] New: ICE in seh_cfa_offset since 14.1.0 reiter.christoph at gmail dot com
2024-05-11 12:15 ` [Bug target/115038] " reiter.christoph at gmail dot com
2024-05-12 15:42 ` [Bug target/115038] [14/15 regression] internal error in seh_cfa_offset with -O2 -fno-omit-frame-pointer ebotcazou at gcc dot gnu.org
2024-05-12 16:00 ` ebotcazou at gcc dot gnu.org
2024-05-12 16:33 ` ebotcazou at gcc dot gnu.org
2024-05-12 18:15 ` reiter.christoph at gmail dot com
2024-05-13  5:45 ` reiter.christoph at gmail dot com
2024-05-13  9:35 ` rguenth at gcc dot gnu.org
2024-05-20  6:25 ` [Bug rtl-optimization/115038] " ebotcazou at gcc dot gnu.org
2024-05-20  7:12 ` ebotcazou at gcc dot gnu.org
2024-05-22 14:48 ` law at gcc dot gnu.org
2024-05-22 16:04 ` ebotcazou at gcc dot gnu.org
2024-05-22 16:14 ` cvs-commit at gcc dot gnu.org
2024-05-22 18:54 ` cvs-commit at gcc dot gnu.org
2024-05-22 18:55 ` 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).